`print(output) does not get called again. On the third example, the breakpoint hits are as follows:
print(output)
loss.backward()
loss.backward()
*exit with error*

I’ll go check with the Transformer folks to see what they think and mention your question about the autograd. It very well could be the case that it’s being called somewhere else in the library. I agree also that I don’t see how loss.backward() could be called twice, but not cause problems on the other examples.