class_docstr: A sparse matrix in COO format.
  
  Args:
      data (:ref:`ndarray`): The entries of the matrix.
          The entries are usually non-zero-elements in the matrix.
      row (:ref:`ndarray`): The row indices of the matrix
          entries.
      col (:ref:`ndarray`): The column indices of the matrix
          entries.
      shape (tuple of int): The shape of the matrix in dense format.
      order ('C', 'F', 'other' or None): If ``'C'``, the maxtix is assumed
          that its row indices are sorted. If ``'F'``, the matrix is assumed
          that its column indices are sorted. If ``'other'``, the matrix is
          assumed as neither 'C' order nor 'F' order. If ``None`` (this is
          the default), the matrix is automatically checked if it is 'C'
          order, 'F' order or another. This information will be used by some
          functions like :func:`~chainer.functions.sparse_matmul` as a hint
          to improve performance.
      requires_grad (bool): If ``True``, gradient of this sparse matrix will
          be computed in back-propagation.
  
  .. seealso::
      See :func:`~chainer.utils.to_coo` for how to construct a COO matrix
      from an array.
docstr: Returns a dense matrix format of this sparse matrix.
code: def to_dense(self):
      """Returns a dense matrix format of this sparse matrix."""
      data = self.data
      if data.ndim == 1:
          shape = self.shape
      elif data.ndim == 2:
          shape = (data.shape[0], *self.shape)
      else:
          assert False
  
      xp = data.xp
      x = xp.zeros(shape, dtype=data.dtype)
  
      if data.size > 0:
          row = self.row
          col = self.col
          if xp is numpy:
              add_at = numpy.add.at
          elif xp is cuda.cupy:
              add_at = cuda.cupyx.scatter_add
  
          data = data.array
          if data.ndim == 1:
              _add_at(add_at, x, row, col, data)
          elif data.ndim == 2:
              for i in range(data.shape[0]):
                  _add_at(add_at, x[i], row[i], col[i], data[i])
          else:
              assert False
      return x
  
file_path: chainer/chainer/utils/sparse.py
imports: import numpy
  import chainer
  from chainer import backend
  from chainer import cuda
label_desc: Use image node_id 2 for calling the CooMatrix obj's underlying member method code with example usage: obj.to_dense() and returns: x