code: def create_clevr_distance_disk_folder(
      input_path: str, output_path: str
  ):
      """
      Transform the CLEVR_v1.0 dataset in folder 'input_path' to a classifcation dataset
      following the disk_folder format at 'output_path' where the goal is to estimate the
      distance of the closest object.
      """
      thresholds = np.array([8.0, 8.5, 9.0, 9.5, 10.0, 100.0])
      target_labels = [f"below_{threshold}" for threshold in thresholds]
  
      for split in ("train", "val"):
          print(f"Processing the {split} split...")
  
          # Read the scene description, holding all object information
          scenes_path = os.path.join(
              input_path, "scenes", f"CLEVR_{split}_scenes.json"
          )
          with open(scenes_path) as f:
              scenes = json.load(f)["scenes"]
  
          # Associate the images with their corresponding target
          image_paths = []
          image_labels = []
          for scene in tqdm(scenes):
              image_path = os.path.join(
                  input_path, "images", split, scene["image_filename"]
              )
              distance = min(
                  object["pixel_coords"][2]
                  for object in scene["objects"]
              )
              target_id = bisect.bisect_left(thresholds, distance)
              target = target_labels[target_id]
              image_paths.append(image_path)
              image_labels.append(target)
  
          # Save the these lists in the disk_filelist format
          os.makedirs(output_path, exist_ok=True)
          img_info_out_path = os.path.join(
              output_path, f"{split}_images.npy"
          )
          label_info_out_path = os.path.join(
              output_path, f"{split}_labels.npy"
          )
          np.save(img_info_out_path, np.array(image_paths))
          np.save(label_info_out_path, np.array(image_labels))
  
file_path: vissl/extra_scripts/datasets/create_clevr_dist_data_files.py
imports: import argparse
  import bisect
  import json
  import os
  import numpy
  from tqdm import tqdm
  from vissl.utils.download import download_and_extract_archive
label_desc: Use image node_id 3 for calling a global function with example usage: create_clevr_distance_disk_folder(input_path, output_path) without return types