If you’ve just wrapped the loss function using nn.MSELoss into your custom class, both approaches should work identically.
Is the slower training reproducible?
Also, in your second script it looks like you are not initializing nn.MSELoss but just pass the input and target values directly. Is this a typo pasting the code?
Could you check the shapes on input and target using both approaches?
Make sure both shapes are equal, as otherwise an unwanted broadcasting might happen which could slow down or stop your training.