code: def test_reduce_multiple_group(
      ray_start_single_node, dst_rank, backend, num_groups=5
  ):
      world_size = 2
      actors, _ = create_collective_workers(world_size, backend=backend)
      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_reduce.remote(
                      dst_rank=dst_rank, group_name=group_name
                  )
                  for a in actors
              ]
          )
          for j in range(world_size):
              if j == dst_rank:
                  assert (
                      results[j]
                      == np.ones((10,), dtype=np.float32) * (i + 2)
                  ).all()
              else:
                  assert (
                      results[j] == np.ones((10,), dtype=np.float32)
                  ).all()
  
file_path: ray/python/ray/util/collective/tests/single_node_cpu_tests/test_reduce.py
imports: import pytest
  import numpy
  import ray
  from ray.util.collective.types import Backend, ReduceOp
  from ray.util.collective.tests.cpu_util import create_collective_workers
label_desc: Use image node_id 3 for calling a global function with example usage: test_reduce_multiple_group(ray_start_single_node, dst_rank, backend, num_groups) without return types