code: def _test_distrib_integration_multilabel(device):
      rank = idist.get_rank()
  
      def _test(n_epochs, metric_device):
          metric_device = torch.device(metric_device)
          n_iters = 80
          batch_size = 16
          n_classes = 10
  
          torch.manual_seed(12 + rank)
  
          y_true = torch.randint(
              0, 2, size=(n_iters * batch_size, n_classes, 8, 10)
          ).to(device)
          y_preds = torch.randint(
              0, 2, size=(n_iters * batch_size, n_classes, 8, 10)
          ).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)
  
          acc = Accuracy(is_multilabel=True, device=metric_device)
          acc.attach(engine, "acc")
  
          data = list(range(n_iters))
          engine.run(data=data, max_epochs=n_epochs)
  
          y_true = idist.all_gather(y_true)
          y_preds = idist.all_gather(y_preds)
  
          assert (
              acc._num_correct.device == metric_device
          ), f"{type(acc._num_correct.device)}:{acc._num_correct.device} vs {type(metric_device)}:{metric_device}"
  
          assert "acc" in engine.state.metrics
          res = engine.state.metrics["acc"]
          if isinstance(res, torch.Tensor):
              res = res.cpu().numpy()
  
          true_res = accuracy_score(
              to_numpy_multilabel(y_true), to_numpy_multilabel(y_preds)
          )
  
          assert pytest.approx(res) == true_res
  
      metric_devices = ["cpu"]
      if device.type != "xla":
          metric_devices.append(idist.device())
      for metric_device in metric_devices:
          for _ in range(2):
              _test(n_epochs=1, metric_device=metric_device)
              _test(n_epochs=2, metric_device=metric_device)
  
imports: import os
  import pytest
  import torch
  from packaging.version import Version
  from sklearn.metrics import accuracy_score
  import ignite.distributed
  from ignite.engine import Engine
  from ignite.exceptions import NotComputableError
  from ignite.metrics import Accuracy
label_desc: Use image node_id 17 for calling a global function with example usage: _test_distrib_integration_multilabel(device) and returns: y_preds,  y_true