def make_2d ( ary ) : dim_0 ,  * _ = np . atleast_1d ( ary ) . shape return ary . reshape ( dim_0 , - 1 , order = "F" )
how to flatten 3d array in python
Convert any array into a 2d numpy array .
def make_2d(ary):
    """Convert any array into a 2d numpy array.

    In case the array is already more than 2 dimensional, will ravel the
    dimensions after the first.
    """
    dim_0, *_ = np.atleast_1d(ary).shape
    return ary.reshape(dim_0, -1, order="F")