docstr: Ensure all_gather exception is propagated properly.
docstr_tok: ["Ensure","all_gather","exception","is","propagated","properly","."]
code: def test_all_gather_result_raises_exceptions_from_func(
      self,
  ) -> None:
      """
      Ensure all_gather exception is propagated properly.
      """
      # no process group
      func = mock.MagicMock()
      exc = Exception("test exception")
      func.side_effect = exc
      expected_exception = "test exception"
      with self.assertRaisesRegex(Exception, expected_exception):
          all_gather(data_or_fn=func)
  
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 9 for calling the TestCollectiveUtils obj's underlying member method code with example usage: obj.test_all_gather_result_raises_exceptions_from_func() without return types