Hi @ptrblck,
Right now I’m trying to divide the image into 3x3 patches, process them and then stitch them back together  into a new one.
There is a bit of a problem with my processing step: it takes too much time.
Here is my code for the process:
coor = {(0,0) : np.matrix([[0, 263, 536, 852, 1920, 2988, 3304, 3577], [2, 2, 1, 0, 0, 0, 1, 2]])
        ...
       }
patches = torch.randn(921600, 1, 3, 3)

def change_patches(patches, coor, i, j):
    coordinate = [i+1,j+1]
    indices = torch.tensor(coor[(coordinate[0],coordinate[1])])
    a = int(coordinate[0]*1280+coordinate[1]/3)
    patches[a,0,2,1] = image[0,0,indices[1,0],indices[0,0]]
    patches[a,0,2,2] = image[0,0,indices[1,1],indices[0,1]]
    patches[a,0,1,2] = image[0,0,indices[1,2],indices[0,2]]
    patches[a,0,0,2] = image[0,0,indices[1,3],indices[0,3]]
    patches[a,0,0,1] = image[0,0,indices[1,4],indices[0,4]]
    patches[a,0,0,0] = image[0,0,indices[1,5],indices[0,5]]
    patches[a,0,1,0] = image[0,0,indices[1,6],indices[0,6]]
    patches[a,0,2,0] = image[0,0,indices[1,7],indices[0,7]]
    return(patches)

I’m trying to find a way of implementing this with less time. Since this process is sequential, I want to perform this in parallel. I found out about multiprocessing.pool which has starmap() function that can only work on CPU. I noted that pytorch also has a similar one as torch.multiprocessing.
How do I use this one? Can you provide me with an example on my case?
Thank you very much!!!