This error should be raised, since you are attaching tensors to self.zs in each iteration and use them in backprop.
This would let the computation graph grow until you would be running out of memory.
I’m not familiar with your use case, but you could reinitialize the list at the beginning of the forward method via self.zs = [].