code: def main():
      parser = argparse.ArgumentParser(
          description="Create COCO data files"
      )
      parser.add_argument(
          "--json_annotations_dir",
          type=str,
          default=None,
          help="Path for the json dataset annotations for various partitions",
      )
      parser.add_argument(
          "--output_dir",
          type=str,
          default=None,
          help="Output directory where images/label information will be written",
      )
      parser.add_argument(
          "--train_imgs_path",
          type=str,
          default=None,
          help="Path where training images (.jpg) for COCO2014 are stored",
      )
      parser.add_argument(
          "--val_imgs_path",
          type=str,
          default=None,
          help="Path where val images (.jpg) for COCO2014 are stored",
      )
      args = parser.parse_args()
  
      # given the data directory for the partitions train, val, minival and
      # valminusminival, we will write numpy files for each partition.
      partitions = ["val", "train", "minival", "valminusminival"]
      for partition in partitions:
          annotation_file = f"{args.json_annotations_dir}/instances_{partition}2014.json"
          logger.info(
              "========Preparing {} data files========".format(
                  partition
              )
          )
          imgs_info, lbls_info = get_imgs_labels_info(
              partition, annotation_file, args
          )
          img_info_out_path = (
              f"{args.output_dir}/{partition}_images.npy"
          )
          label_info_out_path = (
              f"{args.output_dir}/{partition}_labels.npy"
          )
          logger.info(
              "=================SAVING DATA files======================="
          )
          logger.info(
              f"partition: {partition} saving img_paths to: {img_info_out_path}"
          )
          logger.info(
              f"partition: {partition} saving lbls_paths: {label_info_out_path}"
          )
          logger.info(
              f"partition: {partition} imgs: {np.array(imgs_info).shape}"
          )
          np.save(img_info_out_path, np.array(imgs_info))
          np.save(label_info_out_path, np.array(lbls_info))
      logger.info("DONE!")
  
file_path: vissl/extra_scripts/datasets/create_coco_data_files.py
imports: import argparse
  import json
  import logging
  import sys
  import numpy
  from iopath.common.file_io import g_pathmgr
  from pycocotools.coco import COCO
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types