How can I apply the same RANDOM data augmentations on both input and ground truth?

I am using torchvision.transforms.RandomRotation to try and create random rotations for both my input and ground truth. How do I make sure that RandomRotation applies the same randomness to both sets? Currently when I show my images I can see each pair of X and Y are getting different rotations.

You should look at torchvision functional transforms

You can randomly choose augmentation stratergy and apply on both input and ground truth

Thank you this works, you just have to sample a random integer and use that as the degress param for the functional transform.