Random crop in valid range

Some torchvision transforms like RandomRotation or RandomAffine will add pad the image with a constant at some places as they change the size of the image.
If I apply this function first and crop later, it is no problem to get an image that doesn’t have any filled regions in it but only a part of the original image (given suitable input and crop sizes). I could achieve this by simply taking the centre crop every time. But is there a way to do that with RandomCrop and control the random crop position, so that it doesn’t pick something in the padded areas? So for example like this:
Screenshot 2021-03-08 192501

You could write a custom RandomCrop method and change how the min. and max. values are created so that the random crop would be performed in your specified bounds.