The question is analogous to Slice 2d array into smaller 2d arrays except for the fact that I use tensors (torch) & I have a 4D, not 2D, tensor of the shape eg. (3, 1, 32, 32) - in my case, it is 3 images of size 32x32.
I want to split each tensor of form [i, 0, :, :] into smaller subarrays, so the output would have a shape eg. (3, 16, 8, 8), where each [:, j, :, :] is a small square cut from the original image. I cannot find a way to modify the proposed solution for 4D tensor.
I also tried to just use
subx = x.reshape(3, 16, 8, 8)
but this does not reshape it as I want.