code: def test_ece_percls():
      ece_calculator = ECE_PerCLs(n_cls=3, n_bins=3)
  
      # start with multiclass classification
      pred = torch.FloatTensor([[0.4, 0.5, 0.1], [0.1, 0.8, 0.1]])
      target = torch.LongTensor([[2], [1]])
  
      for i in range(2):
          ece_calculator.update(
              output=pred[i, :].unsqueeze(0),
              target=target[i, :].unsqueeze(0),
          )
  
      assert np.allclose(
          ece_calculator.samples,
          np.array([[0, 0, 0], [0, 0, 1], [0, 1, 0]]),
      )
      assert np.allclose(
          ece_calculator.tp, np.array([[0, 0, 0], [0, 0, 1], [0, 0, 0]])
      )
      assert np.allclose(
          ece_calculator.conf_agg,
          np.array([[0, 0, 0], [0, 0.0, 0.8], [0, 0.5, 0.0]]),
      )
      assert np.allclose(
          ece_calculator.value, np.array([0.0, 0.2, 0.5])
      )
  
      pth = "tmp"
      Path(pth).mkdir(exist_ok=True)
      print(pth)
      ece_calculator.plot(pth=os.path.join(pth, "figure.png"))
      assert os.path.exists(os.path.join(pth, "figure.png"))
      shutil.rmtree(pth)
  
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 12 for calling a global function with example usage: test_ece_percls() without return types