def _load_metadata(self):
        """Main method to load the CUB200 metadata"""

        cub_dir = self.root / "CUB_200_2011"
        images_list: Dict[int, List] = OrderedDict()

        with open(str(cub_dir / "train_test_split.txt")) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=" ")
            for row in csv_reader:
                img_id = int(row[0])
                is_train_instance = int(row[1]) == 1
                if is_train_instance == self.train:
                    images_list[img_id] = []

        with open(str(cub_dir / "images.txt")) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=" ")
            for row in csv_reader:
                img_id = int(row[0])
                if img_id in images_list:
                    images_list[img_id].append(row[1])

        with open(str(cub_dir / "image_class_labels.txt")) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=" ")
            for row in csv_reader:
                img_id = int(row[0])
                if img_id in images_list:
                    # CUB starts counting classes from 1 ...
                    images_list[img_id].append(int(row[1]) - 1)

        with open(str(cub_dir / "bounding_boxes.txt")) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=" ")
            for row in csv_reader:
                img_id = int(row[0])
                if img_id in images_list:
                    box_cub = [int(float(x)) for x in row[1:]]
                    box_avl = [box_cub[1], box_cub[0], box_cub[3], box_cub[2]]
                    # PathsDataset accepts (top, left, height, width)
                    images_list[img_id].append(box_avl)

        images_tuples = []
        for _, img_tuple in images_list.items():
            images_tuples.append(tuple(img_tuple))
        self._images = images_tuples  # type: ignore

        # Integrity check
        for row_check in self._images:
            filepath = self.root / CUB200.images_folder / row_check[0]
            if not filepath.is_file():
                if self.verbose:
                    print("[CUB200] Error checking integrity of:", filepath)
                return False

        return True
Main method to load the CUB200 metadata
avalanche/benchmarks/datasets/cub200/cub200.py