It depends on what do you want to do with the loss.
Do you just need the value so you know what the average for the dataloaders are? Or is it something else? More particularly, I don’t understand you you to backward the loss_tot.
If you look at how it works, I think loss_tot will be loss of the last batch of the last dataloader + losses of the last batches of the dataloaders. It doesn’t make sense.