def ndcg_score(relevances: List[float]) -> float:
  """nDCG score computation.

  We normalize using the "ideal" result set which has only relevant results.
  This scales the DCG scores for any number of results k into the interval
  [0, 1].

  Args:
    relevances: List[float], The list of relevance scores.

  Returns:
    The normalized discounted cumulative gain for k == len(relevances).
  """
  if not relevances:
    return 0.0
  return dcg_score(relevances) / dcg_score([1.0] * len(relevances))
nDCG score computation.

  We normalize using the "ideal" result set which has only relevant results.
  This scales the DCG scores for any number of results k into the interval
  [0, 1].

  Args:
    relevances: List[float], The list of relevance scores.

  Returns:
    The normalized discounted cumulative gain for k == len(relevances).
  
language/search_agents/muzero/utils.py