code: def init_tensors_for_gather_scatter(
      actors, array_size=10, dtype=cp.float32, tensor_backend="cupy"
  ):
      world_size = len(actors)
      for i, a in enumerate(actors):
          if tensor_backend == "cupy":
              t = cp.ones(array_size, dtype=dtype) * (i + 1)
          elif tensor_backend == "torch":
              t = torch.ones(array_size, dtype=torch.float32).cuda() * (
                  i + 1
              )
          else:
              raise RuntimeError("Unsupported tensor backend.")
          ray.get([a.set_buffer.remote(t)])
      if tensor_backend == "cupy":
          list_buffer = [
              cp.ones(array_size, dtype=dtype)
              for _ in range(world_size)
          ]
      elif tensor_backend == "torch":
          list_buffer = [
              torch.ones(array_size, dtype=torch.float32).cuda()
              for _ in range(world_size)
          ]
      else:
          raise RuntimeError("Unsupported tensor backend.")
      ray.get([a.set_list_buffer.remote(list_buffer) for a in actors])
  
imports: import cupy
  import logging
  import ray
  import ray.util.collective
  from ray.util.collective.types import Backend, ReduceOp
  from ray.util.collective.collective_group.nccl_util import get_num_gpus
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: init_tensors_for_gather_scatter(actors, array_size, dtype, tensor_backend) without return types