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: Update the running accuracy given the true and predicted labels for each
  class.
  
  :param predicted_y: The model prediction. Both labels and logit vectors
      are supported.
  :param true_y: The ground truth. Both labels and one-hot vectors
      are supported.
  :param task_labels: the int task label associated to the current
      experience or the task labels vector showing the task label
      for each pattern.
  :return: None.
docstr_tok: ["Update","the","running","accuracy","given","the","true","and","predicted","labels","for","each","class",".",":","param","predicted_y",":","The","model","prediction",".","Both","labels","and","logit","vectors","are","supported",".",":","param","true_y",":","The","ground","truth",".","Both","labels","and","one-hot","vectors","are","supported",".",":","param","task_labels",":","the","int","task","label","associated","to","the","current","experience","or","the","task","labels","vector","showing","the","task","label","for","each","pattern",".",":","return",":","None","."]
code: def update(
      self,
      predicted_y: Tensor,
      true_y: Tensor,
      task_labels: Union[int, Tensor],
  ) -> None:
      """
      Update the running accuracy given the true and predicted labels for each
      class.
  
      :param predicted_y: The model prediction. Both labels and logit vectors
          are supported.
      :param true_y: The ground truth. Both labels and one-hot vectors
          are supported.
      :param task_labels: the int task label associated to the current
          experience or the task labels vector showing the task label
          for each pattern.
      :return: None.
      """
      if len(true_y) != len(predicted_y):
          raise ValueError(
              "Size mismatch for true_y and predicted_y tensors"
          )
  
      if isinstance(task_labels, Tensor) and len(task_labels) != len(
          true_y
      ):
          raise ValueError(
              "Size mismatch for true_y and task_labels tensors"
          )
  
      if not isinstance(task_labels, (int, Tensor)):
          raise ValueError(
              f"Task label type: {type(task_labels)}, "
              f"expected int or Tensor"
          )
  
      if isinstance(task_labels, int):
          task_labels = [task_labels] * len(true_y)
  
      true_y = torch.as_tensor(true_y)
      predicted_y = torch.as_tensor(predicted_y)
  
      # Check if logits or labels
      if len(predicted_y.shape) > 1:
          # Logits -> transform to labels
          predicted_y = torch.max(predicted_y, 1)[1]
  
      if len(true_y.shape) > 1:
          # Logits -> transform to labels
          true_y = torch.max(true_y, 1)[1]
  
      for pred, true, t in zip(predicted_y, true_y, task_labels):
          t = int(t)
  
          if self.dynamic_classes:
              self.classes[t].add(int(true))
          else:
              if t not in self.classes:
                  continue
              if int(true) not in self.classes[t]:
                  continue
  
          true_positives = (pred == true).float().item()  # 1.0 or 0.0
          self._class_accuracies[t][int(true)].update(true_positives, 1)
  
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 2 for calling the ClassAccuracy obj's underlying member method code with example usage: obj.update(predicted_y, true_y, task_labels) without return types