Solved by eqy in post #2 
              
              
                I don’t think the error is due to MaxPooling because the output should be a tensor as shown in the docs: MaxPool2d — PyTorch 1.9.0 documentation 
Can you post a minimal code snippet that reproduces this error or provide some details like the type of y2?