Perform Transformation on Images based on Target

I intend to perform transformations on each image of the dataset. The transformations require the class label (I’m generating adversarial examples). For this, the target label must be passed to the adversarial algorithm for transformation. Is there any way to achieve this?

transform = transforms.Compose(

Some people may recommend extending the dataset class and performing transformations there, but I want to achieve this using transformation.