The running_loss calculation multiplies the averaged batch loss (loss) with the current batch size, and divides this sum by the total number of samples.
In your example you are summing the averaged batch losses and divide by the number of batches.
This might create an offset, if your last batch is smaller than the others.
Your code snippet looks alright, if you want to ignore the potential offset in the loss calculation.
However, val_epoch_tr_loss uses the loss of the last batch during training and divides by the number of batches in the training DataLoader, which still seems to be wrong.