What kind of error are you seeing?
Would you like to apply a specific pre-defined kernel for the “smoothing” operation?
If so, you should be able to define the kernel and apply a grouped convolution to the input.
The functional API would probably be a bit easier than using the nn.Conv2d module.