Wouldn’t the provided code snippet automatically reconstruct the image using the correct patches?
Also, if you put all patches into the batch dimension, you could avoid the for loop, which should be slower than a single forward pass.