Custom im2col function

Hi All,

I am studying the paper “Random Shifting for CNN: a Solution to Reduce
Information Loss in Down-Sampling Layers” where a new way to take the stride operation is presented. I want to implement this idea but it needs modification in the way the filter moves over the image. I guess that I will have to change the kernel itself, does anyone know how to do it? Is there a sample code guiding me towards the same?

Another option is to write a new layer in Pytorch itself as shown here?

Thanks,
Shivin