class_docstr: Accuracy monitoring metric. 
docstr: Computes accuracy metric given the predicted label and the true label.
  
  Parameters
  ----------
  y_pred
      Predicted label.
  y_true
      True label.
docstr_tok: ["Computes","accuracy","metric","given","the","predicted","label","and","the","true","label",".","Parameters","--","--","--","--","--","y_pred","Predicted","label",".","y_true","True","label","."]
code: def compute_metric(
      self,
      y_pred: Union[torch.Tensor, np.ndarray],
      y_true: Union[torch.Tensor, np.ndarray],
  ) -> None:
      """
      Computes accuracy metric given the predicted label and the true label.
  
      Parameters
      ----------
      y_pred
          Predicted label.
      y_true
          True label.
      """
  
      if isinstance(y_true, torch.Tensor):
          y_true = y_true.detach().cpu().numpy()
  
      if isinstance(y_pred, torch.Tensor):
          y_pred = y_pred.detach().cpu().numpy()
  
      # in case y_pred is a distribution and not a label
      if len(y_pred.shape) > len(y_true.shape):
          y_pred = np.argmax(y_pred, axis=-1)
  
      # check if the shapes match
      if y_pred.shape != y_true.shape:
          raise ValueError(
              "The shape of the prediction and labels do not match"
          )
  
      matches = np.array(y_pred == y_true)
      super().update_state(matches)
  
imports: import torch
  import numpy
  from enum import Enum
  from abc import ABC, abstractmethod
  from typing import Dict, Union, Callable
label_desc: Use image node_id 2 for calling the AccuracyMetric obj's underlying member method code with example usage: obj.compute_metric(y_pred, y_true) without return types