You don’t want gradients for your “target” Tensor but you do want gradients for the second argument of bce right?
And bce does not implement backward towards that second argument.
But in your second call, you give your “input” Tensor (that requires grad) as the second argument.