class_docstr: Computes min label position metric.
class_docstr_tok: ["Computes","min","label","position","metric","."]
code: def add_input(
      self,
      accumulator: _MinLabelPositionAccumulator,
      element: metric_types.StandardMetricInputs,
  ) -> _MinLabelPositionAccumulator:
      labels, predictions, example_weight = next(
          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,
              example_weighted=self._example_weighted,
              flatten=False,
              allow_none=True,
              require_single_example_weight=True,
          )
      )  # pytype: disable=wrong-arg-types
      if self._label_key:
          labels = util.get_by_keys(element.features, [self._label_key])
      if labels is not None:
          min_label_pos = None
          for i, l in enumerate(labels[np.argsort(predictions)[::-1]]):
              if np.sum(l) > 0:
                  min_label_pos = i + 1  # Use 1-indexed positions
                  break
          if min_label_pos:
              accumulator.total_min_position += min_label_pos * float(
                  example_weight
              )
              accumulator.total_weighted_examples += float(
                  example_weight
              )
      return accumulator
  
file_path: model-analysis/tensorflow_model_analysis/metrics/min_label_position.py
imports: from typing import Dict, Iterable, List, 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
  from tensorflow_model_analysis.utils import util
label_desc: Use image node_id 3 for calling the _MinLabelPositionCombiner obj's underlying member method code with example usage: obj.add_input(accumulator, element) and returns: accumulator