code: def testEvaluateWithEvalSavedModel(self):
      temp_export_dir = self._getExportDir()
      _, export_dir = linear_classifier.simple_linear_classifier(
          None, temp_export_dir
      )
      eval_config = config_pb2.EvalConfig(
          model_specs=[config_pb2.ModelSpec(signature_name="eval")],
          slicing_specs=[
              config_pb2.SlicingSpec(),
              config_pb2.SlicingSpec(feature_keys=["slice_key"]),
          ],
      )
      eval_shared_model = self.createTestEvalSharedModel(
          eval_saved_model_path=export_dir,
          add_metrics_callbacks=[_addExampleCountMetricCallback],
      )
      extractors = [
          legacy_predict_extractor.PredictExtractor(
              eval_shared_model, eval_config=eval_config
          ),
          unbatch_extractor.UnbatchExtractor(),
          slice_key_extractor.SliceKeyExtractor(
              eval_config=eval_config
          ),
      ]
      evaluators = [
          metrics_plots_and_validations_evaluator.MetricsPlotsAndValidationsEvaluator(
              eval_config=eval_config,
              eval_shared_model=eval_shared_model,
          )
      ]
  
      examples = [
          self._makeExample(
              age=3.0,
              language="english",
              label=1.0,
              slice_key="first_slice",
          ),
          self._makeExample(
              age=3.0,
              language="chinese",
              label=0.0,
              slice_key="first_slice",
          ),
          self._makeExample(
              age=4.0,
              language="english",
              label=0.0,
              slice_key="second_slice",
          ),
          self._makeExample(
              age=5.0,
              language="chinese",
              label=1.0,
              slice_key="second_slice",
          ),
          self._makeExample(
              age=5.0,
              language="chinese",
              label=1.0,
              slice_key="second_slice",
          ),
      ]
  
      tfx_io = raw_tf_record.RawBeamRecordTFXIO(
          physical_format="inmemory",
          raw_record_column_name=constants.ARROW_INPUT_COLUMN,
          telemetry_descriptors=["TFMATest"],
      )
      with beam.Pipeline() as pipeline:
          # pylint: disable=no-value-for-parameter
          metrics = (
              pipeline
              | "Create"
              >> beam.Create([e.SerializeToString() for e in examples])
              | "BatchExamples" >> tfx_io.BeamSource()
              | "InputsToExtracts"
              >> model_eval_lib.BatchedInputsToExtracts()
              | "ExtractAndEvaluate"
              >> model_eval_lib.ExtractAndEvaluate(
                  extractors=extractors, evaluators=evaluators
              )
          )
  
          # pylint: enable=no-value-for-parameter
  
          def check_metrics(got):
              try:
                  self.assertLen(got, 3)
                  slices = {}
                  for slice_key, value in got:
                      slices[slice_key] = value
                  overall_slice = ()
                  first_slice = (("slice_key", "first_slice"),)
                  second_slice = (("slice_key", "second_slice"),)
                  self.assertCountEqual(
                      list(slices),
                      [overall_slice, first_slice, second_slice],
                  )
                  self.assertDictElementsAlmostEqual(
                      slices[overall_slice],
                      {
                          metric_types.MetricKey(
                              name="accuracy", example_weighted=None
                          ): 0.4,
                          metric_types.MetricKey(
                              name="label/mean", example_weighted=None
                          ): 0.6,
                          metric_types.MetricKey(
                              name="my_mean_age", example_weighted=None
                          ): 4.0,
                          metric_types.MetricKey(
                              name="my_mean_age_times_label",
                              example_weighted=None,
                          ): 2.6,
                          metric_types.MetricKey(
                              name="added_example_count",
                              example_weighted=None,
                          ): 5.0,
                      },
                  )
                  self.assertDictElementsAlmostEqual(
                      slices[first_slice],
                      {
                          metric_types.MetricKey(
                              name="accuracy", example_weighted=None
                          ): 1.0,
                          metric_types.MetricKey(
                              name="label/mean", example_weighted=None
                          ): 0.5,
                          metric_types.MetricKey(
                              name="my_mean_age", example_weighted=None
                          ): 3.0,
                          metric_types.MetricKey(
                              name="my_mean_age_times_label",
                              example_weighted=None,
                          ): 1.5,
                          metric_types.MetricKey(
                              name="added_example_count",
                              example_weighted=None,
                          ): 2.0,
                      },
                  )
                  self.assertDictElementsAlmostEqual(
                      slices[second_slice],
                      {
                          metric_types.MetricKey(
                              name="accuracy", example_weighted=None
                          ): 0.0,
                          metric_types.MetricKey(
                              name="label/mean", example_weighted=None
                          ): 2.0
                          / 3.0,
                          metric_types.MetricKey(
                              name="my_mean_age", example_weighted=None
                          ): 14.0
                          / 3.0,
                          metric_types.MetricKey(
                              name="my_mean_age_times_label",
                              example_weighted=None,
                          ): 10.0
                          / 3.0,
                          metric_types.MetricKey(
                              name="added_example_count",
                              example_weighted=None,
                          ): 3.0,
                      },
                  )
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(
              metrics[constants.METRICS_KEY],
              check_metrics,
              label="metrics",
          )
  
imports: import os
  from absl.testing import parameterized
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.addons.fairness.metrics import lift
  from tensorflow_model_analysis.api import model_eval_lib
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.eval_saved_model.example_trainers import dnn_classifier
  from tensorflow_model_analysis.eval_saved_model.example_trainers import fixed_prediction_estimator_extra_fields
  from tensorflow_model_analysis.eval_saved_model.example_trainers import linear_classifier
  from tensorflow_model_analysis.eval_saved_model.example_trainers import multi_head
  from tensorflow_model_analysis.evaluators import metrics_plots_and_validations_evaluator
  from tensorflow_model_analysis.extractors import example_weights_extractor
  from tensorflow_model_analysis.extractors import features_extractor
  from tensorflow_model_analysis.extractors import labels_extractor
  from tensorflow_model_analysis.extractors import legacy_predict_extractor
  from tensorflow_model_analysis.extractors import materialized_predictions_extractor
  from tensorflow_model_analysis.extractors import predictions_extractor
  from tensorflow_model_analysis.extractors import slice_key_extractor
  from tensorflow_model_analysis.extractors import unbatch_extractor
  from tensorflow_model_analysis.metrics import attributions
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import calibration
  from tensorflow_model_analysis.metrics import calibration_plot
  from tensorflow_model_analysis.metrics import confusion_matrix_plot
  from tensorflow_model_analysis.metrics import metric_specs
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import ndcg
  from tensorflow_model_analysis.post_export_metrics import metrics
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import validation_result_pb2
  from tfx_bsl.tfxio import raw_tf_record
  from tfx_bsl.tfxio import tensor_adapter
  from tfx_bsl.tfxio import test_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 20 for calling the MetricsPlotsAndValidationsEvaluatorTest obj's underlying member method code with example usage: obj.testEvaluateWithEvalSavedModel() without return types