class_docstr: The Top-k Accuracy metric. This is a standalone metric.
  It is defined using torchmetrics.functional accuracy with top_k
class_docstr_tok: ["The","Top-k","Accuracy","metric",".","This","is","a","standalone","metric",".","It","is","defined","using","torchmetrics.functional","accuracy","with","top_k"]
code: def _compute_topk_acc(self, pred, gt, top_k):
      if self.__torchmetrics_requires_task:
          num_classes = int(torch.max(torch.as_tensor(gt))) + 1
          pred_t = torch.as_tensor(pred)
          if len(pred_t.shape) > 1:
              num_classes = max(num_classes, pred_t.shape[1])
  
          return accuracy(
              pred,
              gt,
              task="multiclass",
              num_classes=num_classes,
              top_k=self.top_k,
          )
      else:
          return accuracy(pred, gt, top_k=self.top_k)
  
imports: from typing import TYPE_CHECKING, List, Union, Dict
  import torch
  from torch import Tensor
  import torchmetrics
  from torchmetrics.functional import accuracy
  from avalanche.evaluation import Metric, GenericPluginMetric
  from avalanche.evaluation.metrics.mean import Mean
  from avalanche.evaluation.metric_utils import phase_and_task
  from collections import defaultdict
  from packaging import version
label_desc: Use image node_id 3 for calling the TopkAccuracy obj's underlying member method code with example usage: obj._compute_topk_acc(pred, gt, top_k) and returns: accuracy, accuracy