def __getitem__(self, index):
        """
        Loads an instance given its index.

        :param index: The index of the instance to retrieve.

        :return: a (sample, target) tuple where the target is a
            torchvision-style annotation for object detection
            https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
        """
        img_id = self.img_ids[index]
        img_dict: LVISImgEntry = self.lvis_api.load_imgs(ids=[img_id])[0]
        annotation_dicts: LVISImgTargets = self.targets[index]

        # Transform from LVIS dictionary to torchvision-style target
        num_objs = annotation_dicts["bbox"].shape[0]

        boxes = []
        labels = []
        for i in range(num_objs):
            xmin = annotation_dicts["bbox"][i][0]
            ymin = annotation_dicts["bbox"][i][1]
            xmax = xmin + annotation_dicts["bbox"][i][2]
            ymax = ymin + annotation_dicts["bbox"][i][3]
            boxes.append([xmin, ymin, xmax, ymax])
            labels.append(annotation_dicts["category_id"][i])

        if len(boxes) > 0:
            boxes = torch.as_tensor(boxes, dtype=torch.float32)
        else:
            boxes = torch.empty((0, 4), dtype=torch.float32)
        labels = torch.as_tensor(labels, dtype=torch.int64)

        image_id = torch.tensor([img_id])
        areas = []
        for i in range(num_objs):
            areas.append(annotation_dicts["area"][i])
        areas = torch.as_tensor(areas, dtype=torch.float32)
        iscrowd = torch.zeros((num_objs,), dtype=torch.int64)

        target = dict()
        target["boxes"] = boxes
        target["labels"] = labels
        target["image_id"] = image_id
        target["area"] = areas
        target["iscrowd"] = iscrowd

        img = self._load_img(img_dict)

        if self.transform is not None:
            img, target = self.transform(img, target)

        return img, target

        Loads an instance given its index.

        :param index: The index of the instance to retrieve.

        :return: a (sample, target) tuple where the target is a
            torchvision-style annotation for object detection
            https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
        
avalanche/benchmarks/datasets/lvis_dataset/lvis_dataset.py