code: def testConfusionMatrixPlot(self):
      computations = confusion_matrix_plot.ConfusionMatrixPlot(
          num_thresholds=4
      ).computations()
      histogram = computations[0]
      matrices = computations[1]
      plot = computations[2]
  
      example1 = {
          "labels": np.array([0.0]),
          "predictions": np.array([0.0]),
          "example_weights": np.array([1.0]),
      }
      example2 = {
          "labels": np.array([0.0]),
          "predictions": np.array([0.5]),
          "example_weights": np.array([1.0]),
      }
      example3 = {
          "labels": np.array([1.0]),
          "predictions": np.array([0.3]),
          "example_weights": np.array([1.0]),
      }
      example4 = {
          "labels": np.array([1.0]),
          "predictions": np.array([0.9]),
          "example_weights": np.array([1.0]),
      }
  
      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)
              | "ComputeMatrices"
              >> beam.Map(
                  lambda x: (x[0], matrices.result(x[1]))
              )  # pyformat: ignore
              | "ComputePlot"
              >> beam.Map(lambda x: (x[0], plot.result(x[1])))
          )
  
          # pylint: enable=no-value-for-parameter
  
          def check_result(got):
              try:
                  self.assertLen(got, 1)
                  got_slice_key, got_plots = got[0]
                  self.assertEqual(got_slice_key, ())
                  self.assertLen(got_plots, 1)
                  key = metric_types.PlotKey(
                      name="confusion_matrix_plot"
                  )
                  self.assertIn(key, got_plots)
                  got_plot = got_plots[key]
                  self.assertProtoEquals(
                      """
                matrices {
                  threshold: -1e-06
                  false_positives: 2.0
                  true_positives: 2.0
                  precision: 0.5
                  recall: 1.0
                  false_positive_rate: 1.0
                  f1: 0.6666667
                  accuracy: 0.5
                  false_omission_rate: nan
                }
                matrices {
                  false_positives: 2.0
                  true_positives: 2.0
                  precision: 0.5
                  recall: 1.0
                  false_positive_rate: 1.0
                  f1: 0.6666667
                  accuracy: 0.5
                  false_omission_rate: nan
                }
                matrices {
                  threshold: 0.25
                  true_negatives: 1.0
                  false_positives: 1.0
                  true_positives: 2.0
                  precision: 0.6666667
                  recall: 1.0
                  false_positive_rate: 0.5
                  f1: 0.8
                  accuracy: 0.75
                  false_omission_rate: 0.0
                }
                matrices {
                  threshold: 0.5
                  false_negatives: 1.0
                  true_negatives: 2.0
                  true_positives: 1.0
                  precision: 1.0
                  recall: 0.5
                  false_positive_rate: 0.0
                  f1: 0.6666667
                  accuracy: 0.75
                  false_omission_rate: 0.3333333
                }
                matrices {
                  threshold: 0.75
                  false_negatives: 1.0
                  true_negatives: 2.0
                  true_positives: 1.0
                  precision: 1.0
                  recall: 0.5
                  false_positive_rate: 0.0
                  f1: 0.6666667
                  accuracy: 0.75
                  false_omission_rate: 0.3333333
                }
                matrices {
                  threshold: 1.0
                  false_negatives: 2.0
                  true_negatives: 2.0
                  precision: 1.0
                  recall: 0.0
                  false_positive_rate: 0.0
                  f1: 0.0
                  accuracy: 0.5
                  false_omission_rate: 0.5
                }
            """,
                      got_plot,
                  )
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(result, check_result, label="result")
  
file_path: model-analysis/tensorflow_model_analysis/metrics/confusion_matrix_plot_test.py
imports: 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 confusion_matrix_plot
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
label_desc: Use image node_id 1 for calling the ConfusionMatrixPlotTest obj's underlying member method code with example usage: obj.testConfusionMatrixPlot() without return types