Ohh right, the self is also counted as an argument. Thanks for the reminder!
Anyway, I just solved my problem. It appears that I am using the wrong CocoDetection Dataset class. I orginally used:
import torchvision.datasets as dset
# and then
coco_test = dset.CocoDetection(root = root_dir,
                                annFile = test_json,
                                transforms=get_transform())

When what I should’ve used is:
from torchvision.datasets.coco import CocoDetection
# and then
coco_test = CocoDetection(root = root_dir,
                                annFile = test_json,
                                transforms=get_transform())

And it worked!
So, it appears that there are two CocoDetection classes. One in torchvision.datasets, another in torchvision.datasets.coco. Should I inform them about this duplicate code? And if so, how should I inform them about this?