I tried writing my own function
class JointHorFlip(object):
    def __call__(self, img, target):
        if random.random() < .5:
            return (F.hflip(img), F.hflip(target))
        return (img, target)

train_set = torchvision.datasets.VOCSegmentation(
            root = '../data',
            year = '2012',
            image_set = 'train',
            transforms = JointHorFlip(),
    )

but when I check through the images, the inputs and targets are still not consistent?