code: def test_multiclass_images():
      num_classes = 3
      cm = MultiLabelConfusionMatrix(num_classes=num_classes)
  
      y_true, y_pred = get_y_true_y_pred()
  
      # Compute confusion matrix with sklearn
      sklearn_CM = multilabel_confusion_matrix(
          y_true.transpose((0, 2, 3, 1)).reshape(-1, 3),
          y_pred.transpose((0, 2, 3, 1)).reshape(-1, 3),
      )
  
      # Update metric
      output = (torch.tensor(y_pred), torch.tensor(y_true))
      cm.update(output)
  
      ignite_CM = cm.compute().cpu().numpy()
  
      assert np.all(ignite_CM == sklearn_CM)
  
      # Another test on batch of 2 images
      cm = MultiLabelConfusionMatrix(num_classes=num_classes)
  
      # Create a batch of two images:
      th_y_true1 = torch.tensor(y_true)
      th_y_true2 = torch.tensor(y_true.transpose(0, 1, 3, 2))
      th_y_true = torch.cat([th_y_true1, th_y_true2], dim=0)
  
      th_y_pred1 = torch.tensor(y_pred)
      th_y_pred2 = torch.tensor(y_pred.transpose(0, 1, 3, 2))
      th_y_pred = torch.cat([th_y_pred1, th_y_pred2], dim=0)
  
      # Update metric & compute
      output = (th_y_pred, th_y_true)
      cm.update(output)
      ignite_CM = cm.compute().cpu().numpy()
  
      # Compute confusion matrix with sklearn
      th_y_true = idist.all_gather(th_y_true)
      th_y_pred = idist.all_gather(th_y_pred)
  
      np_y_true = (
          th_y_true.cpu().numpy().transpose((0, 2, 3, 1)).reshape(-1, 3)
      )
      np_y_pred = (
          th_y_pred.cpu().numpy().transpose((0, 2, 3, 1)).reshape(-1, 3)
      )
      sklearn_CM = multilabel_confusion_matrix(np_y_true, np_y_pred)
  
      assert np.all(ignite_CM == sklearn_CM)
  
file_path: ignite/tests/ignite/metrics/test_multilabel_confusion_matrix.py
imports: import numpy
  import pytest
  import torch
  from sklearn.metrics import multilabel_confusion_matrix
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics.multilabel_confusion_matrix import MultiLabelConfusionMatrix
label_desc: Use image node_id 5 for calling a global function with example usage: test_multiclass_images() without return types