Since f2 is not computed in a differentiable manner, from the autograd point of view, it is the same as if you were adding a constant number to your loss.
And when taking derivatives, a constant number does not change anything, so you can actually remove f2 from this line and you will see the exact same behavior wrt to the gradients that are computed.
When you use .data (which you should never use in general ) you break the “link” with tensor1 and tensor2 from the point of view of the autograd. And so what you do there is ignore for gradient computations.
Here you could replace NUM = 42 and you will get the same result.
no because in 1, you do H - NUM but here you do H + NUM. But otherwise yes they will be the same.
There are gradients flowing to H (because you compute it in a differentiable manner) and so this will influence your training.