class_docstr: Accuracy metric. This is a standalone metric.
  
  The update method computes the accuracy incrementally
  by keeping a running average of the <prediction, target> pairs
  of Tensors provided over time.
  
  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
  across all predictions made since the last `reset`.
  
  The reset method will bring the metric to its initial state. By default
  this metric in its initial state will return an accuracy value of 0.
class_docstr_tok: ["Accuracy","metric",".","This","is","a","standalone","metric",".","The","update","method","computes","the","accuracy","incrementally","by","keeping","a","running","average","of","the","<","prediction",",","target",">","pairs","of","Tensors","provided","over","time",".","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","across","all","predictions","made","since","the","last","`","reset","`",".","The","reset","method","will","bring","the","metric","to","its","initial","state",".","By","default","this","metric","in","its","initial","state","will","return","an","accuracy","value","of","0","."]
docstr: Update the running accuracy given the true and predicted labels.
  
  :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.
  
  :return: None.
docstr_tok: ["Update","the","running","accuracy","given","the","true","and","predicted","labels",".",":","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",".",":","return",":","None","."]
code: def update(
      self,
      predicted_y: Tensor,
      true_y: Tensor,
  ) -> None:
      """Update the running accuracy given the true and predicted labels.
  
      :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.
  
      :return: None.
      """
      true_y = torch.as_tensor(true_y)
      predicted_y = torch.as_tensor(predicted_y)
  
      if len(true_y) != len(predicted_y):
          raise ValueError(
              "Size mismatch for true_y and predicted_y tensors"
          )
  
      # 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]
  
      true_positives = float(torch.sum(torch.eq(predicted_y, true_y)))
      total_patterns = len(true_y)
      self._mean_accuracy.update(
          true_positives / total_patterns, total_patterns
      )
  
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 Accuracy obj's underlying member method code with example usage: obj.update(predicted_y, true_y) without return types