code: def _reference_topk(x, dim, k):
      x = x.cpu().numpy()
      one_hot = np.zeros((x.shape[0], x.shape[1]), dtype=int)
      if dim == 1:
          for i in range(x.shape[0]):
              one_hot[
                  i, np.argsort(x[i, :], kind="stable")[::-1][:k]
              ] = 1
          return one_hot
      for i in range(x.shape[1]):
          one_hot[np.argsort(x[:, i], kind="stable")[::-1][:k], i] = 1
      return one_hot
  
imports: import sys
  import numpy
  import pytest
  import torch
  from torch import tensor
  from torchmetrics.regression import MeanSquaredError, PearsonCorrCoef
  from torchmetrics.utilities import check_forward_full_state_property, rank_zero_debug, rank_zero_info, rank_zero_warn
  from torchmetrics.utilities.checks import _allclose_recursive
  from torchmetrics.utilities.data import _bincount, _cumsum, _flatten, _flatten_dict, select_topk, to_categorical, to_onehot
  from torchmetrics.utilities.distributed import class_reduce, reduce
  from torchmetrics.utilities.exceptions import TorchMetricsUserWarning
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_1_13
label_desc: Use image node_id 13 for calling a global function with example usage: _reference_topk(x, dim, k) and returns: one_hot, one_hot