I’m unsure what might be causing the issue. Creating a random PIL.Image inside the Dataset works fine:
class MultiClassCelebA(Dataset):
    def __init__(self, dataframe, folder_dir, transform=None, target_transform=None):
        self.transform = transform
        self.target_transform = target_transform
        
    def __len__(self):
        return 10
    
    def __getitem__(self, index):
        image = transforms.ToPILImage()(torch.randn(3, 224, 224))
        label = torch.randint(0, 10, (1,))
        if self.transform is not None:
            image = self.transform(image)
        if self.target_transform is not None:
            label = self.target_transform(label)
        return image, label

tfms = transforms.Compose([transforms.Resize((256, 256)),
                           transforms.PILToTensor()])

train_dl = MultiClassCelebA(None, None, transform=tfms)

train_dataloader = DataLoader(train_dl, shuffle = True, batch_size = 32)
next(iter(train_dataloader))