code: def inter_allreduce_gpu(
      inter_mpi_comm,
      size,
      gpu_buffer_a,
      gpu_buffer_b,
      n_bytes_buffer,
      n_elems_per_node,
      n_bytes_per_node,
      cuda_stream,
  ):
      inter_size = inter_mpi_comm.size
  
      # Exchange all data to get own region data (bufferB -> bufferA)
      cuda_stream.synchronize()
      inter_mpi_comm.Alltoall(
          [gpu_buffer_b.buffer(n_bytes_buffer), mpi4py.MPI.FLOAT],
          [gpu_buffer_a.buffer(n_bytes_buffer), mpi4py.MPI.FLOAT],
      )
  
      # Reduce own region data (inplace bufferA) and averaging
      ret = gpu_buffer_a.array(inter_size * n_elems_per_node).reshape(
          inter_size, n_elems_per_node
      ).sum(axis=0) * (1.0 / size)
  
      # Gather others' region data (bufferA -> bufferB)
      for i in range(0, inter_size):
          gpu_buffer_a.from_device(
              ret, n_bytes_per_node, i * n_bytes_per_node
          )
  
      cuda_stream.synchronize()
      inter_mpi_comm.Alltoall(
          [gpu_buffer_a.buffer(n_bytes_buffer), mpi4py.MPI.FLOAT],
          [gpu_buffer_b.buffer(n_bytes_buffer), mpi4py.MPI.FLOAT],
      )
  
file_path: chainer/chainermn/communicators/_communication_utility.py
imports: from chainermn import nccl
  import collections
  import numpy
  import pickle
  import mpi4py.MPI
label_desc: Use image node_id 5 for calling a global function with example usage: inter_allreduce_gpu(inter_mpi_comm, size, gpu_buffer_a, gpu_buffer_b, n_bytes_buffer, n_elems_per_node, n_bytes_per_node, cuda_stream) without return types