code: def ndcg(
      y_pred: npt.NDArray[np.float32], y_true: npt.NDArray[np.float32]
  ) -> npt.NDArray[np.float32]:
      """
      Computes the normalized discounted cumulative gain of the predictions.
  
      Args:
          y_pred: Array of shape [N, D] with the predictions (N: number of elements, D: number of
              metrics).
          y_true: Array of shape [N, D] with the true metrics.
  
      Returns:
          Array of shape [D] with the nDCG for each metric.
      """
      n = y_pred.shape[0]
  
      # First, get the relevance
      true_argsort = y_true.argsort(0)  # [N, D]
      true_ranks = true_argsort.argsort(0)  # [N, D]
      relevance = 1 / (true_ranks + 1)  # [N, D]
      relevance[true_ranks >= 10] = 0
  
      # Then, compute the iDCG
      num = np.take_along_axis(
          relevance, true_argsort, axis=0
      )  # [N, D]
      denom = np.log2(np.arange(n) + 2)[:, None]  # [N, D]
      idcg = (num / denom).sum(0)
  
      # And compute the DCG
      pred_argsort = y_pred.argsort(0)
      num = np.take_along_axis(relevance, pred_argsort, axis=0)
      denom = np.log2(np.arange(n) + 2)[:, None]
      dcg = (num / denom).sum(0)
  
      return dcg / idcg
  
imports: import numpy
  import numpy.typing
  import scipy.stats
label_desc: Use image node_id 5 for calling a global function with example usage: ndcg(y_pred, y_true) and returns: unknown