This is my dataset class:
class Dataset(Dataset):

    def __init__(self, dataset_path='./data/CT',  is_train=True, resize=64, cropsize=64):
        
        self.dataset_path = dataset_path
        self.is_train = is_train
        self.resize = resize
        self.cropsize = cropsize

        
        self.x, self.y, self.mask = self.load_dataset_folder()

        
        self.transform_x = T.Compose([T.Resize(resize),
                                      T.CenterCrop(cropsize),         
                                      T.Grayscale(channel),
                                      T.ToTensor(),
                                      T.Normalize(mean=[0.5, 0.5, 0.5],
                                                  std=[0.5, 0.5, 0.5])])
        
        self.transform_mask = T.Compose([T.Resize(resize),
                                         T.CenterCrop(cropsize),
                                         T.Grayscale(channel),
                                         T.ToTensor()])
        


    #Function to obtain the     
    def __getitem__(self, idx):
        x, y, mask = self.x[idx], self.y[idx], self.mask[idx]

        x = Image.open(x)
        x = self.transform_x(x)

        if y == 0:
            mask = torch.zeros([1, self.cropsize, self.cropsize])

        else:
            mask = Image.open(mask)
            mask = self.transform_mask(mask)

        return x, y, mask
        


    def __len__(self):
        return len(self.x)


    def load_dataset_folder(self):
        phase = 'train' if self.is_train else 'test'
        
        #lists of images, labels and masks 
        x, y, mask = [], [], []

        img_dir = os.path.join(self.dataset_path, phase)
        gt_dir = os.path.join(self.dataset_path, 'ground_truth')

        img_types = sorted(os.listdir(img_dir))
        
        for img_type in img_types:
            
            img_type_dir = os.path.join(img_dir,  img_type)     
            if not os.path.isdir(img_type_dir):
                continue

            img_fpath_list = sorted([os.path.join(img_type_dir, f) for f in os.listdir(img_type_dir) ])

            x.extend(img_fpath_list)
                # load gt labels

            if img_type == 'normal':
                y.extend([0] * len(img_fpath_list))
                mask.extend([None] * len(img_fpath_list))
            
            else:
                y.extend([1] * len(img_fpath_list))
                
                gt_type_dir = os.path.join(gt_dir, img_type)
                #img_fname_list = [os.path.splitext(os.path.basename(f))[0] for f in img_fpath_list]
                
                gt_fpath_list = sorted([os.path.join(gt_type_dir, d) for d in os.listdir(gt_type_dir) ])

                mask.extend(gt_fpath_list)             
       
     #   assert len(x) == len(y), 'number of x and y should be same'
        return list(x), list(y), list(mask)


How can I solve the problem?