class_docstr: Creates histogram from labels, predictions, and example weights.
class_docstr_tok: ["Creates","histogram","from","labels",",","predictions",",","and","example","weights","."]
code: def add_input(
      self,
      accumulator: _CalibrationHistogramCombinerAcctype,
      element: metric_types.StandardMetricInputs,
  ) -> _CalibrationHistogramCombinerAcctype:
      # Note that in the case of top_k, if the aggregation type is not set then
      # the non-top_k predictions will be set to float('-inf'), but the labels
      # will remain unchanged. If aggregation type is set then both the
      # predictions and labels will be truncated to only the top_k values.
      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,
          fractional_labels=self._fractional_labels,
          flatten=True,
          aggregation_type=self._aggregation_type,
          class_weights=self._class_weights,
          example_weighted=self._example_weighted,
      ):
          example_weight = float(example_weight)
          label = float(label)
          prediction = float(prediction)
          weighted_label = label * example_weight
          weighted_prediction = prediction * example_weight
          if self._prediction_based_bucketing:
              bucket_index = self._bucket_index(prediction)
          else:
              bucket_index = self._bucket_index(label)
          if bucket_index not in accumulator:
              accumulator[bucket_index] = Bucket(
                  bucket_index,
                  weighted_label,
                  weighted_prediction,
                  example_weight,
              )
          else:
              existing_bucket = accumulator[bucket_index]
              existing_bucket.weighted_labels += weighted_label
              existing_bucket.weighted_predictions += (
                  weighted_prediction
              )
              existing_bucket.weighted_examples += example_weight
      return accumulator
  
file_path: model-analysis/tensorflow_model_analysis/metrics/calibration_histogram.py
imports: import dataclasses
  import operator
  from typing import Dict, Iterable, List, Optional
  import apache_beam
  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 4 for calling the _CalibrationHistogramCombiner obj's underlying member method code with example usage: obj.add_input(accumulator, element) and returns: accumulator