code: def ndcg_at_k(k) -> EvaluationMetric:
      """
      This function will create a metric for evaluating `NDCG@k`_ for retriever models.
  
      NDCG score is capable of handling non-binary notions of relevance. However, for simplicity,
      we use binary relevance here. The relevance score for documents in the ground truth is 1,
      and the relevance score for documents not in the ground truth is 0.
  
      The NDCG score is calculated using sklearn.metrics.ndcg_score with the following edge cases
      on top of the sklearn implementation:
  
      1. If no ground truth doc IDs are provided and no documents are retrieved, the score is 1.
      2. If no ground truth doc IDs are provided and documents are retrieved, the score is 0.
      3. If ground truth doc IDs are provided and no documents are retrieved, the score is 0.
      4. If duplicate doc IDs are retrieved and the duplicate doc IDs are in the ground truth,
         they will be treated as different docs. For example, if the ground truth doc IDs are
         [1, 2] and the retrieved doc IDs are [1, 1, 1, 3], the score will be equavalent to
         ground truth doc IDs [10, 11, 12, 2] and retrieved doc IDs [10, 11, 12, 3].
  
      .. _NDCG@k: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.ndcg_score.html
      """
      return make_metric(
          eval_fn=_ndcg_at_k_eval_fn(k),
          greater_is_better=True,
          name=f"ndcg_at_{k}",
      )
  
imports: from mlflow.metrics.base import MetricValue
  from mlflow.metrics.metric_definitions import _accuracy_eval_fn, _ari_eval_fn, _f1_score_eval_fn, _flesch_kincaid_eval_fn, _mae_eval_fn, _mape_eval_fn, _max_error_eval_fn, _mse_eval_fn, _ndcg_at_k_eval_fn, _precision_at_k_eval_fn, _precision_eval_fn, _r2_score_eval_fn, _recall_at_k_eval_fn, _recall_eval_fn, _rmse_eval_fn, _rouge1_eval_fn, _rouge2_eval_fn, _rougeL_eval_fn, _rougeLsum_eval_fn, _token_count_eval_fn, _toxicity_eval_fn
  from mlflow.models import EvaluationMetric, make_metric
  from mlflow.utils.annotations import experimental
label_desc: Use image node_id 13 for calling a global function with example usage: ndcg_at_k(k) and returns: make_metric