How do I make sure the output of a CNN never decrease in size using padding?

I want to create one code such that no matter what task or input size the image is, it will always produce a ConvNet such that the padding is set such that the size of the features is always equal to the size of the original image (up until the end/final layer).

How does one do that in pytorch?

I realized this might be useful:

Cross posted with code: