Based on the stacktrace it seems that the DataLoader is raising this error while trying to stack the image tensors to a batch, as some tensors seems to use 3 channels while others 4.
Did you make sure that each image has indeed 4 channels? You could set the batch_size to 1, iterate the DataLoader once for an entire epoch and check the number of channels of each image.