code: def test_simple_batched():
      num_iters = 5
      num_samples = 100
      num_classes = 10
      batch_size = 1
      torch.manual_seed(0)
  
      for _ in range(num_iters):  # 2D tests
          mlcm = MultiLabelConfusionMatrix(
              num_classes, normalized=False
          )
          targets = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
              ),
          )
          predictions = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
              ),
          )
          for i in range(int(num_samples / batch_size)):
              target_sample = targets[i]
              prediction_sample = predictions[i]
              mlcm.update([prediction_sample, target_sample])
  
          ignite_CM = mlcm.compute().numpy()
          targets_reshaped = targets.reshape(-1, num_classes)
          predictions_reshaped = predictions.reshape(-1, num_classes)
          sklearn_CM = multilabel_confusion_matrix(
              targets_reshaped.numpy(), predictions_reshaped.numpy()
          )
          assert np.all(
              sklearn_CM.astype(np.int64) == ignite_CM.astype(np.int64)
          )
  
      size_3d = 4
      for _ in range(num_iters):  # 3D tests
          mlcm = MultiLabelConfusionMatrix(
              num_classes, normalized=False
          )
          targets = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
                  size_3d,
              ),
          )
          predictions = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
                  size_3d,
              ),
          )
          for i in range(int(num_samples / batch_size)):
              target_sample = targets[i]
              prediction_sample = predictions[i]
              mlcm.update([prediction_sample, target_sample])
  
          ignite_CM = mlcm.compute().numpy()
          targets_reshaped = targets.permute(0, 1, 3, 2).reshape(
              -1, num_classes
          )
          predictions_reshaped = predictions.permute(
              0, 1, 3, 2
          ).reshape(-1, num_classes)
          sklearn_CM = multilabel_confusion_matrix(
              targets_reshaped.numpy(), predictions_reshaped.numpy()
          )
          assert np.all(
              sklearn_CM.astype(np.int64) == ignite_CM.astype(np.int64)
          )
  
      size_4d = 4
      for _ in range(num_iters):  # 4D tests
          mlcm = MultiLabelConfusionMatrix(
              num_classes, normalized=False
          )
          targets = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
                  size_3d,
                  size_4d,
              ),
          )
          predictions = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
                  size_3d,
                  size_4d,
              ),
          )
          for i in range(int(num_samples / batch_size)):
              target_sample = targets[i]
              prediction_sample = predictions[i]
              mlcm.update([prediction_sample, target_sample])
  
          ignite_CM = mlcm.compute().numpy()
          targets_reshaped = targets.permute(0, 1, 3, 4, 2).reshape(
              -1, num_classes
          )
          predictions_reshaped = predictions.permute(
              0, 1, 3, 4, 2
          ).reshape(-1, num_classes)
          sklearn_CM = multilabel_confusion_matrix(
              targets_reshaped.numpy(), predictions_reshaped.numpy()
          )
          assert np.all(
              sklearn_CM.astype(np.int64) == ignite_CM.astype(np.int64)
          )
  
      size_5d = 4
      for _ in range(num_iters):  # 5D tests
          mlcm = MultiLabelConfusionMatrix(
              num_classes, normalized=False
          )
          targets = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
                  size_3d,
                  size_4d,
                  size_5d,
              ),
          )
          predictions = torch.randint(
              0,
              2,
              size=(
                  int(num_samples / batch_size),
                  batch_size,
                  num_classes,
                  size_3d,
                  size_4d,
                  size_5d,
              ),
          )
          for i in range(int(num_samples / batch_size)):
              target_sample = targets[i]
              prediction_sample = predictions[i]
              mlcm.update([prediction_sample, target_sample])
  
          ignite_CM = mlcm.compute().numpy()
          targets_reshaped = targets.permute(0, 1, 3, 4, 5, 2).reshape(
              -1, num_classes
          )
          predictions_reshaped = predictions.permute(
              0, 1, 3, 4, 5, 2
          ).reshape(-1, num_classes)
          sklearn_CM = multilabel_confusion_matrix(
              targets_reshaped.numpy(), predictions_reshaped.numpy()
          )
          assert np.all(
              sklearn_CM.astype(np.int64) == ignite_CM.astype(np.int64)
          )
  
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 10 for calling a global function with example usage: test_simple_batched() without return types