How to get the same RandomResizedCrop result of img and gt

https://discuss.pytorch.org/t/torchvision-transfors-how-to-perform-identical-transform-on-both-image-and-target/10606

Read the topic above, and then read some Github issues. Now, I think the best solution is to write own transform(take both image and target as arguments).
For example, my initial question can be solved as below.



Now, the transform result of image and target are same. Here, mainly use torchvision.Transform.get_params() and torchvision.transforms.functional.xxx.

The Github Issue link mentioned above: https://github.com/pytorch/vision/issues/230.
If you want convenience, you can git clone https://github.com/pytorch/vision/blob/main/references/segmentation/transforms.py to your workspace.(My solution is also mimic him)