code: def _test_distrib_integration_multilabel(device):
      from ignite.engine import Engine
  
      torch.manual_seed(12)
  
      def _test(average, n_epochs, metric_device):
          n_iters = 60
          batch_size = 16
          n_classes = 7
  
          y_true = torch.randint(
              0, 2, size=(n_iters * batch_size, n_classes, 6, 8)
          ).to(device)
          y_preds = torch.randint(
              0, 2, size=(n_iters * batch_size, n_classes, 6, 8)
          ).to(device)
  
          def update(engine, i):
              return (
                  y_preds[i * batch_size : (i + 1) * batch_size, ...],
                  y_true[i * batch_size : (i + 1) * batch_size, ...],
              )
  
          engine = Engine(update)
  
          re = Recall(
              average=average, is_multilabel=True, device=metric_device
          )
          re.attach(engine, "re")
          assert re._updated is False
  
          data = list(range(n_iters))
          engine.run(data=data, max_epochs=n_epochs)
  
          y_preds = idist.all_gather(y_preds)
          y_true = idist.all_gather(y_true)
  
          assert "re" in engine.state.metrics
          assert re._updated is True
          res = engine.state.metrics["re"]
          res2 = re.compute()
          if isinstance(res, torch.Tensor):
              res = res.cpu().numpy()
              res2 = res2.cpu().numpy()
              assert (res == res2).all()
          else:
              assert res == res2
  
          np_y_preds = to_numpy_multilabel(y_preds)
          np_y_true = to_numpy_multilabel(y_true)
          assert re._type == "multilabel"
          sk_average_parameter = ignite_average_to_scikit_average(
              average, "multilabel"
          )
          with warnings.catch_warnings():
              warnings.simplefilter(
                  "ignore", category=UndefinedMetricWarning
              )
              assert recall_score(
                  np_y_true, np_y_preds, average=sk_average_parameter
              ) == pytest.approx(res)
  
      metric_devices = ["cpu"]
      if device.type != "xla":
          metric_devices.append(idist.device())
      rank = idist.get_rank()
      for i in range(2):
          torch.manual_seed(12 + rank + i)
          for metric_device in metric_devices:
              _test(
                  average=False, n_epochs=1, metric_device=metric_device
              )
              _test(
                  average=False, n_epochs=2, metric_device=metric_device
              )
              _test(
                  average="macro",
                  n_epochs=1,
                  metric_device=metric_device,
              )
              _test(
                  average="macro",
                  n_epochs=2,
                  metric_device=metric_device,
              )
              _test(
                  average="micro",
                  n_epochs=1,
                  metric_device=metric_device,
              )
              _test(
                  average="micro",
                  n_epochs=2,
                  metric_device=metric_device,
              )
              _test(
                  average="weighted",
                  n_epochs=1,
                  metric_device=metric_device,
              )
              _test(
                  average="weighted",
                  n_epochs=2,
                  metric_device=metric_device,
              )
              _test(
                  average="samples",
                  n_epochs=1,
                  metric_device=metric_device,
              )
              _test(
                  average="samples",
                  n_epochs=2,
                  metric_device=metric_device,
              )
  
imports: import os
  import warnings
  import pytest
  import torch
  from sklearn.exceptions import UndefinedMetricWarning
  from sklearn.metrics import recall_score
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import Recall
label_desc: Use image node_id 14 for calling a global function with example usage: _test_distrib_integration_multilabel(device) and returns: y_preds,  y_true