A = np.arange(16).reshape(4, 4)
A
strides = A.itemsize * np.array([8, 2, 4, 1])
x = p.lib.stride_tricks.as_strided(A, shape=(2, 2, 2, 2), strides=strides)
x
x.reshape(4, 2, 2)
Numpy - Reshape and partition 2D array to 3D