Max pooling immediately followed by upsampling

I saw in some code that I’m using something like that:

...
out = torch.nn.functional.max_pool2d(out, kernel_size=2, stride=2)
out = nn.functional.upsample(out, scale_factor=2)
....

It seems odd and I don’t really see the value in that. Any ideas?

P.S:
I know the code was adapted from some torch (LUA) code, but it seems to have the exact same meaning:

....
local out = nn.SpatialMaxPooling(2,2,2,2)(out)
local out = nn.SpatialUpSamplingNearest(2)(out)
...