code: def topk(y_pred, y_true, k, *, ignore_index=-100, reduction="mean"):
      """
      Computes the top-k accuracy.
  
      This is a functional version of :class:`~poutyne.TopKAccuracy`.
  
      See :class:`~poutyne.TopKAccuracy` for details.
      """
      topk_pred = y_pred.topk(k, dim=1)[1]
      weights = (y_true != ignore_index).float()
      num_labels = weights.sum()
      topk_acc = (y_true.unsqueeze(1) == topk_pred).any(
          1
      ).float() * weights
  
      if reduction in ["mean", "sum"]:
          topk_acc = topk_acc.sum()
  
      if reduction == "mean":
          topk_acc = topk_acc / num_labels
  
      return topk_acc * 100
  
imports: from abc import ABC
  import torch.nn
  from poutyne.framework.metrics.metrics_registering import do_register_metric_func, register_metric_func
label_desc: Use image node_id 3 for calling a global function with example usage: topk(y_pred, y_true, k) and returns: unknown