code: def test_allreduce_multigpu_multiple_group(
      ray_start_distributed_multigpu_2_nodes_4_gpus,
      backend="nccl",
      num_groups=5,
  ):
      world_size = 2
      num_gpu_per_worker = 2
      actual_world_size = world_size * num_gpu_per_worker
      actors, _ = create_collective_multigpu_workers(world_size)
      for group_name in range(1, num_groups):
          ray.get(
              [
                  actor.init_group.remote(
                      world_size, i, backend, str(group_name)
                  )
                  for i, actor in enumerate(actors)
              ]
          )
      for i in range(num_groups):
          group_name = "default" if i == 0 else str(i)
          results = ray.get(
              [
                  a.do_allreduce_multigpu.remote(group_name)
                  for a in actors
              ]
          )
          assert (
              results[0]
              == cp.ones((10,), dtype=cp.float32)
              * (actual_world_size ** (i + 1))
          ).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 4 for calling a global function with example usage: test_allreduce_multigpu_multiple_group(ray_start_distributed_multigpu_2_nodes_4_gpus, backend, num_groups) without return types