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"]
docstr: Creates an instance of the standalone Top-k Accuracy metric.
  
  By default this metric in its initial state will return a value of 0.
  The metric can be updated by using the `update` method while
  the running top-k accuracy can be retrieved using the `result` method.
  
  :param top_k: integer number to define the value of k.
docstr_tok: ["Creates","an","instance","of","the","standalone","Top-k","Accuracy","metric",".","By","default","this","metric","in","its","initial","state","will","return","a","value","of","0",".","The","metric","can","be","updated","by","using","the","`","update","`","method","while","the","running","top-k","accuracy","can","be","retrieved","using","the","`","result","`","method",".",":","param","top_k",":","integer","number","to","define","the","value","of","k","."]
code: def __init__(self, top_k: int):
      """
      Creates an instance of the standalone Top-k Accuracy metric.
  
      By default this metric in its initial state will return a value of 0.
      The metric can be updated by using the `update` method while
      the running top-k accuracy can be retrieved using the `result` method.
  
      :param top_k: integer number to define the value of k.
      """
      self._topk_acc_dict: Dict[int, Mean] = defaultdict(Mean)
      self.top_k: int = top_k
  
      self.__torchmetrics_requires_task = version.parse(
          torchmetrics.__version__
      ) >= version.parse("0.11.0")
  
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 1 to create a new TopkAccuracy object from inherited base classes: Metric with example: obj = TopkAccuracy(top_k)