code: def _test_distrib_config(
      local_rank,
      backend,
      ws,
      true_device,
      rank=None,
      true_init_method=None,
  ):
      assert (
          idist.backend() == backend
      ), f"{idist.backend()} vs {backend}"
  
      this_device = idist.device()
      assert isinstance(this_device, torch.device)
      if (
          backend in ("nccl", "gloo", "horovod")
          and "cuda" in this_device.type
      ):
          assert (
              this_device.type == torch.device(true_device).type
          ), f"{this_device} vs {true_device}"
      elif backend in ("gloo", "horovod"):
          assert this_device.type == torch.device(true_device).type
      elif backend == "xla-tpu":
          assert true_device in this_device.type
  
      if rank is None:
          if idist.model_name() == "native-dist":
              rank = dist.get_rank()
  
      if rank is not None:
          assert idist.get_rank() == rank
  
      assert idist.get_world_size() == ws
      assert idist.get_local_rank() == local_rank
  
      assert idist.model_name() in (
          "native-dist",
          "xla-dist",
          "horovod-dist",
      )
  
      _sanity_check()
  
      if idist.model_name() == "native-dist":
          from ignite.distributed.utils import _model
  
          if true_init_method is not None:
              assert _model._init_method == true_init_method
  
file_path: ignite/tests/ignite/distributed/utils/__init__.py
imports: import pytest
  import torch
  import torch.distributed
  import ignite.distributed
  from ignite.distributed.utils import sync
  from ignite.engine import Engine, Events
label_desc: Use image node_id 2 for calling a global function with example usage: _test_distrib_config(local_rank, backend, ws, true_device, rank, true_init_method) without return types