You actually want gradients for your targets?
If it is the case, I would recommend using BCELossWithLogits 62 which combines Sigmoid and BCELoss and for which the gradients for the target is implemented.