class_docstr: Combines compilable metric weights and computes result.
class_docstr_tok: ["Combines","compilable","metric","weights","and","computes","result","."]
code: def add_input(
      self,
      accumulator: tf_metric_accumulators.TFCompilableMetricsAccumulator,
      element: metric_types.StandardMetricInputs,
  ) -> tf_metric_accumulators.TFCompilableMetricsAccumulator:
      for i, output_name in enumerate(self._output_names):
          # When micro averaging is being used, flatten should be set to True so
          # that each class is treated as though it was an independent example.
          micro_average = (
              self._aggregation_type
              and self._aggregation_type.micro_average
          )
          for (
              label,
              prediction,
              example_weight,
          ) in metric_util.to_label_prediction_example_weight(
              element,
              eval_config=self._eval_config,
              model_name=self._model_name,
              output_name=output_name,
              # Skip sub_key processing if part of the keras config
              sub_key=self._sub_key
              if not self._sub_key_in_config
              else None,
              aggregation_type=self._aggregation_type,
              class_weights=self._class_weights,
              example_weighted=self._example_weighted,
              flatten=micro_average,
          ):
              # Keras requires non-sparse keys for its calcuations.
              if (
                  self._sub_key_in_config
                  and label.shape != prediction.shape
              ):
                  label = metric_util.one_hot(label, prediction)
              accumulator.add_input(
                  i, label, prediction, example_weight
              )
      if accumulator.should_flush():
          self._process_batch(accumulator)
      return accumulator
  
imports: import collections
  import importlib
  import itertools
  from typing import Any, Dict, Iterable, List, Optional, Type, Tuple, Union
  import apache_beam
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  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
  from tensorflow_model_analysis.metrics import tf_metric_accumulators
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import model_util
label_desc: Use image node_id 5 for calling the _CompilableMetricsCombiner obj's underlying member method code with example usage: obj.add_input(accumulator, element) and returns: accumulator