How to extract smaller image patches (3D)?

Maybe you can draw some ideas from here https://github.com/pytorch/pytorch/issues/3387