code: def testTFCompilableMetricsAccumulator(self):
      acc = tf_metric_accumulators.TFCompilableMetricsAccumulator(
          metric_counts=[1, 2], padding_options=None
      )
  
      self.assertEqual(0, acc.len_inputs())
  
      acc.add_input(
          0, np.array([1.0, 0.0]), np.array([0.5, 0.5]), np.array([1.0])
      )
      acc.add_input(
          0, np.array([1.0, 1.0]), np.array([0.3, 0.7]), np.array([1.0])
      )
      acc.add_input(
          1, np.array([0.0, 0.0]), np.array([0.2, 0.8]), np.array([0.5])
      )
      acc.add_input(
          1, np.array([0.0, 1.0]), np.array([0.1, 0.9]), np.array([0.5])
      )
      acc.add_input(
          1, np.array([1.0, 1.0]), np.array([0.6, 0.4]), np.array([0.7])
      )
      self.assertAllClose(
          acc.get_inputs(0),
          (
              np.array([np.array([1.0, 0.0]), np.array([1.0, 1.0])]),
              np.array([np.array([0.5, 0.5]), np.array([0.3, 0.7])]),
              np.array([np.array([1.0]), np.array([1.0])]),
          ),
      )
      self.assertAllClose(
          acc.get_inputs(1),
          (
              np.array(
                  [
                      np.array([0.0, 0.0]),
                      np.array([0.0, 1.0]),
                      np.array([1.0, 1.0]),
                  ]
              ),
              np.array(
                  [
                      np.array([0.2, 0.8]),
                      np.array([0.1, 0.9]),
                      np.array([0.6, 0.4]),
                  ]
              ),
              np.array(
                  [np.array([0.5]), np.array([0.5]), np.array([0.7])]
              ),
          ),
      )
  
      acc.clear_inputs()
      self.assertEqual(0, acc.len_inputs())
  
      acc.add_weights(0, 0, np.array([1.0, 2.0]))
      acc.add_weights(1, 0, np.array([3.0, 4.0]))
      acc.add_weights(1, 1, np.array([5.0, 6.0]))
      acc.add_weights(1, 1, np.array([7.0, 8.0]))
      self.assertAllClose(acc.get_weights(0, 0), np.array([1.0, 2.0]))
      self.assertAllClose(acc.get_weights(1, 0), np.array([3.0, 4.0]))
      self.assertAllClose(acc.get_weights(1, 1), np.array([12.0, 14.0]))
  
file_path: model-analysis/tensorflow_model_analysis/metrics/tf_metric_accumulators_test.py
imports: import numpy
  import tensorflow
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.metrics import tf_metric_accumulators
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 2 for calling the TfMetricAccumulatorsTest obj's underlying member method code with example usage: obj.testTFCompilableMetricsAccumulator() without return types