class_docstr: MpiCommunicatorBase
  
  Implementation of communicator interface defined by
  :class:`CommunicatorBase`. This communicator assumes MPI4py and
  all ChainerMN processes are invoked by ``mpirun`` (``mpiexec``)
  command. Although this lacks several important methods such as
  ``multi_node_mean_grad`` to be impelmented with speficic algorithm. See
  hierarchical communicator or pure_nccl communicator for example.
docstr: A primitive of inter-process allreduce communication.
  
  This method tries to invoke allreduce communication within the
  communicator. All processes in the communicator are expected to
  invoke ``allreduce()``. This method relies on mpi4py fast communication
  optimized for numpy arrays, as well as ``send()`` and ``recv()``.
  
  Note that this method can only handle the same shapes of data
  over all processes, and cannot handle tuple data.
  
  If ``x`` is numpy array, the received data will also be allocated
  as numpy array. Additionally, when ``x`` is cupy array, the returned
  array will be placed at current device
  (``https://docs-cupy.chainer.org/en/stable/tutorial/basic.html#current-device``)
  regardless of which device the argument is placed at remote nodes.
  
  Args:
      x (numpy/cupy array): An array to apply allreduce operation.
  
  Returns:
      ys (numpy/cupy array): An array that allreduce (currently SUM only)
          has been applied.
docstr_tok: ["A","primitive","of","inter-process","allreduce","communication",".","This","method","tries","to","invoke","allreduce","communication","within","the","communicator",".","All","processes","in","the","communicator","are","expected","to","invoke","``","allreduce","(",")","``",".","This","method","relies","on","mpi4py","fast","communication","optimized","for","numpy","arrays",",","as","well","as","``","send","(",")","``","and","``","recv","(",")","``",".","Note","that","this","method","can","only","handle","the","same","shapes","of","data","over","all","processes",",","and","can","not","handle","tuple","data",".","If","``","x","``","is","numpy","array",",","the","received","data","will","also","be","allocated","as","numpy","array",".","Additionally",",","when","``","x","``","is","cupy","array",",","the","returned","array","will","be","placed","at","current","device","(","``","https",":","\/\/docs-cupy.chainer.org\/en\/stable\/tutorial\/basic.html","#","current-device","``",")","regardless","of","which","device","the","argument","is","placed","at","remote","nodes",".","Args",":","x","(","numpy\/cupy","array",")",":","An","array","to","apply","allreduce","operation",".","Returns",":","ys","(","numpy\/cupy","array",")",":","An","array","that","allreduce","(","currently","SUM","only",")","has","been","applied","."]
code: def allreduce(self, x):
      """A primitive of inter-process allreduce communication.
  
      This method tries to invoke allreduce communication within the
      communicator. All processes in the communicator are expected to
      invoke ``allreduce()``. This method relies on mpi4py fast communication
      optimized for numpy arrays, as well as ``send()`` and ``recv()``.
  
      Note that this method can only handle the same shapes of data
      over all processes, and cannot handle tuple data.
  
      If ``x`` is numpy array, the received data will also be allocated
      as numpy array. Additionally, when ``x`` is cupy array, the returned
      array will be placed at current device
      (``https://docs-cupy.chainer.org/en/stable/tutorial/basic.html#current-device``)
      regardless of which device the argument is placed at remote nodes.
  
      Args:
          x (numpy/cupy array): An array to apply allreduce operation.
  
      Returns:
          ys (numpy/cupy array): An array that allreduce (currently SUM only)
              has been applied.
  
      """
  
      msgtype = _MessageType(x)
      _check_dtype("allreduce", msgtype)
  
      if msgtype.is_tuple:
          raise TypeError("allreduce cannot handle tuple data")
  
      xp = chainer.backend.get_array_module(x)
  
      # TODO(kuenishi): do we check all messages have same shape and dims?
  
      # Source buffer
      sbuf = _memory_utility.array_to_buffer_object(
          x, _get_mpi_type(msgtype)
      )
      # Destination buffer and its object
      shape = msgtype.shapes[0]
      dbuf = xp.empty(
          [chainer.utils.size_of_shape(shape)], dtype=msgtype.dtype
      )
      dbuf_buffer_obj = _memory_utility.array_to_buffer_object(
          dbuf, _get_mpi_type(msgtype)
      )
      self.mpi_comm.Allreduce(sbuf, dbuf_buffer_obj)
  
      return dbuf.reshape(shape)
  
imports: import mpi4py
  import numpy
  import chainer
  import chainer.backends
  import chainer.utils
  from chainer.utils import collections_abc
  from chainermn.communicators import _communication_utility
  from chainermn.communicators._communication_utility import chunked_bcast_obj
  from chainermn.communicators import _memory_utility
  from chainermn.communicators import communicator_base
  import chainerx
label_desc: Use image node_id 17 for calling the MpiCommunicatorBase obj's underlying member method code with example usage: obj.allreduce(x) and returns: dbuf