According to document of MSELoss:
Input: (N,∗) where * means, any number of additional dimensions
Target: (N,∗), same shape as the input

The first argument is Input and second is the Target, so you are passing them in a wrong order.
And, the size of the Input and Target should be the same no matter what shape they are. Like 10 and 10 is OK, 10x30 and 10x30 is OK, but 10x30 and 10x40 is not OK.