code: def __init__(
      self,
      main_dir,
      subset,
      version="v4",
      labels_filter=None,
      annotation_cache_dir=".",
      parent_label=None,
      **kwargs,
  ):
      if version == "challenge2018":
          metadata = "challenge2018"
      elif version == "v4":
          metadata = "2018_04"
      elif version == "v3":
          metadata = "2017_11"
      else:
          raise NotImplementedError(
              "There is currently no implementation for versions older than v3"
          )
  
      if version == "challenge2018":
          self.base_dir = os.path.join(main_dir, "images", "train")
      else:
          self.base_dir = os.path.join(main_dir, "images", subset)
  
      metadata_dir = os.path.join(main_dir, metadata)
      annotation_cache_json = os.path.join(
          annotation_cache_dir, subset + ".json"
      )
  
      self.hierarchy = load_hierarchy(metadata_dir, version=version)
      id_to_labels, cls_index = get_labels(
          metadata_dir, version=version
      )
  
      if os.path.exists(annotation_cache_json):
          with open(annotation_cache_json, "r") as f:
              self.annotations = json.loads(f.read())
      else:
          self.annotations = generate_images_annotations_json(
              main_dir, metadata_dir, subset, cls_index, version=version
          )
          json.dump(self.annotations, open(annotation_cache_json, "w"))
  
      if labels_filter is not None or parent_label is not None:
          self.id_to_labels, self.annotations = self.__filter_data(
              id_to_labels, cls_index, labels_filter, parent_label
          )
      else:
          self.id_to_labels = id_to_labels
  
      self.id_to_image_id = dict(
          [(i, k) for i, k in enumerate(self.annotations)]
      )
  
      super(OpenImagesGenerator, self).__init__(**kwargs)
  
imports: import csv
  import json
  import os
  import warnings
  import numpy
  from PIL import Image
  from .generator import Generator
  from ..utils.image import read_image_bgr
label_desc: Use image node_id 1 to create a new OpenImagesGenerator object from inherited base classes: Generator with example: obj = OpenImagesGenerator(main_dir, subset, version, labels_filter, annotation_cache_dir, parent_label)