Thanks. This makes sense, but I was unsure to use detach because of what is said in the following post:
“When a variable is detached, the backward computations will not visit the branches that start from this variable (all the operations done on it).”
If I understand this statement correctly, this is not exactly what I want. I do want backprop on operations that involved this variable (although not with respect to this variable itself.)