How to output loss from model.generate()?

I have a question.
Are there concerns that temporarily removing @torch.no_grad() could lead to learning during the test phase?