class_docstr: The Average Mean Class Accuracy (AMCA) 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.
  
  Beware that this class does not provide mechanisms to separate scores based
  on the originating data stream. For this, please refer to
  :class:`MultiStreamAMCA`.
  
  The "prediction" and "target" tensors may contain plain labels or
  one-hot/logit vectors.
  
  Each time `result` is called, this metric emits the average mean accuracy
  as the average accuracy of all previous experiences (also considering the
  accuracy in the current experience).
  The metric expects that the :meth:`next_experience` method will be called
  after each experience. This is needed to consolidate the current mean
  accuracy. After calling :meth:`next_experience`, a new experience with
  accuracy 0.0 is immediately started. If you need to obtain the AMCA up to
  experience `t-1`, obtain the :meth:`result` before calling
  :meth:`next_experience`.
  
  
  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
  (tracked classes will be kept). By default, this metric in its initial state
  will return a `{task_id -> amca}` dictionary in which all AMCAs are set to 0
  (that is, the `reset` method will hardly be useful when using this metric).
class_docstr_tok: ["The","Average","Mean","Class","Accuracy","(","AMCA",")","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",".","Beware","that","this","class","does","not","provide","mechanisms","to","separate","scores","based","on","the","originating","data","stream",".","For","this",",","please","refer","to",":","class",":","`","MultiStreamAMCA","`",".","The","``","prediction","''","and","``","target","''","tensors","may","contain","plain","labels","or","one-hot\/logit","vectors",".","Each","time","`","result","`","is","called",",","this","metric","emits","the","average","mean","accuracy","as","the","average","accuracy","of","all","previous","experiences","(","also","considering","the","accuracy","in","the","current","experience",")",".","The","metric","expects","that","the",":","meth",":","`","next_experience","`","method","will","be","called","after","each","experience",".","This","is","needed","to","consolidate","the","current","mean","accuracy",".","After","calling",":","meth",":","`","next_experience","`",",","a","new","experience","with","accuracy","0.0","is","immediately","started",".","If","you","need","to","obtain","the","AMCA","up","to","experience","`","t-1","`",",","obtain","the",":","meth",":","`","result","`","before","calling",":","meth",":","`","next_experience","`",".","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","(","tracked","classes","will","be","kept",")",".","By","default",",","this","metric","in","its","initial","state","will","return","a","`","{","task_id","-",">","amca","}","`","dictionary","in","which","all","AMCAs","are","set","to","0","(","that","is",",","the","`","reset","`","method","will","hardly","be","useful","when","using","this","metric",")","."]
docstr: Creates an instance of the standalone AMCA 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 AMCA 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 will initialize the accuracy for that
  class to 0.0.
  
  Setting the `classes` parameter is very important, as the mean class
  accuracy may vary based on this! If the test set is fixed and contains
  at least a sample for each class, then it is safe to leave `classes`
  to None.
  
  :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 list of classes to be considered
      is created immediately. This will ensure that the mean class
      accuracy is correctly computed. In addition, this can be used to
      restrict the classes that should be considered when computing the
      mean class accuracy.
docstr_tok: ["Creates","an","instance","of","the","standalone","AMCA","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","AMCA","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","will","initialize","the","accuracy","for","that","class","to","0.0",".","Setting","the","`","classes","`","parameter","is","very","important",",","as","the","mean","class","accuracy","may","vary","based","on","this","!","If","the","test","set","is","fixed","and","contains","at","least","a","sample","for","each","class",",","then","it","is","safe","to","leave","`","classes","`","to","None",".",":","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","list","of","classes","to","be","considered","is","created","immediately",".","This","will","ensure","that","the","mean","class","accuracy","is","correctly","computed",".","In","addition",",","this","can","be","used","to","restrict","the","classes","that","should","be","considered","when","computing","the","mean","class","accuracy","."]
code: def __init__(self, classes: Optional[TrackedClassesType] = None):
      """
      Creates an instance of the standalone AMCA 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 AMCA 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 will initialize the accuracy for that
      class to 0.0.
  
      Setting the `classes` parameter is very important, as the mean class
      accuracy may vary based on this! If the test set is fixed and contains
      at least a sample for each class, then it is safe to leave `classes`
      to None.
  
      :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 list of classes to be considered
          is created immediately. This will ensure that the mean class
          accuracy is correctly computed. In addition, this can be used to
          restrict the classes that should be considered when computing the
          mean class accuracy.
      """
      self._class_accuracies = ClassAccuracy(classes=classes)
      """
          A dictionary "task_id -> {class_id -> Mean}".
          """
  
      # Here a Mean metric could be used as well. However, that could make it
      # difficult to compute the running AMCA...
      self._prev_exps_accuracies: Dict[int, List[float]] = defaultdict(
          list
      )
      """
          The mean class accuracy of previous experiences as a dictionary
          `{task_id -> [accuracies]}`.
          """
  
      self._updated_once = False
  
imports: from typing import Callable, Dict, Iterable, List, Union, TYPE_CHECKING, Optional, Sequence, Set
  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 generic_get_metric_name
  from avalanche.evaluation.metrics.class_accuracy import ClassAccuracy, TrackedClassesType
label_desc: Use image node_id 1 to create a new AverageMeanClassAccuracy object from inherited base classes: Metric with example: obj = AverageMeanClassAccuracy(classes)