code: def testValidateWithEvalSavedModel(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")],
          metrics_specs=[
              config_pb2.MetricsSpec(
                  thresholds={
                      "accuracy": config_pb2.MetricThreshold(
                          value_threshold=config_pb2.GenericValueThreshold(
                              lower_bound={"value": 0.9}
                          )
                      ),
                      "nonexistent_metrics": config_pb2.MetricThreshold(
                          value_threshold=config_pb2.GenericValueThreshold(
                              lower_bound={"value": 0.1}
                          )
                      ),
                  }
              )
          ],
          slicing_specs=[
              config_pb2.SlicingSpec(),
          ],
      )
      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
          evaluations = (
              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_validations(got):
              try:
                  self.assertLen(got, 1)
                  got = got[0]
                  expected_failures = [
                      text_format.Parse(
                          """
                   metric_key {
                      name: "accuracy"
                    }
                    metric_threshold {
                      value_threshold {
                        lower_bound {
                          value: 0.9
                        }
                      }
                    }
                    """,
                          validation_result_pb2.ValidationFailure(),
                      ),
                      text_format.Parse(
                          """
                   metric_key {
                      name: "nonexistent_metrics"
                    }
                    metric_threshold {
                      value_threshold {
                        lower_bound {
                          value: 0.1
                        }
                      }
                    }
                    message: "Metric not found."
                    """,
                          validation_result_pb2.ValidationFailure(),
                      ),
                  ]
                  self.assertFalse(got.validation_ok)
                  self.assertLen(got.metric_validations_per_slice, 1)
                  # Ignore the metric_value to avoid fragility of float rounding issue.
                  # The correctness of the metric_value has been tested in other tests.
                  failures = got.metric_validations_per_slice[
                      0
                  ].failures
                  self.assertLen(failures, len(expected_failures))
                  for failure, expected_failure in zip(
                      failures, expected_failures
                  ):
                      failure.ClearField("metric_value")
                      self.assertProtoEquals(expected_failure, failure)
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(
              evaluations[constants.VALIDATIONS_KEY], check_validations
          )
  
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 21 for calling the MetricsPlotsAndValidationsEvaluatorTest obj's underlying member method code with example usage: obj.testValidateWithEvalSavedModel() without return types