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:
          cm = ConfusionMatrix(num_classes=3, device=metric_device)
          assert cm._device == metric_device
          assert (
              cm.confusion_matrix.device == metric_device
          ), f"{type(cm.confusion_matrix.device)}:{cm._num_correct.device} vs {type(metric_device)}:{metric_device}"
  
          y_true, y_pred = get_y_true_y_pred()
          th_y_true, th_y_logits = compute_th_y_true_y_logits(
              y_true, y_pred
          )
          cm.update((th_y_logits, th_y_true))
  
          assert (
              cm.confusion_matrix.device == metric_device
          ), f"{type(cm.confusion_matrix.device)}:{cm._num_correct.device} vs {type(metric_device)}:{metric_device}"
  
imports: import os
  import numpy
  import pytest
  import torch
  from sklearn.metrics import accuracy_score, confusion_matrix, precision_score, recall_score
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import ConfusionMatrix, IoU, JaccardIndex, mIoU
  from ignite.metrics.confusion_matrix import cmAccuracy, cmPrecision, cmRecall, DiceCoefficient
label_desc: Use image node_id 20 for calling a global function with example usage: _test_distrib_accumulator_device(device) without return types