Which PyTorch version are you using? If I remember correctly, this bug was recently fixed by @albanD in this PR 5 and I get an error using your my_MSELoss function as:

RuntimeError: derivative for argmax is not implemented