code: def init_ranks(mpi_comm):
      """Returns rank information of the local process in `mpi_comm`.
  
      Args:
          mpi_comm (type:TODO)
                   MPI Communicator from mpi4py
  
      Returns:
          rank_info (list):
              Elements are:
                  * rank (`mpi_comm.rank`)
                  * intra_rank (rank within the local computing node)
                  * intra_size (number of processes on the node)
                  * inter_rank (rank of the node)
                  * inter_size (number of computing nodes)
      """
  
      global_names = mpi_comm.gather(mpi4py.MPI.Get_processor_name())
  
      if mpi_comm.rank == 0:
          name_to_global_ranks = collections.defaultdict(list)
          for global_rank, name in enumerate(global_names):
              name_to_global_ranks[name].append(global_rank)
  
          for global_ranks in name_to_global_ranks.values():
              global_ranks.sort()
  
          inter_names = sorted(
              set(global_names),
              key=lambda name: name_to_global_ranks[name],
          )
          name_to_inter_rank = {
              name: inter_rank
              for inter_rank, name in enumerate(inter_names)
          }
          inter_size = len(inter_names)
  
          all_ranks = []
          for global_rank, name in enumerate(global_names):
              ranks = name_to_global_ranks[name]
              intra_rank = ranks.index(global_rank)
              intra_size = len(ranks)
              inter_rank = name_to_inter_rank[name]
              all_ranks.append(
                  (
                      global_rank,
                      intra_rank,
                      intra_size,
                      inter_rank,
                      inter_size,
                  )
              )
          my_ranks = mpi_comm.scatter(all_ranks)
      else:
          my_ranks = mpi_comm.scatter(None)
  
      assert my_ranks[0] == mpi_comm.rank
      return my_ranks
  
file_path: chainer/chainermn/communicators/_communication_utility.py
imports: from chainermn import nccl
  import collections
  import numpy
  import pickle
  import mpi4py.MPI
label_desc: Use image node_id 1 for calling a global function with example usage: init_ranks(mpi_comm) and returns: my_ranks