The problem is that the last layer of your encoder is a max pooling.
In your custom forward, you do: x, i = self.mp1e(x) to get on one side the output and on the other the indices.
But with the Sequential module, then you give the tuple of these two outputs to the Linear layer. Which is unexpected.
Also you might need a reshape before the Linear to go from the 4D inputs of convolutions to the 2D input of a Linear layer.