This isn’t very common so I’m not sure what the cleanest way to do this is without writing a custom transformation.
What does transforms.RandomCrop(23) give you? or transforms.RandomCrop(28, padding=2)? Note that I picked 2 in this case because I’m not sure if you meant 5 pixels long each axis or each border.