Yes, you could use the functional version of pooling function 275 with dynamically computed kernel sizes, dependent on the input size:
def spatial_pyramid_pooling(input, output_size):
    assert input.dim() == 4 and input.size(2) == input.size(3)
    F.max_pool2d(input, kernel_size=input.size(2) // output_size)