code: def _test_distrib_accumulator_device(device):
      metric_devices = [torch.device("cpu")]
      if device.type != "xla":
          metric_devices.append(idist.device())
      for metric_device in metric_devices:
          acc = Accuracy(device=metric_device)
          assert acc._device == metric_device
          assert (
              acc._num_correct.device == metric_device
          ), f"{type(acc._num_correct.device)}:{acc._num_correct.device} vs {type(metric_device)}:{metric_device}"
  
          y_pred = torch.randint(
              0, 2, size=(10,), device=device, dtype=torch.long
          )
          y = torch.randint(
              0, 2, size=(10,), device=device, dtype=torch.long
          )
          acc.update((y_pred, y))
  
          assert (
              acc._num_correct.device == metric_device
          ), f"{type(acc._num_correct.device)}:{acc._num_correct.device} vs {type(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 18 for calling a global function with example usage: _test_distrib_accumulator_device(device) without return types