How to get the loss from the Trainer class?

I’m implementing a DecisionTransformer as in this tutorial.
But the problem is that since I run the code in a python file and not in a jupyter notebook, when it cames to the line:

trainer.train()

than I have to wait the end of the training for getting the loss, the epoch and the learning_rate and so on.
But I want to keep track of those values during the training.
Is there any way to achieve that?