I guess you are changing the attribute of a reference, so you could create different objects for the training and validation datasets instead.
Your code currently doesn’t show the complete workflow, but since total_loader is reused, the same internal dataset would be used.