def blockshaped(arr, nrows, ncols):
h, w = arr.shape<EOL>return (arr.reshape(h // nrows, nrows, -<NUM_LIT:1>, ncols)<EOL>.swapaxes(<NUM_LIT:1>, <NUM_LIT:2>)<EOL>.reshape(-<NUM_LIT:1>, nrows, ncols))<EOL>
Return an new array of shape (n, nrows, ncols) where
n * nrows * ncols = arr.size

If arr is a 2D array, the returned array looks like n subblocks with
each subblock preserving the "physical" layout of arr.