code: def testEvaluateGraph(self):
      # Have 3 labels of values 3, 23, 16 and predictions of values 2, 2, 2.
      # This should give sum = 48 and mean = 8.
      examples = [
          self._makeExample(
              age=3.0, language="english", predictions=2.0, labels=3.0
          ),
          self._makeExample(
              age=3.0, language="chinese", predictions=2.0, labels=23.0
          ),
          self._makeExample(
              age=4.0, language="english", predictions=2.0, labels=16.0
          ),
      ]
      serialized_examples = [e.SerializeToString() for e in examples]
  
      # Set up a model agnostic config so we can get the FPLConfig.
      feature_map = {
          "age": tf.io.FixedLenFeature([], tf.float32),
          "language": tf.io.VarLenFeature(tf.string),
          "predictions": tf.io.FixedLenFeature([], tf.float32),
          "labels": tf.io.FixedLenFeature([], tf.float32),
      }
  
      model_agnostic_config = agnostic_predict.ModelAgnosticConfig(
          label_keys=["labels"],
          prediction_keys=["predictions"],
          feature_spec=feature_map,
      )
  
      # Create a Model Anostic Evaluate graph handler and feed in the FPL list.
      evaluate_graph = (
          model_agnostic_evaluate_graph.ModelAgnosticEvaluateGraph(
              [add_mean_callback], model_agnostic_config
          )
      )
      evaluate_graph.metrics_reset_update_get_list(serialized_examples)
      outputs = evaluate_graph.get_metric_values()
  
      # Verify that we got the right metrics out.
      self.assertEqual(2, len(outputs))
      self.assertEqual(outputs["tf_metric_mean"], 8.0)
      self.assertEqual(outputs["py_func_total_label"], 48.0)
  
file_path: model-analysis/tensorflow_model_analysis/model_agnostic_eval/model_agnostic_evaluate_graph_test.py
imports: import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  from tensorflow_model_analysis.api import model_eval_lib
  from tensorflow_model_analysis.api import tfma_unit
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.evaluators import legacy_metrics_and_plots_evaluator
  from tensorflow_model_analysis.extractors import slice_key_extractor
  from tensorflow_model_analysis.model_agnostic_eval import model_agnostic_evaluate_graph
  from tensorflow_model_analysis.model_agnostic_eval import model_agnostic_extractor
  from tensorflow_model_analysis.model_agnostic_eval import model_agnostic_predict
  from tensorflow_model_analysis.slicer import slicer_lib
label_desc: Use image node_id 1 for calling the ModelAgnosticEvaluateGraphTest obj's underlying member method code with example usage: obj.testEvaluateGraph() without return types