Thank you for your reply.
I used else statement as I want to print the training loss after the dataloader loop runs over all the image batches in one epoch. I find the results for both cases (with and without else statement) are similar. Could you explain why we should not use else statement here? Is it just because it make our code shorter or does it cause something wrong? Thank you!