Ah yes you are correct!
I meant scaling it by the inverse scale of the mask which is what I assume you are referring to in the last line of code.
I am curious if there was some torch component or loss function argument that did this “behind the scenes”. I think it might just be better to do it explicitly like you suggested.