code: def _test_dist_spawn_fn(
      local_rank, backend, world_size, device, **kwargs
  ):
      from ignite.distributed.utils import _model
  
      assert dist.is_available() and dist.is_initialized()
      assert dist.get_backend() == backend
  
      assert isinstance(
          _model, _NativeDistModel
      ), f"{type(_model)} vs _NativeDistModel"
  
      assert _model.get_local_rank() == local_rank
      assert _model.get_world_size() == world_size
      assert _model.device().type == torch.device(device).type
  
      if "master_addr" in kwargs:
          assert os.environ["MASTER_ADDR"] == kwargs["master_addr"]
      if "master_port" in kwargs:
          assert os.environ["MASTER_PORT"] == str(kwargs["master_port"])
  
imports: import os
  import pytest
  import torch
  import torch.distributed
  from ignite.distributed.comp_models import has_native_dist_support
label_desc: Use image node_id 23 for calling a global function with example usage: _test_dist_spawn_fn(local_rank, backend, world_size, device) without return types