class_docstr: Computes NDCG (normalized discounted cumulative gain).
class_docstr_tok: ["Computes","NDCG","(","normalized","discounted","cumulative","gain",")","."]
docstr: Calculate the value of DCG@k.
  
  Args:
    k: The last position to consider.
    sorted_values: A list of gain values assumed to be sorted in the desired
      ranking order.
  
  Returns:
    The value of DCG@k.
docstr_tok: ["Calculate","the","value","of","DCG","@","k.","Args",":","k",":","The","last","position","to","consider",".","sorted_values",":","A","list","of","gain","values","assumed","to","be","sorted","in","the","desired","ranking","order",".","Returns",":","The","value","of","DCG","@","k","."]
code: def _calculate_dcg_at_k(
      self, k: int, sorted_values: List[float]
  ) -> float:
      """Calculate the value of DCG@k.
  
      Args:
        k: The last position to consider.
        sorted_values: A list of gain values assumed to be sorted in the desired
          ranking order.
  
      Returns:
        The value of DCG@k.
      """
      return np.sum(
          np.array(sorted_values)[:k]
          / np.log2(np.array(range(2, k + 2)))
      )
  
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 4 for calling the _NDCGCombiner obj's underlying member method code with example usage: obj._calculate_dcg_at_k(k, sorted_values) and returns: np