This thread might be relevant
  
    
    
    Torchvision.transfors: How to perform identical transform on both image and target? vision
  
  
    How can I perform an identical transform on both image and target? 
For example, in Semantic segmentation and Edge detection where the input image and target ground-truth are both 2D images, one must perform the same transform on both input image and target ground-truth.