Hi,
What this error means is that some part of the graph is shared between iteration. This is most likely due to the fact that you pre-compute something outside of the for loop and re-use it at each iteration inside.
If you want gradients flowing throw these computations, you should move them inside the for-loop.
If you don’t want gradients flowing, you should .detach() the result of the pre-computations so that gradients won’t flow back there.