code: def test_allreduce_torch_cupy(
      ray_start_distributed_multigpu_2_nodes_4_gpus,
  ):
      # import torch
      world_size = 2
      actual_world_size = 4
      actors, _ = create_collective_multigpu_workers(world_size)
      ray.get(actors[0].set_buffer.remote([10]))
      ray.get(
          actors[1].set_buffer.remote(
              [10], tensor_type0="torch", tensor_type1="torch"
          )
      )
      results = ray.get(
          [a.do_allreduce_multigpu.remote() for a in actors]
      )
      assert (results[0] == cp.ones((10,)) * actual_world_size).all()
  
      ray.get(
          actors[0].set_buffer.remote(
              [10], tensor_type0="cupy", tensor_type1="torch"
          )
      )
      ray.get(
          actors[1].set_buffer.remote(
              [10], tensor_type0="torch", tensor_type1="cupy"
          )
      )
      results = ray.get(
          [a.do_allreduce_multigpu.remote() for a in actors]
      )
      assert (results[0] == cp.ones((10,)) * actual_world_size).all()
  
file_path: ray/python/ray/util/collective/tests/distributed_multigpu_tests/test_distributed_multigpu_allreduce.py
imports: import pytest
  import logging
  import cupy
  import ray
  from ray.util.collective.types import ReduceOp
  from ray.util.collective.tests.util import create_collective_multigpu_workers
label_desc: Use image node_id 7 for calling a global function with example usage: test_allreduce_torch_cupy(ray_start_distributed_multigpu_2_nodes_4_gpus) without return types