code: def test_that_accuracy_metric_calculates_multiclass_correctly(
      y_ypred,
  ):
      predicted, true = y_ypred
      predicted = (
          predicted.softmax(-1) + torch.randn_like(predicted) / 100
      )
      # test adding a batch:
      accuracy_calculator = Accuracy(average=True, topk=(1,))
      accuracy_calculator.update(predicted, true)
      assert np.allclose(
          accuracy_calculator.value,
          (true == predicted.argmax(-1)).float().mean().item(),
      )
      # test adding all elements in a batch separately
      new_accuracy_calculator = Accuracy(average=True, topk=(1,))
      for x, y in zip(predicted, true):
          x, y = x.unsqueeze(0), y.unsqueeze(0)
          new_accuracy_calculator.update(x, y)
      assert np.allclose(
          new_accuracy_calculator.value, accuracy_calculator.value
      )
  
imports: import os
  from pathlib import Path
  import numpy
  import pytest
  import shutil
  import torch
  from hypothesis import given
  from torch_hypothesis import classification_logits_and_labels
  from baal.utils.metrics import Loss, Accuracy, Precision, ECE, ClassificationReport, PRAuC, ECE_PerCLs
label_desc: Use image node_id 2 for calling a global function with example usage: test_that_accuracy_metric_calculates_multiclass_correctly(y_ypred) without return types