How to train model with different sized images in pytorch for introducing Spatial pyramid pooling

i am working on the dataset with variable sized images. i have to apply Spatial Pyramid pooling for it. my confusion is that how do i apply varying sized images? do i resize the image in preprocessing or train the model with variable inputs?