Hi @rasbt, thanks for your answer, but I do not understand what you’re suggesting. What is the difference between  torch.nn.fanctional 's  max_pool2d  and  torch.nn 's  MaxPool2d ? I mean, to my understanding, what you wrote will do the maximum pooling on  x , but how I would use the appropriate indices in order to pull from another tensor  y ?

Oh, I misread your question. I somehow thought your question was more about how to dynamically change the pooling sizes based on the input. MaxPool2d and max_pool2d would do the same thing. But with MaxPool2d you instantiate it as an object instance (of a class) so you can’t conveniently change the pooling size during the forward pass.