class_docstr: The task-aware Accuracy metric.
  
  The metric computes a dictionary of <task_label, accuracy value> pairs.
  update/result/reset methods are all task-aware.
  
  See :class:`avalanche.evaluation.Accuracy` for the documentation about
  the `Accuracy` metric.
class_docstr_tok: ["The","task-aware","Accuracy","metric",".","The","metric","computes","a","dictionary","of","<","task_label",",","accuracy","value",">","pairs",".","update\/result\/reset","methods","are","all","task-aware",".","See",":","class",":","`","avalanche.evaluation.Accuracy","`","for","the","documentation","about","the","`","Accuracy","`","metric","."]
docstr: Update the running accuracy given the true and predicted labels.
  
  Parameter `task_labels` is used to decide how to update the inner
  dictionary: if Float, only the dictionary value related to that task
  is updated. If Tensor, all the dictionary elements belonging to the
  task labels will be updated.
  
  :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",".","Parameter","`","task_labels","`","is","used","to","decide","how","to","update","the","inner","dictionary",":","if","Float",",","only","the","dictionary","value","related","to","that","task","is","updated",".","If","Tensor",",","all","the","dictionary","elements","belonging","to","the","task","labels","will","be","updated",".",":","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[float, Tensor],
  ) -> None:
      """Update the running accuracy given the true and predicted labels.
  
      Parameter `task_labels` is used to decide how to update the inner
      dictionary: if Float, only the dictionary value related to that task
      is updated. If Tensor, all the dictionary elements belonging to the
      task labels will be updated.
  
      :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 isinstance(task_labels, int):
          self._mean_accuracy[task_labels].update(predicted_y, true_y)
      elif isinstance(task_labels, Tensor):
          for pred, true, t in zip(predicted_y, true_y, task_labels):
              if isinstance(t, Tensor):
                  t = t.item()
              self._mean_accuracy[t].update(
                  pred.unsqueeze(0), true.unsqueeze(0)
              )
      else:
          raise ValueError(
              f"Task label type: {type(task_labels)}, "
              f"expected int/float or Tensor"
          )
  
imports: from typing import List, Optional, Union, Dict
  import torch
  from torch import Tensor
  from avalanche.evaluation import Metric, GenericPluginMetric
  from avalanche.evaluation.metrics.mean import Mean
  from collections import defaultdict
label_desc: Use image node_id 2 for calling the TaskAwareAccuracy obj's underlying member method code with example usage: obj.update(predicted_y, true_y, task_labels) without return types