code: def testRougeEnd2End(self):
      # Same tests as RougeTest.testRougeMultipleExamplesWeighted
      eval_config = text_format.Parse(
          """
          model_specs {
            label_key: "labels"
            prediction_key: "predictions"
          }
          metrics_specs {
            metrics {
              class_name: "Rouge"
              config: '"rouge_type":"rouge1"'
            }
            metrics {
              class_name: "Rouge"
              config: '"rouge_type":"rouge2"'
            }
            metrics {
              class_name: "Rouge"
              config: '"rouge_type":"rougeL"'
            }
            metrics {
              class_name: "Rouge"
              config: '"rouge_type":"rougeLsum"'
            }
          }
          """,
          tfma.EvalConfig(),
      )
      rouge_types = ["rouge1", "rouge2", "rougeL", "rougeLsum"]
      example_weights = [0.5, 0.7]
      extracts = [
          {
              constants.LABELS_KEY: np.array(["testing one two"]),
              constants.PREDICTIONS_KEY: np.array(["testing"]),
              constants.EXAMPLE_WEIGHTS_KEY: np.array(
                  [example_weights[0]]
              ),
              constants.FEATURES_KEY: None,
              constants.SLICE_KEY_TYPES_KEY: slicer.slice_keys_to_numpy_array(
                  [()]
              ),
          },
          {
              constants.LABELS_KEY: np.array(["This is a test"]),
              constants.PREDICTIONS_KEY: np.array(
                  ["This is not a test"]
              ),
              constants.EXAMPLE_WEIGHTS_KEY: np.array(
                  [example_weights[1]]
              ),
              constants.FEATURES_KEY: None,
              constants.SLICE_KEY_TYPES_KEY: slicer.slice_keys_to_numpy_array(
                  [()]
              ),
          },
      ]
  
      # Values are [unweighed_score_for_example_1, unweighted_score_for_example_2]
      # where the scores are precision, recall, and fmeasure.
      expected_unweighted_scores = {
          "rouge1": ([1, 4 / 5], [1 / 3, 1], [1 / 2, 8 / 9]),
          "rouge2": ([0, 1 / 2], [0, 2 / 3], [0, 4 / 7]),
          "rougeL": ([1, 4 / 5], [1 / 3, 1], [1 / 2, 8 / 9]),
          "rougeLsum": ([1, 4 / 5], [1 / 3, 1], [1 / 2, 8 / 9]),
      }
      for rouge_type in rouge_types:
          rouge_key = metric_types.MetricKey(name=rouge_type)
  
          with beam.Pipeline() as pipeline:
              result = (
                  pipeline
                  | "LoadData" >> beam.Create(extracts)
                  | "ExtractEval"
                  >> metrics_plots_and_validations_evaluator.MetricsPlotsAndValidationsEvaluator(
                      eval_config=eval_config
                  ).ptransform
              )
  
              def check_result(
                  got, rouge_key=rouge_key, rouge_type=rouge_type
              ):
                  try:
                      self.assertLen(got, 1)
                      got_slice_key, got_metrics = got[0]
                      self.assertEqual(got_slice_key, ())
                      self.assertIn(rouge_key, got_metrics.keys())
                      self.assertAlmostEqual(
                          np.average(
                              expected_unweighted_scores[rouge_type][0],
                              weights=example_weights,
                          ),
                          got_metrics[rouge_key].precision,
                      )
                      self.assertAlmostEqual(
                          np.average(
                              expected_unweighted_scores[rouge_type][1],
                              weights=example_weights,
                          ),
                          got_metrics[rouge_key].recall,
                      )
                      self.assertAlmostEqual(
                          np.average(
                              expected_unweighted_scores[rouge_type][2],
                              weights=example_weights,
                          ),
                          got_metrics[rouge_key].fmeasure,
                      )
  
                  except AssertionError as err:
                      raise util.BeamAssertException(err)
  
              self.assertIn("metrics", result)
              util.assert_that(
                  result["metrics"], check_result, label="result"
              )
  
imports: import statistics
  from absl.testing import parameterized
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  import tensorflow_model_analysis
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.evaluators import metrics_plots_and_validations_evaluator
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.metrics import rouge
  from tensorflow_model_analysis.slicer import slicer_lib
  from google.protobuf import text_format
  from rouge_score import tokenizers
label_desc: Use image node_id 1 for calling the RougeEnd2EndTest obj's underlying member method code with example usage: obj.testRougeEnd2End() without return types