code: def cube2matrix(data_cube):
      r
  
      return data_cube.reshape([data_cube.shape[0]] +
                               [np.prod(data_cube.shape[1:])]).T
docs: r"""Cube to Matrix
  
      This method transforms a 3D cube to a 2D matrix
  
      Parameters
      ----------
      data_cube : np.ndarray
          Input data cube, 3D array
  
      Returns
      -------
      np.ndarray 2D matrix
  
      Examples
      --------
      >>> from modopt.base.transform import cube2matrix
      >>> a = np.arange(16).reshape((4, 2, 2))
      >>> cube2matrix(a)
      array([[ 0,  4,  8, 12],
             [ 1,  5,  9, 13],
             [ 2,  6, 10, 14],
             [ 3,  7, 11, 15]])