code: def testCustomTFMetric(self):
      metric = tf_metric_wrapper.tf_metric_computations(
          [_CustomMetric()], example_weighted=True
      )[0]
  
      example1 = {
          "labels": [0.0],
          "predictions": [0.2],
          "example_weights": [1.0],
      }
      example2 = {
          "labels": [0.0],
          "predictions": [0.8],
          "example_weights": [1.0],
      }
      example3 = {
          "labels": [0.0],
          "predictions": [0.5],
          "example_weights": [2.0],
      }
  
      with beam.Pipeline() as pipeline:
          # pylint: disable=no-value-for-parameter
          result = (
              pipeline
              | "Create" >> beam.Create([example1, example2, example3])
              | "Process"
              >> beam.Map(metric_util.to_standard_metric_inputs)
              | "AddSlice" >> beam.Map(lambda x: ((), x))
              | "Combine" >> beam.CombinePerKey(metric.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, ())
  
                  custom_key = metric_types.MetricKey(
                      name="custom", example_weighted=True
                  )
                  self.assertDictElementsAlmostEqual(
                      got_metrics,
                      {
                          custom_key: (0.2 + 0.8 + 2 * 0.5)
                          / (1.0 + 1.0 + 2.0)
                      },
                  )
  
              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 5 for calling the NonConfusionMatrixMetricsTest obj's underlying member method code with example usage: obj.testCustomTFMetric() without return types