def __filter_data(self, id_to_labels, cls_index, labels_filter=None, parent_label=None):
        """
        If you want to work with a subset of the labels just set a list with trainable labels
        :param labels_filter: Ex: labels_filter = ['Helmet', 'Hat', 'Analog television']
        :param parent_label: If parent_label is set this will bring you the parent label
        but also its children in the semantic hierarchy as defined in OID, ex: Animal
        hierarchical tree
        :return:
        """

        children_id_to_labels = {}

        if parent_label is None:
            # there is/are no other sublabel(s) other than the labels itself

            for label in labels_filter:
                for i, lb in id_to_labels.items():
                    if lb == label:
                        children_id_to_labels[i] = label
                        break
        else:
            parent_cls = None
            for i, lb in id_to_labels.items():
                if lb == parent_label:
                    parent_id = i
                    for c, index in cls_index.items():
                        if index == parent_id:
                            parent_cls = c
                    break

            if parent_cls is None:
                raise Exception('Couldnt find label {}'.format(parent_label))

            parent_tree = find_hierarchy_parent(self.hierarchy, parent_cls)

            if parent_tree is None:
                raise Exception('Couldnt find parent {} in the semantic hierarchical tree'.format(parent_label))

            children = load_hierarchy_children(parent_tree)

            for cls in children:
                index = cls_index[cls]
                label = id_to_labels[index]
                children_id_to_labels[index] = label

        id_map = dict([(ind, i) for i, ind in enumerate(children_id_to_labels.keys())])

        filtered_annotations = {}
        for k in self.annotations:
            img_ann = self.annotations[k]

            filtered_boxes = []
            for ann in img_ann['boxes']:
                cls_id = ann['cls_id']
                if cls_id in children_id_to_labels:
                    ann['cls_id'] = id_map[cls_id]
                    filtered_boxes.append(ann)

            if len(filtered_boxes) > 0:
                filtered_annotations[k] = {'w': img_ann['w'], 'h': img_ann['h'], 'boxes': filtered_boxes}

        children_id_to_labels = dict([(id_map[i], l) for (i, l) in children_id_to_labels.items()])

        return children_id_to_labels, filtered_annotations

        If you want to work with a subset of the labels just set a list with trainable labels
        :param labels_filter: Ex: labels_filter = ['Helmet', 'Hat', 'Analog television']
        :param parent_label: If parent_label is set this will bring you the parent label
        but also its children in the semantic hierarchy as defined in OID, ex: Animal
        hierarchical tree
        :return:
        
keras_retinanet/preprocessing/open_images.py