def patches2image(patches):
    """
        Return patches obtained from a 2D image into the original image.

        Args:
            patches: 
                Tiles to return into the 2D image. Shape = (N_patch_x, N_patch_y, Patch_size_x, Patch_size_y)
            Return:
                image:
                    2D image reconstructed from patches

    """
    
    assert len(patches.shape) == 4, "patches2image is compatible with image2patches, input patches should be in the shape (N_patch_x, N_patch_y, Patch_size_x, Patch_size_y)"
    n_h,n_w,p0,p1 = patches.shape
    return patches.reshape(n_h, n_w, p0,p1).swapaxes(1,2).reshape(n_h*p0,n_w*p1)