How to get the same RandomResizedCrop result of img and gt

my code snippet is below

Now ,the img ,gt do different RandomResizedCrop. But I want they do the same, because the img and gt must be correspond.
How should I modify the code?

This thread might be relevant

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

The Github Issue link mentioned above:
If you want convenience, you can git clone to your workspace.(My solution is also mimic him)