torchvision.transforms expect the PIL.Image as an input and also return the image, while your custom transformation returns a dict and tries to unwrap the incoming image so you won’t be able to use this transformation directly in transforms.Compose.
You could apply the torchvision.transformations on the image and target separately and use RandomStretch on both of them in another custom class.