code: def test_torch_process_group_gloo():
      @ray.remote
      class TestWorker(TorchDistributedWorker):
          def run(self):
              tensor = torch.tensor([1.0])
              dist.all_reduce(tensor)
              return tensor.numpy()
  
      workers = [TestWorker.remote() for _ in range(5)]
  
      init_torch_dist_process_group(
          workers, backend="gloo", init_method="env"
      )
  
      reduced = ray.get([w.run.remote() for w in workers])
  
      # One tensor from each worker.
      assert len(reduced) == 5
      for r in reduced:
          assert len(r) == 1
          assert r.dtype == np.float32
          # All-reduce. Each tensor contributed 1.0. 5 tensors in total.
          assert r[0] == 5.0
  
      shutdown_torch_dist_process_group(workers)
  
file_path: ray/python/ray/air/tests/test_util_torch_dist.py
imports: import numpy
  import pytest
  import torch
  import torch.distributed
  import ray
  from ray.air.util.torch_dist import init_torch_dist_process_group, shutdown_torch_dist_process_group, TorchDistributedWorker
label_desc: Use image node_id 1 for calling a global function with example usage: test_torch_process_group_gloo() and returns: tensor