How to random crop a image tuple

I have a image tuple (image,segmentation result),I want to augment my dataset by random crop operation.But I don’t know how to random the two pics simutaneously,I mean, the random crop must be an atomic opearion which applied on the two image,crop the exact the same part.

I think in torch.transforms you can do that while apply the dataset itself.

are these api crop exactly the same region on image and segmentation result?

I would recommend to use the functional API.
Here is an example.