class_docstr: Accuracy for 2D parallelism
docstr: Calculate the accuracy of predicted labels.
  
  Args:
      logits (:class:`torch.tensor`): Predicted labels.
      targets (:class:`torch.tensor`): True labels from data.
  
  Returns:
      float: the accuracy of prediction.
docstr_tok: ["Calculate","the","accuracy","of","predicted","labels",".","Args",":","logits","(",":","class",":","`","torch.tensor","`",")",":","Predicted","labels",".","targets","(",":","class",":","`","torch.tensor","`",")",":","True","labels","from","data",".","Returns",":","float",":","the","accuracy","of","prediction","."]
code: def forward(self, logits, targets):
      """Calculate the accuracy of predicted labels.
  
      Args:
          logits (:class:`torch.tensor`): Predicted labels.
          targets (:class:`torch.tensor`): True labels from data.
  
      Returns:
          float: the accuracy of prediction.
      """
      with torch.no_grad():
          targets = split_batch_2d(targets)
          correct = calc_acc(logits, targets)
          correct = reduce_by_batch_2d(correct)
      return correct
  
file_path: colossalai/colossalai/legacy/nn/metric/accuracy_2d.py
imports: import torch
  from torch import nn
  from colossalai.legacy.nn.layer.parallel_2d import reduce_by_batch_2d, split_batch_2d
  from ._utils import calc_acc
label_desc: Use image node_id 2 for calling the Accuracy2D obj's underlying member method code with example usage: obj.forward(logits, targets) and returns: correct