You could use tensor.unfold to create the patches and reshape them back as explained in this post.
tensor.unfold