class_docstr: This class provides interface functions for users to get the parallel context,
  such as the global rank, the local rank, the world size, etc. of each device.
  
  Note:
      The parallel_mode used in this class should be concluded in ``ParallelMode``.
      More details about ``ParallelMode`` could be found in
      `parallel_mode <https://github.com/hpcaitech/ColossalAI/blob/main/colossalai/context/parallel_mode.py>`_.
docstr: Initializes the global distributed environment
  
  Args:
     rank (int): rank for the default process group.
     world_size (int): world size of the default process group.
     backend (str): backend for ``torch.distributed``
     host (str): the master address for distributed training.
     port (str): the master port for distributed training
docstr_tok: ["Initializes","the","global","distributed","environment","Args",":","rank","(","int",")",":","rank","for","the","default","process","group",".","world_size","(","int",")",":","world","size","of","the","default","process","group",".","backend","(","str",")",":","backend","for","``","torch.distributed","``","host","(","str",")",":","the","master","address","for","distributed","training",".","port","(","str",")",":","the","master","port","for","distributed","training"]
code: def init_global_dist(
      self,
      rank: int,
      world_size: int,
      backend: str,
      host: str,
      port: int,
  ):
      """Initializes the global distributed environment
  
      Args:
         rank (int): rank for the default process group.
         world_size (int): world size of the default process group.
         backend (str): backend for ``torch.distributed``
         host (str): the master address for distributed training.
         port (str): the master port for distributed training
      """
      # initialize the default process group
      init_method = f"tcp://[{host}]:{port}"
      dist.init_process_group(
          rank=rank,
          world_size=world_size,
          backend=backend,
          init_method=init_method,
      )
  
      # None will give the default global process group for pytorch dist operations
      ranks = list(range(world_size))
      cpu_group = (
          dist.new_group(ranks, backend="gloo")
          if dist.get_backend() != "gloo"
          else None
      )
      self._register_dist(
          rank,
          world_size,
          dist.GroupMember.WORLD,
          cpu_group,
          ranks,
          ParallelMode.GLOBAL,
      )
      self.add_global_rank(ParallelMode.GLOBAL, rank)
  
imports: import random
  import socket
  from collections import Counter
  from typing import Union
  import numpy
  import torch
  import torch.distributed
  from colossalai.context.config import Config
  from colossalai.context.singleton_meta import SingletonMeta
  from colossalai.legacy.constants import ALLOWED_MODES, INITIALIZER_MAPPING
  from colossalai.legacy.global_variables import tensor_parallel_env
  from colossalai.legacy.registry import DIST_GROUP_INITIALIZER
  from colossalai.logging import get_dist_logger
  from .parallel_mode import ParallelMode
  from .random import add_seed, get_seeds, set_mode
label_desc: Use image node_id 27 for calling the ParallelContext obj's underlying member method code with example usage: obj.init_global_dist(rank, world_size, backend, host, port) without return types