code: def test_allreduce_different_op(
      ray_start_distributed_2_nodes, backend
  ):
      world_size = 8
      actors, _ = create_collective_workers(world_size, backend=backend)
  
      # check product
      ray.wait(
          [
              a.set_buffer.remote(
                  np.ones(10, dtype=np.float32) * (i + 2)
              )
              for i, a in enumerate(actors)
          ]
      )
      results = ray.get(
          [a.do_allreduce.remote(op=ReduceOp.PRODUCT) for a in actors]
      )
      product = 1
      for i in range(world_size):
          product = product * (i + 2)
      assert (
          results[0] == np.ones((10,), dtype=np.float32) * product
      ).all()
      assert (
          results[1] == np.ones((10,), dtype=np.float32) * product
      ).all()
  
      # check min
      ray.wait(
          [
              a.set_buffer.remote(
                  np.ones(10, dtype=np.float32) * (i + 2)
              )
              for i, a in enumerate(actors)
          ]
      )
      results = ray.get(
          [a.do_allreduce.remote(op=ReduceOp.MIN) for a in actors]
      )
      assert (results[0] == np.ones((10,), dtype=np.float32) * 2).all()
      assert (results[1] == np.ones((10,), dtype=np.float32) * 2).all()
  
      # check max
      ray.wait(
          [
              a.set_buffer.remote(
                  np.ones(10, dtype=np.float32) * (i + 2)
              )
              for i, a in enumerate(actors)
          ]
      )
      results = ray.get(
          [a.do_allreduce.remote(op=ReduceOp.MAX) for a in actors]
      )
      assert (results[0] == np.ones((10,), dtype=np.float32) * 9).all()
      assert (results[1] == np.ones((10,), dtype=np.float32) * 9).all()
  
file_path: ray/python/ray/util/collective/tests/distributed_cpu_tests/test_distributed_allreduce.py
imports: import pytest
  import ray
  from ray.util.collective.types import ReduceOp
  import numpy
  import torch
  from ray.util.collective.types import Backend
  from ray.util.collective.tests.cpu_util import create_collective_workers
label_desc: Use image node_id 5 for calling a global function with example usage: test_allreduce_different_op(ray_start_distributed_2_nodes, backend) without return types