I know it is late, but I am also looking for the same answer. Here is what I got, hope it helps others who got the same question in the future.
    def mse_loss(self, input, target, ignored_index, reduction):
        mask = target == ignored_index
        out = (input[~mask]-target[~mask])**2
        if reduction == "mean":
            return out.mean()
        elif reduction == "None":
            return out