I remember having a similar error.
I believe that making a DataLoader with the torchvision.dataset.VOCDetection does not work. This is because the labels are a dictionary and pytorch does not know how they should be placed into a tensor as a batch. You will see that the code probably runs fine if you use batch_size = 1. I agree however that the error message is somewhat misleading.
I suggest writing your own dataset class 58,  which can still use torchvision.datasets.VOCDetection,  where you use your prepare_ground_truth function to convert the labels into a tensor. Then use this dataset inside the DataLoader.
Hope this helps!