code: def test_allreduce_torch_cupy(ray_start_distributed_2_nodes_4_gpus):
      # import torch
      world_size = 4
      actors, _ = create_collective_workers(world_size)
      ray.wait(
          [
              actors[1].set_buffer.remote(
                  torch.ones(
                      10,
                  ).cuda()
              )
          ]
      )
      results = ray.get([a.do_allreduce.remote() for a in actors])
      assert (results[0] == cp.ones((10,)) * world_size).all()
  
      ray.wait(
          [
              actors[0].set_buffer.remote(
                  torch.ones(
                      10,
                  )
              )
          ]
      )
      ray.wait(
          [
              actors[1].set_buffer.remote(
                  cp.ones(
                      10,
                  )
              )
          ]
      )
      with pytest.raises(RuntimeError):
          results = ray.get([a.do_allreduce.remote() for a in actors])
  
file_path: ray/python/ray/util/collective/tests/distributed_gpu_tests/test_distributed_allreduce.py
imports: import pytest
  import ray
  from ray.util.collective.types import ReduceOp
  import cupy
  import torch
  from ray.util.collective.tests.util import create_collective_workers
label_desc: Use image node_id 7 for calling a global function with example usage: test_allreduce_torch_cupy(ray_start_distributed_2_nodes_4_gpus) without return types