code: def testMetricsWithoutWeights(self, metric_name, expected_value):
      # TODO (b/151636380): remove when CL/299961405 is propagated through Kokoro.
      if metric_name == "specificity_at_sensitivity":
          fix_present = hasattr(
              tf.keras.metrics.SpecificityAtSensitivity,
              "_find_max_under_constraint",
          )
          if not fix_present:
              expected_value = 0.5
      computations = tf_metric_wrapper.tf_metric_computations(
          [self._tf_metric_by_name(metric_name)], example_weighted=False
      )
      histogram = computations[0]
      matrix = computations[1]
      metric = computations[2]
  
      example1 = {
          "labels": np.array([0.0]),
          "predictions": np.array([0.0]),
          "example_weights": np.array(
              [0.1]
          ),  # ignored, example_weighted=False
      }
      example2 = {
          "labels": np.array([0.0]),
          "predictions": np.array([0.5]),
          "example_weights": np.array(
              [0.2]
          ),  # ignored, example_weighted=False
      }
      example3 = {
          "labels": np.array([1.0]),
          "predictions": np.array([0.3]),
          "example_weights": np.array(
              [0.3]
          ),  # ignored, example_weighted=False
      }
      example4 = {
          "labels": np.array([1.0]),
          "predictions": np.array([0.9]),
          "example_weights": np.array(
              [0.4]
          ),  # ignored, example_weighted=False
      }
  
      with beam.Pipeline() as pipeline:
          # pylint: disable=no-value-for-parameter
          result = (
              pipeline
              | "Create"
              >> beam.Create([example1, example2, example3, example4])
              | "Process"
              >> beam.Map(metric_util.to_standard_metric_inputs)
              | "AddSlice" >> beam.Map(lambda x: ((), x))
              | "ComputeHistogram"
              >> beam.CombinePerKey(histogram.combiner)
              | "ComputeConfusionMatrix"
              >> beam.Map(
                  lambda x: (x[0], matrix.result(x[1]))
              )  # pyformat: disable
              | "ComputeMetric"
              >> beam.Map(lambda x: (x[0], metric.result(x[1])))
          )  # pyformat: disable
  
          # 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, ())
                  key = metric_types.MetricKey(
                      name=metric_name, example_weighted=False
                  )
                  self.assertDictElementsAlmostEqual(
                      got_metrics, {key: expected_value}, places=5
                  )
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(result, check_result, label="result")
  
imports: 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.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.metrics import tf_metric_wrapper
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 2 for calling the ConfusionMatrixMetricsTest obj's underlying member method code with example usage: obj.testMetricsWithoutWeights(metric_name, expected_value) without return types