code: def _recall_at_k(
      target: np.ndarray, preds: np.ndarray, top_k: Optional[int] = None
  ):
      """Didn't find a reliable implementation of Recall in Information Retrieval, so, reimplementing here.
  
      See wikipedia for more information about definition.
  
      """
      assert target.shape == preds.shape
      assert (
          len(target.shape) == 1
      )  # works only with single dimension inputs
  
      top_k = top_k or len(preds)
  
      if target.sum() > 0:
          order_indexes = np.argsort(preds, axis=0)[::-1]
          relevant = np.sum(target[order_indexes][:top_k])
          return relevant * 1.0 / target.sum()
      return np.NaN
  
file_path: torchmetrics/tests/unittests/retrieval/test_recall.py
imports: from typing import Callable, Optional, Union
  import numpy
  import pytest
  from torch import Tensor
  from torchmetrics.functional.retrieval.recall import retrieval_recall
  from torchmetrics.retrieval.recall import RetrievalRecall
  from typing_extensions import Literal
  from unittests.helpers import seed_all
  from unittests.retrieval.helpers import RetrievalMetricTester, _concat_tests, _custom_aggregate_fn, _default_metric_class_input_arguments, _default_metric_class_input_arguments_ignore_index, _default_metric_functional_input_arguments, _errors_test_class_metric_parameters_default, _errors_test_class_metric_parameters_k, _errors_test_class_metric_parameters_no_pos_target, _errors_test_functional_metric_parameters_default, _errors_test_functional_metric_parameters_k
label_desc: Use image node_id 1 for calling a global function with example usage: _recall_at_k(target, preds, top_k) and returns: np, unknown