code: def test_intra_rank_and_size(self):
      ranks_and_sizes = self.mpi_comm.gather(
          (
              self.communicator.intra_rank,
              self.communicator.intra_size,
              self.communicator.inter_rank,
              self.communicator.inter_size,
          )
      )
  
      if self.mpi_comm.rank == 0:
          for intra_rank, intra_size, _, _ in ranks_and_sizes:
              self.assertTrue(0 <= intra_rank < intra_size)
  
          inter_rank_to_intra_ranks = collections.defaultdict(list)
  
          for intra_rank, _, inter_rank, _ in ranks_and_sizes:
              inter_rank_to_intra_ranks[inter_rank].append(intra_rank)
  
          for ranks in inter_rank_to_intra_ranks.values():
              ranks.sort()
  
          for _, intra_size, inter_rank, _ in ranks_and_sizes:
              self.assertEqual(
                  inter_rank_to_intra_ranks[inter_rank],
                  list(range(intra_size)),
              )
  
file_path: chainer/tests/chainermn_tests/communicator_tests/test_node_aware_communicator_base.py
imports: import collections
  import os
  import unittest
  import mpi4py.MPI
  import pytest
  from chainermn.communicators.mpi_communicator_base import MpiCommunicatorBase
label_desc: Use image node_id 5 for calling the TestMpiCommunicatorBase obj's underlying member method code with example usage: obj.test_intra_rank_and_size() without return types