code: def testBinaryConfusionMatricesExampleIdKeyNotInFeatures(self):
      thresholds = [0.1, 0.9]
      example_id_key = "example_id_key"
      example_ids_count = 2
  
      # Example Ids are empty because 'example_id_key' will not be defined in
      # 'features'
      expected_metrics = {
          metric_types.MetricKey(
              "_binary_confusion_matrices:example_id_key=example_id_key,"
              "example_ids_count=2,thresholds=[0.1, 0.9]"
          ): binary_confusion_matrices.Matrices(
              thresholds=[0.1, 0.9],
              tp=[2.0, 0.0],
              fp=[1.0, 0.0],
              tn=[1.0, 2.0],
              fn=[0.0, 2.0],
          ),
          metric_types.MetricKey(
              "_binary_confusion_examples:example_id_key=example_id_key,"
              "example_ids_count=2,thresholds=[0.1, 0.9]"
          ): binary_confusion_matrices.Examples(
              thresholds=[0.1, 0.9],
              tp_examples=[[], []],
              tn_examples=[[], []],
              fp_examples=[[], []],
              fn_examples=[[], []],
          ),
      }
  
      computations = (
          binary_confusion_matrices.binary_confusion_matrices(
              thresholds=thresholds,
              example_id_key=example_id_key,
              example_ids_count=example_ids_count,
          )
      )
      histogram = computations[0]
      matrices = computations[1]
  
      examples = [
          {
              "labels": np.array([0.0]),
              "predictions": np.array([0.0]),
              "example_weights": np.array([1.0]),
              "features": {},
          },
          {
              "labels": np.array([0.0]),
              "predictions": np.array([0.5]),
              "example_weights": np.array([1.0]),
              "features": {},
          },
          {
              "labels": np.array([1.0]),
              "predictions": np.array([0.3]),
              "example_weights": np.array([1.0]),
              "features": {},
          },
          {
              "labels": np.array([1.0]),
              "predictions": np.array([0.9]),
              "example_weights": np.array([1.0]),
              "features": {},
          },
          {
              # Ensure that empty inputs are handled safely.
              "labels": np.array([]),
              "predictions": np.array([]),
              "example_weights": np.array([]),
              "features": {},
          },
      ]
  
      with beam.Pipeline() as pipeline:
          # pylint: disable=no-value-for-parameter
          result = (
              pipeline
              | "Create" >> beam.Create(examples)
              | "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: 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, ())
                  self.assertEqual(got_metrics, expected_metrics)
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(result, check_result, label="result")
  
file_path: model-analysis/tensorflow_model_analysis/metrics/binary_confusion_matrices_test.py
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 binary_confusion_matrices
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
label_desc: Use image node_id 4 for calling the BinaryConfusionMatricesTest obj's underlying member method code with example usage: obj.testBinaryConfusionMatricesExampleIdKeyNotInFeatures() without return types