code: def testAggregateMultipleSlices(self):
      temp_eval_export_dir = self._getEvalExportDir()
      _, eval_export_dir = linear_classifier.simple_linear_classifier(
          None, temp_eval_export_dir
      )
  
      eval_shared_model = self.createTestEvalSharedModel(
          eval_saved_model_path=eval_export_dir
      )
  
      with beam.Pipeline() as pipeline:
          example1 = self._makeExample(
              age=3.0, language="english", label=1.0
          )
          example2 = self._makeExample(
              age=3.0, language="chinese", label=0.0
          )
          example3 = self._makeExample(
              age=4.0, language="english", label=1.0
          )
          example4 = self._makeExample(
              age=5.0, language="chinese", label=0.0
          )
  
          predict_result_english_slice = [
              example1.SerializeToString(),
              example3.SerializeToString(),
          ]
  
          predict_result_chinese_slice = [
              example2.SerializeToString(),
              example4.SerializeToString(),
          ]
  
          test_input = (
              create_test_input(
                  predict_result_english_slice,
                  [(("language", "english"))],
              )
              + create_test_input(
                  predict_result_chinese_slice,
                  [(("language", "chinese"))],
              )
              +
              # Overall slice
              create_test_input(
                  predict_result_english_slice
                  + predict_result_chinese_slice,
                  [()],
              )
          )
  
          metrics = (
              pipeline
              | "CreateTestInput" >> beam.Create(test_input)
              | "ComputePerSliceMetrics"
              >> aggregate.ComputePerSliceMetrics(
                  eval_shared_model=eval_shared_model,
                  desired_batch_size=3,
              )
          )
  
          def check_result(got):
              self.assertEqual(3, len(got), "got: %s" % got)
              slices = {}
              for slice_key, metrics in got:
                  slices[slice_key] = metrics
              overall_slice = ()
              english_slice = ("language", "english")
              chinese_slice = ("language", "chinese")
              self.assertCountEqual(
                  list(slices),
                  [overall_slice, english_slice, chinese_slice],
              )
              self.assertDictElementsAlmostEqual(
                  slices[overall_slice],
                  {
                      "accuracy": 1.0,
                      "label/mean": 0.5,
                      "my_mean_age": 3.75,
                      "my_mean_age_times_label": 1.75,
                  },
              )
              self.assertDictElementsAlmostEqual(
                  slices[english_slice],
                  {
                      "accuracy": 1.0,
                      "label/mean": 1.0,
                      "my_mean_age": 3.5,
                      "my_mean_age_times_label": 3.5,
                  },
              )
              self.assertDictElementsAlmostEqual(
                  slices[chinese_slice],
                  {
                      "accuracy": 1.0,
                      "label/mean": 0.0,
                      "my_mean_age": 4.0,
                      "my_mean_age_times_label": 0.0,
                  },
              )
  
          util.assert_that(metrics, check_result)
  
file_path: model-analysis/tensorflow_model_analysis/evaluators/legacy_aggregate_test.py
imports: import os
  import apache_beam
  from apache_beam.testing import util
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.eval_saved_model.example_trainers import linear_classifier
  from tensorflow_model_analysis.evaluators import legacy_aggregate
  from tensorflow_model_analysis.evaluators import legacy_poisson_bootstrap
label_desc: Use image node_id 3 for calling the AggregateTest obj's underlying member method code with example usage: obj.testAggregateMultipleSlices() without return types