I resolved it, though I am encountering some other error. Did you applied same transformations to both images and mask. i have the following transformations-
data_transforms = transforms.Compose([transforms.RandomCrop((512,512)),
                                 transforms.Lambda(gaussian_blur),
                                 transforms.Lambda(elastic_transform),
                                 transforms.RandomRotation([+90,+180]),
                                 transforms.RandomRotation([+180,+270]),
                                 transforms.RandomHorizontalFlip(),
                                 transforms.ToTensor(),
                                 transforms.Normalize(mean=train_mean, std=train_std)
                               ])

Here, rotation, flips are to be applied to both images and mask and rest of the transforms only to the images, I followed  this 31 post but I can’t use lambda transforms using this way.So I am just thinking of a workaround it?