Is it possible to save modified data to a dataloader?

Suppose each of my batches are (data, target, modified_variable) where modified_variable has shape (batch_size, *) (each datapoint has an associated mdofied_variable). At a given epoch, I’d like to modify this extra variable, and save it to be accessed at the following epoch, when the same batch is loaded. How can this be done?
As an example: modified_variable could be a perturbed version of data.

Thanks!

Assuming modified_variable is stored inside the Dataset, you could directly manipulate it after the epoch (if persistent_workers=False in your DataLoader) via loader.dataset.modified_variable = ....