Oh yes, I removed the transformations in __getitem__, I defined a method transform in class MyDataset and call transform in __getitem__.
The code as follows:
class MyDataset(Dataset):
    def __init__(self, root,set_name,):
        super(MyDataset, self).__init__()
        assert set_name == 'train' or set_name == 'val' or set_name == 'test'
        self.root = root
        self.set_name = set_name
        self.mapping = {
            0: 0,
            255: 1
        }
        self.image_list = glob.glob(os.path.join(
            root,
            set_name,
            args.images_folder,
            "*.tif",
        ))
        self.label_list = glob.glob(os.path.join(
            root,
            set_name,
            args.labels_folder,
            "*.tif",
        ))

    def mask_to_class(self, mask):
        for k in self.mapping:
            mask[mask == k] = self.mapping[k]
        return mask

    def transform(self, image, mask):
        # Resize
        resize = transforms.Resize(size=(args.input_size, args.input_size))
        image = resize(image)
        mask = resize(mask)
        # Random horizontal flipping
        if random.random() > 0.5:
            image = TF.hflip(image)
            mask = TF.hflip(image)
        # Random vertical flipping
        if random.random() > 0.5:
            image = TF.vflip(image)
            mask = TF.vflip(mask)
        # masks to gray_scale
        mask = TF.to_grayscale(mask)
        # Transform to Tensor
        image = TF.to_tensor(image)
        mask = TF.to_tensor(mask)
        mask = self.mask_to_class(mask)
        # Normalized only images? Yes
        image = TF.normalize(image, mean=[0.4353, 0.4452, 0.4131],
                             std=[0.2044, 0.1924, 0.2013])
        return image, mask

    def __getitem__(self, index):

        images = Image.open(self.image_list[index]).convert('RGB')
        masks = Image.open(self.label_list[index]).convert('RGB')
        t_images, t_masks = self.transform(images, masks)
        return t_images, t_masks

    def __len__(self):

        return len(self.image_list)

And test dataset and dataloader like this:
    dst = MyDataset(root = args.dataset_root_dir, set_name="train")
    #print(len(dst)) 
    data_loader = DataLoader(dataset=dst, batch_size=args.batch_size, shuffle=False)
    for i, (data, target) in enumerate(data_loader):
        print(i)
        print(data.shape)
        print(target.shape)
        break


data.shape is [batch_size, 3, height, width]
target.shape is [batch_size, 1, height, width]

But when I read masks as Grayscale, when do a vertical and horizontal flip there will be a dimension mismatch error.
How can I read the images as RGB and masks as Grayscale directly without these so many conversions?
Thank you very much !