code: def test_serial_model():
      _SerialModel.create_from_backend()
      model = _SerialModel.create_from_context()
  
      assert model.get_local_rank() == 0
      assert model.get_rank() == 0
      assert model.get_world_size() == 1
      assert model.get_nproc_per_node() == 1
      assert model.get_nnodes() == 1
      assert model.get_node_rank() == 0
      if torch.cuda.is_available():
          assert model.device().type == "cuda"
      elif _torch_version_le_112 and torch.backends.mps.is_available():
          assert model.device().type == "mps"
      else:
          assert model.device().type == "cpu"
      assert model.backend() is None
      model.finalize()
  
      with pytest.raises(
          NotImplementedError,
          match=r"Serial computation model does not implement spawn method",
      ):
          model.spawn()
  
      model.all_reduce(1)
      model.all_gather(1)
      model.broadcast(1)
      assert model._do_all_reduce(torch.tensor(1)) == torch.tensor(1)
      assert model._do_all_gather(torch.tensor(1)) == torch.tensor(1)
      assert model._do_broadcast(
          torch.tensor(1), src=0
      ) == torch.tensor(1)
      model.barrier()
  
file_path: ignite/tests/ignite/distributed/comp_models/test_base.py
imports: import pytest
  import torch
  from ignite.distributed.comp_models.base import _SerialModel, _torch_version_le_112, ComputationModel
label_desc: Use image node_id 1 for calling a global function with example usage: test_serial_model() without return types