Patch a full dataset folder images

How can I create patches of size (64,64) for images with 3 channels and save them from a dataset of size (256,256).

You could use tensor.unfold to create the patches and save them via torch.save.

How tensor.unfold perform patching, is it randomaly?
And then how can I reconstruct the original images?

No, it’s not randomly and the example in the docs would show how the kernel size and stride is applied.
To reconstruct the input, you could take a look at the nn.Unfold and nn.Fold docs.