Your transformation looks alright!
If you pass it to your Dataset it will be applied for every sample in the usual case.
Of course if depends, how you’ve implemented the __getitem__ in your custom Dataset class, i.e. you could randomly apply the transformation. Alternatively, you could use torchvision.transforms.RandomApply 48 to apply your transformation randomly.