class_docstr: CLEVR dataset.
code: def _generate_examples(
      self, images_dir_path, question_file, scenes_description_file
  ):
      image_paths = sorted(
          [
              os.path.join(images_dir_path, filename)
              for filename in tf.io.gfile.listdir(images_dir_path)
          ]
      )
  
      with epath.Path(question_file).open() as f:
          questions_json = json.load(f)
      questions = collections.defaultdict(list)
      for q in questions_json["questions"]:
          questions[q["image_filename"]].append(
              {
                  "question": q["question"],
                  "answer": q.get(
                      "answer", ""
                  ),  # Test set do not have answer.
              }
          )
  
      if tf.io.gfile.exists(scenes_description_file):
          with epath.Path(scenes_description_file).open() as f:
              scenes_json = json.load(f)
      else:
          # if annotation file does not exist, we create empty annotations
          scenes_json = {"scenes": [{"objects": []}] * len(image_paths)}
  
      attrs = [
          "color",
          "material",
          "shape",
          "size",
          "rotation",
          "pixel_coords",
          "3d_coords",
      ]
      for image_path, scene in zip(image_paths, scenes_json["scenes"]):
          objects = scene["objects"]
          fname = os.path.basename(image_path)
          record = {
              "image": image_path,
              "file_name": fname,
              "question_answer": questions[fname],
              "objects": [
                  {attr: obj[attr] for attr in attrs} for obj in objects
              ],  # pylint: disable=g-complex-comprehension
          }
          yield fname, record
  
file_path: datasets/tensorflow_datasets/datasets/clevr/clevr_dataset_builder.py
imports: import collections
  import json
  import os
  from etils import epath
  import numpy
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Builder obj's underlying member method code with example usage: obj._generate_examples(images_dir_path, question_file, scenes_description_file) without return types