code: def check_layer(rank, world_size, port):
      launch(
          config=CONFIG,
          rank=rank,
          world_size=world_size,
          host="localhost",
          port=port,
          backend="nccl",
      )
  
      assert dist.get_rank() == gpc.get_global_rank()
      print(
          "Rank {} / {}".format(dist.get_rank(), dist.get_world_size())
      )
  
      check_all_gather()
      check_reduce_scatter()
      check_all_reduce()
  
      gpc.destroy()
      torch.cuda.empty_cache()
  
file_path: ColossalAI/tests/test_legacy/test_comm/test_comm.py
imports: import pytest
  import torch
  import torch.distributed
  from colossalai.legacy.communication import all_gather, all_reduce, reduce_scatter
  from colossalai.legacy.context import ParallelMode
  from colossalai.legacy.core import global_context
  from colossalai.legacy.initialize import launch
  from colossalai.testing import rerun_if_address_is_in_use, spawn
  from colossalai.utils import get_current_device
label_desc: Use image node_id 4 for calling a global function with example usage: check_layer(rank, world_size, port) without return types