class_docstr: Computes weighted labels, predictions, and examples.
class_docstr_tok: ["Computes","weighted","labels",",","predictions",",","and","examples","."]
code: def add_input(
      self,
      accumulator: _WeightedLabelsPredictionsExamples,
      element: metric_types.StandardMetricInputs,
  ) -> _WeightedLabelsPredictionsExamples:
      for (
          label,
          prediction,
          example_weight,
      ) in metric_util.to_label_prediction_example_weight(
          element,
          eval_config=self._eval_config,
          model_name=self._key.model_name,
          output_name=self._key.output_name,
          sub_key=self._key.sub_key,
          aggregation_type=self._aggregation_type,
          class_weights=self._class_weights,
          example_weighted=self._example_weighted,
          allow_none=True,
      ):
          example_weight = float(example_weight)
          accumulator.total_weighted_examples += example_weight
          if label is not None and len(label):
              if (
                  self._key.sub_key
                  and self._key.sub_key.top_k is not None
              ):
                  for i in range(self._key.sub_key.top_k):
                      weighted_label = label[i] * example_weight
              else:
                  weighted_label = float(label) * example_weight
              accumulator.total_weighted_labels += weighted_label
          if prediction is not None and len(label):
              if (
                  self._key.sub_key
                  and self._key.sub_key.top_k is not None
              ):
                  for i in range(self._key.sub_key.top_k):
                      weighted_prediction = (
                          prediction[i] * example_weight
                      )
              else:
                  weighted_prediction = (
                      float(prediction) * example_weight
                  )
              accumulator.total_weighted_predictions += (
                  weighted_prediction
              )
      return accumulator
  
imports: from typing import Any, Dict, Iterable, Optional
  import apache_beam
  import numpy
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 3 for calling the _WeightedLabelsPredictionsExamplesCombiner obj's underlying member method code with example usage: obj.add_input(accumulator, element) and returns: accumulator