class_docstr: The Class Accuracy metric. This is a standalone metric
  used to compute more specific ones.
  
  Instances of this metric keeps the running average accuracy
  over multiple <prediction, target> pairs of Tensors,
  provided incrementally.
  The "prediction" and "target" tensors may contain plain labels or
  one-hot/logit vectors.
  
  Each time `result` is called, this metric emits the average accuracy
  for all classes seen and across all predictions made since the last `reset`.
  The set of classes to be tracked can be reduced (please refer to the
  constructor parameters).
  
  The reset method will bring the metric to its initial state. By default,
  this metric in its initial state will return a
  `{task_id -> {class_id -> accuracy}}` dictionary in which all accuracies are
  set to 0.
docstr: Creates an instance of the standalone Accuracy metric.
  
  By default, this metric in its initial state will return an empty
  dictionary. The metric can be updated by using the `update` method
  while the running accuracies can be retrieved using the `result` method.
  
  By using the `classes` parameter, one can restrict the list of classes
  to be tracked and in addition can immediately create plots for
  yet-to-be-seen classes.
  
  :param classes: The classes to keep track of. If None (default), all
      classes seen are tracked. Otherwise, it can be a dict of classes
      to be tracked (as "task-id" -> "list of class ids") or, if running
      a task-free benchmark (with only task 0), a simple list of class
      ids. By passing this parameter, the plot of each class is
      created immediately (with a default value of 0.0) and plots
      will be aligned across all classes. In addition, this can be used to
      restrict the classes for which the accuracy should be logged.
docstr_tok: ["Creates","an","instance","of","the","standalone","Accuracy","metric",".","By","default",",","this","metric","in","its","initial","state","will","return","an","empty","dictionary",".","The","metric","can","be","updated","by","using","the","`","update","`","method","while","the","running","accuracies","can","be","retrieved","using","the","`","result","`","method",".","By","using","the","`","classes","`","parameter",",","one","can","restrict","the","list","of","classes","to","be","tracked","and","in","addition","can","immediately","create","plots","for","yet-to-be-seen","classes",".",":","param","classes",":","The","classes","to","keep","track","of",".","If","None","(","default",")",",","all","classes","seen","are","tracked",".","Otherwise",",","it","can","be","a","dict","of","classes","to","be","tracked","(","as","``","task-id","''","-",">","``","list","of","class","ids","''",")","or",",","if","running","a","task-free","benchmark","(","with","only","task","0",")",",","a","simple","list","of","class","ids",".","By","passing","this","parameter",",","the","plot","of","each","class","is","created","immediately","(","with","a","default","value","of","0.0",")","and","plots","will","be","aligned","across","all","classes",".","In","addition",",","this","can","be","used","to","restrict","the","classes","for","which","the","accuracy","should","be","logged","."]
code: def __init__(self, classes: Optional[TrackedClassesType] = None):
      """
      Creates an instance of the standalone Accuracy metric.
  
      By default, this metric in its initial state will return an empty
      dictionary. The metric can be updated by using the `update` method
      while the running accuracies can be retrieved using the `result` method.
  
      By using the `classes` parameter, one can restrict the list of classes
      to be tracked and in addition can immediately create plots for
      yet-to-be-seen classes.
  
      :param classes: The classes to keep track of. If None (default), all
          classes seen are tracked. Otherwise, it can be a dict of classes
          to be tracked (as "task-id" -> "list of class ids") or, if running
          a task-free benchmark (with only task 0), a simple list of class
          ids. By passing this parameter, the plot of each class is
          created immediately (with a default value of 0.0) and plots
          will be aligned across all classes. In addition, this can be used to
          restrict the classes for which the accuracy should be logged.
      """
  
      self.classes: Dict[int, Set[int]] = defaultdict(set)
      """
          The list of tracked classes.
          """
  
      self.dynamic_classes = False
      """
          If True, newly encountered classes will be tracked.
          """
  
      self._class_accuracies: Dict[int, Dict[int, Mean]] = defaultdict(
          lambda: defaultdict(Mean)
      )
      """
          A dictionary "task_id -> {class_id -> Mean}".
          """
  
      if classes is not None:
          if isinstance(classes, dict):
              # Task-id -> classes dict
              self.classes = {
                  task_id: self._ensure_int_classes(class_list)
                  for task_id, class_list in classes.items()
              }
          else:
              # Assume is a plain iterable
              self.classes = {0: self._ensure_int_classes(classes)}
      else:
          self.dynamic_classes = True
  
      self.__init_accs_for_known_classes()
  
imports: from typing import Dict, List, Set, Union, TYPE_CHECKING, Iterable, Optional
  from collections import defaultdict, OrderedDict
  import torch
  from torch import Tensor
  from avalanche.evaluation import Metric, PluginMetric, _ExtendedGenericPluginMetric, _ExtendedPluginMetricValue
  from avalanche.evaluation.metric_utils import default_metric_name_template, generic_get_metric_name
  from avalanche.evaluation.metrics import Mean
label_desc: Use image node_id 1 to create a new ClassAccuracy object from inherited base classes: Metric with example: obj = ClassAccuracy(classes)