code: def testWithMultiClassClassification(
      self, sequential_model, add_custom_metrics
  ):
      export_dir = self._createMultiClassClassificationModel(
          sequential=sequential_model,
          add_custom_metrics=add_custom_metrics,
      )
      eval_shared_model = self.createTestEvalSharedModel(
          eval_saved_model_path=export_dir
      )
      computation = (
          keras_util.metric_computations_using_keras_saved_model(
              "", eval_shared_model.model_loader, None
          )[0]
      )
  
      inputs = [
          metric_types.StandardMetricInputs(
              labels=np.array([0, 0, 1, 0, 0]),
              predictions=np.array([0.1, 0.2, 0.1, 0.25, 0.35]),
              example_weights=np.array([0.5]),
              features={
                  "output": np.array([0.1, 0.2, 0.1, 0.25, 0.35]),
              },
          ),
          metric_types.StandardMetricInputs(
              labels=np.array([0, 1, 0, 0, 0]),
              predictions=np.array([0.2, 0.3, 0.05, 0.15, 0.3]),
              example_weights=np.array([0.7]),
              features={
                  "output": np.array([0.2, 0.3, 0.05, 0.15, 0.3]),
              },
          ),
          metric_types.StandardMetricInputs(
              labels=np.array([0, 0, 0, 1, 0]),
              predictions=np.array([0.01, 0.2, 0.09, 0.5, 0.2]),
              example_weights=np.array([0.9]),
              features={
                  "output": np.array([0.01, 0.2, 0.09, 0.5, 0.2]),
              },
          ),
          metric_types.StandardMetricInputs(
              labels=np.array([0, 1, 0, 0, 0]),
              predictions=np.array([0.3, 0.2, 0.05, 0.4, 0.05]),
              example_weights=np.array([0.3]),
              features={
                  "output": np.array([0.3, 0.2, 0.05, 0.4, 0.05]),
              },
          ),
      ]
  
      # Unweighted:
      #   top_k = 2
      #     TP = 0 + 1 + 1 + 0 = 2
      #     FP = 2 + 1 + 1 + 2 = 6
      #     FN = 1 + 0 + 0 + 1 = 2
      #
      #   top_k = 3
      #     TP = 0 + 1 + 1 + 1 = 3
      #     FP = 3 + 2 + 2 + 2 = 9
      #     FN = 1 + 0 + 0 + 0 = 1
      #
      # Weighted:
      #   top_k = 2
      #     TP = 0.5*0 + 0.7*1 + 0.9*1 + 0.3*0 = 1.6
      #     FP = 0.5*2 + 0.7*1 + 0.9*1 + 0.3*2 = 3.2
      #     FN = 0.5*1 + 0.7*0 + 0.9*0 + 0.3*1 = 0.8
      #
      #   top_k = 3
      #     TP = 0.5*0 + 0.7*1 + 0.9*1 + 0.3*1 = 1.9
      #     FP = 0.5*3 + 0.7*2 + 0.9*2 + 0.3*2 = 5.3
      #     FN = 0.5*1 + 0.7*0 + 0.9*0 + 0.3*0 = 0.5
      expected_values = {
          "precision@2": 2 / (2 + 6),
          "precision@3": 3 / (3 + 9),
          "recall@2": 2 / (2 + 2),
          "recall@3": 3 / (3 + 1),
          "weighted_precision@2": 1.6 / (1.6 + 3.2),
          "weighted_precision@3": 1.9 / (1.9 + 5.3),
          "weighted_recall@2": 1.6 / (1.6 + 0.8),
          "weighted_recall@3": 1.9 / (1.9 + 0.5),
          "loss": 0.77518,
      }
      if add_custom_metrics:
          expected_values["custom"] = 4.0
  
      with beam.Pipeline() as pipeline:
          # pylint: disable=no-value-for-parameter
          result = (
              pipeline
              | "Create" >> beam.Create(inputs)
              | "AddSlice" >> beam.Map(lambda x: ((), x))
              | "ComputeMetric"
              >> beam.CombinePerKey(computation.combiner)
          )
  
          # pylint: enable=no-value-for-parameter
  
          def check_result(got):
              try:
                  self.assertLen(got, 1)
                  got_slice_key, got_metrics = got[0]
                  self.assertEqual(got_slice_key, ())
                  expected = {}
                  for name, value in expected_values.items():
                      sub_key = None
                      if "@" in name:
                          sub_key = metric_types.SubKey(
                              top_k=int(name.split("@")[1])
                          )
                      key = metric_types.MetricKey(
                          name=name,
                          sub_key=sub_key,
                          example_weighted=None,
                      )
                      expected[key] = value
                  self.assertDictElementsAlmostEqual(
                      got_metrics, expected
                  )
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(result, check_result, label="result")
  
imports: import tempfile
  import unittest
  from absl.testing import parameterized
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.evaluators import keras_util
  from tensorflow_model_analysis.metrics import metric_types
label_desc: Use image node_id 9 for calling the KerasSavedModelUtilTest obj's underlying member method code with example usage: obj.testWithMultiClassClassification(sequential_model, add_custom_metrics) without return types