class_docstr: Computes NDCG (normalized discounted cumulative gain).
class_docstr_tok: ["Computes","NDCG","(","normalized","discounted","cumulative","gain",")","."]
code: def add_input(
      self,
      accumulator: _NDCGAccumulator,
      element: metric_types.StandardMetricInputs,
  ) -> _NDCGAccumulator:
      gains, example_weight = self._to_gains_example_weight(element)
      rank_gain = [(pos + 1, gain) for pos, gain in enumerate(gains)]
      for i, key in enumerate(self._metric_keys):
          accumulator.ndcg[i] += (
              self._calculate_ndcg(rank_gain, key.sub_key.top_k)
              * example_weight
          )
      accumulator.total_weighted_examples += float(example_weight)
      return accumulator
  
imports: from typing import Dict, Iterable, List, Optional, Tuple, Union
  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 7 for calling the _NDCGCombiner obj's underlying member method code with example usage: obj.add_input(accumulator, element) and returns: accumulator