This error will occur if any part of your computational graph is shared with the previous iteration.
For example here, if out is not resetted between iterations, you will backpropagate twice in this part of the graph.