code: def _recall_at_k_eval_fn(k):
      if not (isinstance(k, int) and k > 0):
          _logger.warning(
              f"Cannot calculate 'precision_at_k' for invalid parameter 'k'. "
              f"'k' should be a positive integer; found: {k}. Skipping metric logging."
          )
          return noop
  
      def _fn(predictions, targets):
          if not _validate_list_str_data(
              predictions, "precision_at_k", predictions_col_specifier
          ) or not _validate_list_str_data(
              targets, "precision_at_k", targets_col_specifier
          ):
              return
  
          scores = []
          for target, prediction in zip(targets, predictions):
              # only include the top k retrieved chunks
              ground_truth, retrieved = set(target), set(prediction[:k])
              relevant_doc_count = len(
                  ground_truth.intersection(retrieved)
              )
              if len(ground_truth) > 0:
                  scores.append(relevant_doc_count / len(ground_truth))
              elif len(retrieved) == 0:
                  # there are 0 retrieved and ground truth docs, so reward for the match
                  scores.append(1)
              else:
                  # there are > 0 retrieved, but 0 ground truth, so penalize
                  scores.append(0)
  
          return MetricValue(
              scores=scores,
              aggregate_results=standard_aggregations(scores),
          )
  
      return _fn
  
imports: import functools
  import logging
  import os
  import numpy
  from mlflow.metrics.base import MetricValue, standard_aggregations
label_desc: Use image node_id 27 for calling a global function with example usage: _recall_at_k_eval_fn(k) and returns: _fn, noop, MetricValue