You are not using any transformations in Dataset.__getitem__ at the moment, so image and mask will be the loaded images transformed to tensors.
It seems they have a different shape, which would yield this error.
To apply the transformations, you would have to assign transforms in __init__ via:
self.transforms = transforms

and apply it in __getitem__:
if self.transforms:
    image = self.transforms(image)

Note that the torchvisiontransformswork onPIL.Imagesby default, so you might need to switch toPIL` to load the images.