code: def test_sendrecv_torch_numpy(
      ray_start_single_node, dst_rank, backend
  ):
      import torch
  
      world_size = 2
      actors, _ = create_collective_workers(world_size, backend=backend)
      ray.wait(
          [
              actors[1].set_buffer.remote(
                  torch.ones(
                      10,
                  )
                  * 2
              )
          ]
      )
      src_rank = 1 - dst_rank
  
      refs = []
      for i, actor in enumerate(actors):
          if i != dst_rank:
              ref = actor.do_send.remote(dst_rank=dst_rank)
          else:
              ref = actor.do_recv.remote(src_rank=src_rank)
          refs.append(ref)
      results = ray.get(refs)
      if dst_rank == 0:
          assert (results[0] == np.ones((10,)) * 2).all()
          assert (results[1] == torch.ones((10,)) * 2).all()
      else:
          assert (results[0] == np.ones((10,))).all()
          assert (results[1] == torch.ones((10,))).all()
  
file_path: ray/python/ray/util/collective/tests/single_node_cpu_tests/test_sendrecv.py
imports: import pytest
  import numpy
  import ray
  from ray.util.collective.types import Backend
  from ray.util.collective.tests.cpu_util import create_collective_workers
label_desc: Use image node_id 2 for calling a global function with example usage: test_sendrecv_torch_numpy(ray_start_single_node, dst_rank, backend) without return types