@fmassa, thank you for replying! However, I don’t think that the “ReflectionPad2d” does what I want. The result given by “ReflectionPad2d” for my example is
[[5,4,5,6,5],
[2,1,2,3,2],
[5,4,5,6,5],
[8,7,8,9,8],
[5,4,5,6,5]],
not what I want for the periodic padding.
Periodic padding is a natural choice for problems with periodic boundary conditions in physics.