If I understand your use case correctly, your targets are the segmentation masks to the data.
If that’s the case, you should handle them likewise and don’t wrap them in a torch.LongTensor, since they have variable sizes.
Try to return the data and target as a list of lists:
def my_collate(batch):
    data = [item[0] for item in batch]
    target = [item[1] for item in batch]
    return [data, target]