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 all-to-all function.
  
  This method tries to invoke all-to-all communication within the
  communicator. All processes in the communicator are expected to
  invoke ``alltoall()``. This method relies on mpi4py fast communication
  optimized for numpy arrays, as well as ``send()`` and ``recv()``.
  
  If ``xs`` is numpy array, the returned array will also be allocated
  as numpy array. Additionally, when ``xs`` 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:
      xs (tuple of numpy/cupy array)
  
  Returns:
      ys (tuple of numpy/cupy array):
          Received arrays. The length of tuple equals to
          the communicator size.
docstr_tok: ["A","primitive","of","inter-process","all-to-all","function",".","This","method","tries","to","invoke","all-to-all","communication","within","the","communicator",".","All","processes","in","the","communicator","are","expected","to","invoke","``","alltoall","(",")","``",".","This","method","relies","on","mpi4py","fast","communication","optimized","for","numpy","arrays",",","as","well","as","``","send","(",")","``","and","``","recv","(",")","``",".","If","``","xs","``","is","numpy","array",",","the","returned","array","will","also","be","allocated","as","numpy","array",".","Additionally",",","when","``","xs","``","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",":","xs","(","tuple","of","numpy\/cupy","array",")","Returns",":","ys","(","tuple","of","numpy\/cupy","array",")",":","Received","arrays",".","The","length","of","tuple","equals","to","the","communicator","size","."]
code: def alltoall(self, xs):
      """A primitive of inter-process all-to-all function.
  
      This method tries to invoke all-to-all communication within the
      communicator. All processes in the communicator are expected to
      invoke ``alltoall()``. This method relies on mpi4py fast communication
      optimized for numpy arrays, as well as ``send()`` and ``recv()``.
  
      If ``xs`` is numpy array, the returned array will also be allocated
      as numpy array. Additionally, when ``xs`` 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:
          xs (tuple of numpy/cupy array)
  
      Returns:
          ys (tuple of numpy/cupy array):
              Received arrays. The length of tuple equals to
              the communicator size.
      """
      chainer.utils.experimental(
          "chainermn.communicators.MpiCommunicatorBase.alltoall"
      )
  
      if len(xs) != self.size:
          raise ValueError(
              "The length of data must be same as communicator size."
          )
  
      # Type check.
      msgtypes = [_MessageType(x) for x in xs]
      for msgtype in msgtypes:
          _check_dtype("alltoall", msgtype)
      _check_dtypes_are_same(msgtypes)
      send_msgtype = msgtypes[0]
  
      msgtypes = self.mpi_comm.alltoall(msgtypes)
      _check_dtypes_are_same(msgtypes)
      recv_msgtype = msgtypes[0]
  
      # Collective communication.
      slens = [x.size for x in xs]
      xp = chainer.backend.get_array_module(*xs)
      sbuf = xp.hstack([x.reshape(-1) for x in xs])
      shapes = [msgtype.shapes[0] for msgtype in msgtypes]
      rlens = [chainer.utils.size_of_shape(s) for s in shapes]
      rbuf = xp.empty([sum(rlens)], dtype=msgtype.dtype)
      if xp is not numpy:
          sbuf = _memory_utility.get_device_memory_pointer(sbuf)
          chainer.cuda.Stream.null.synchronize()
      self.mpi_comm.Alltoallv(
          [
              sbuf,
              (slens, _cnt_to_dsp(slens)),
              _get_mpi_type(send_msgtype),
          ],
          [
              _memory_utility.get_device_memory_pointer(rbuf),
              (rlens, _cnt_to_dsp(rlens)),
              _get_mpi_type(recv_msgtype),
          ],
      )
      ys = [
          rbuf[i : i + l].reshape(s)
          for i, l, s in zip(_cnt_to_dsp(rlens), rlens, shapes)
      ]
  
      return tuple(ys)
  
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 11 for calling the MpiCommunicatorBase obj's underlying member method code with example usage: obj.alltoall(xs) and returns: tuple