Hi,
Where does “value_path” and “value_body” come from? Do they require gradients? If they do, whatever created them is a part of the gradient that will be common to all the iterations of the loop, hence the error.