class_docstr: Collective gather communication.
class_docstr_tok: ["Collective","gather","communication","."]
code: def forward(self, inputs):
      xp = backend.get_array_module(*inputs)
      (x,) = inputs
  
      # convert to float32 for communication
      x_dtype = x.dtype
      if numpy.float16 == x_dtype:
          x = x.astype(numpy.float32)
      ys = self.comm.gather(x, self.root)
  
      if self.comm.rank == self.root:
          # convert back
          if numpy.float16 == x_dtype:
              ys = tuple([item.astype(x_dtype) for item in ys])
          return ys
  
      else:
          # Return an empty variable, which serves as "delegate_variable."
          return (xp.array([], dtype=x_dtype),)
  
imports: import chainer
  from chainer import backend
  import numpy
label_desc: Use image node_id 2 for calling the Gather obj's underlying member method code with example usage: obj.forward(inputs) and returns: ys, xp