docstr: Basic unit test for all_gather using a process group of default world size.
docstr_tok: ["Basic","unit","test","for","all_gather","using","a","process","group","of","default","world","size","."]
code: def test_all_gather_result(self) -> None:
      """
      Basic unit test for all_gather using a process group of default world size.
      """
      store = c10d.FileStore(self.file_name, self.world_size)
      c10d.init_process_group(
          backend="gloo",
          store=store,
          rank=self.rank,
          world_size=self.world_size,
      )
      pg = c10d.new_group(pg_options=self.opts())
  
      func = mock.MagicMock()
      func.return_value = pg.rank()
  
      res = all_gather(data_or_fn=func, pg=pg)
      func.assert_called_once()
      assert res == list(
          range(self.world_size)
      ), f"Expect res to be list of 0 through {self.world_size} (got {res})"
  
file_path: pytorch/test/distributed/test_collective_utils.py
imports: from unittest import mock
  import torch.distributed
  from torch.distributed.collective_utils import all_gather, broadcast
  from torch.testing._internal.common_distributed import MultiProcessTestCase
label_desc: Use image node_id 7 for calling the TestCollectiveUtils obj's underlying member method code with example usage: obj.test_all_gather_result() without return types