I don’t know in which context this code was produced and if 2000 iterations are one epoch.
How would you define the “true” train error at the end of each epoch?
Would you just use the last batch loss, the average of all batches or in the worst case iterate the training set in eval mode and print the loss?
I just guess the code runs quite fast, the user didn’t want his terminal to be flooded with a lot of information (printing might also be quite expensive if you do it at high frequencies), and thus only prints the average of the last 2000 batches.