code: def test_reduce(seed, dst, inplace, division, comm_nccl_opts):
      if comm_nccl_opts is None:
          pytest.skip(
              "Communicator test is disabled. You can turn it on by an option `--test-communicator`."
          )
      if len(comm_nccl_opts.devices) < 2:
          pytest.skip(
              "Communicator test is disabled. Use more than 1 gpus."
          )
  
      comm = comm_nccl_opts.comm
      device_id = int(comm_nccl_opts.device_id)
      n_devices = len(comm_nccl_opts.devices)
      mpi_rank = comm_nccl_opts.mpi_rank
  
      # Variables
      x_list = []
      x_data_list = []
      x_d_list = []
      num_layers = 20
      rng = np.random.RandomState(seed)
      for l in range(num_layers):
          x_data = rng.rand(3, 4)
          x_data_list.append(x_data)
          x = nn.Variable(x_data.shape)
          x.d = x_data * (device_id + 1)
          x_d_list.append(x.d.copy())
          x_list.append(x)
  
      # Reduce
      comm.reduce(
          [x.data for x in x_list],
          dst,
          division=division,
          inplace=inplace,
      )
  
      if mpi_rank == dst:
          # Ref Reduce
          refs = ref_reduce(x_data_list, n_devices, division)
  
          # Check
          for x, ref in zip(x_list, refs):
              assert_allclose(x.d, ref, rtol=1e-3, atol=1e-6)
  
      else:
          for x, ref in zip(x_list, x_d_list):
              assert_allclose(x.d, ref, rtol=1e-3, atol=1e-6)
  
file_path: nnabla/python/test/communicator/test_comm_reduce.py
imports: import pytest
  import nnabla
  import nnabla.parametric_functions
  import numpy
  from nnabla.testing import assert_allclose
  from six.moves import reduce
label_desc: Use image node_id 2 for calling a global function with example usage: test_reduce(seed, dst, inplace, division, comm_nccl_opts) without return types