Could you check the shape of boxes?
While your indexing assumes boxes has two dimensions, the error message states that it only contains a single dimension.
In your __getitem__ boxes are created via boxes = torch.as_tensor(boxes, dtype=torch.float32), which also works for a single object:
boxes = []
boxes.append([0, 0, 0, 0])
boxes = torch.as_tensor(boxes, dtype=torch.float32)
print(boxes.shape)
> torch.Size([1, 4])
area = (boxes[:, 3] - boxes[:, 1]) * (boxes[:, 2] - boxes[:, 0]) # works