code: def main():
      parser = argparse.ArgumentParser(
          description="Create the ImageNet/Places205 data information file"
      )
      parser.add_argument(
          "--data_source_dir",
          type=str,
          default=None,
          help="Path to data directory containing train and val images",
      )
      parser.add_argument(
          "--output_dir",
          type=str,
          default=None,
          help="Output directory where images/label information will be written",
      )
      parser.add_argument(
          "--generate_json",
          action="store_true",
          help="Whether to json files for partitions train/test/val",
      )
      args = parser.parse_args()
  
      # given the data directory for the partitions train/val both. We will write
      # numpy file since pickle files are prone to failures across different
      # python version
      partitions = ["train", "val"]
      for partition in partitions:
          logger.info(
              f"========Preparing {partition} data files========"
          )
          imgs_info, lbls_info, output_dict = get_images_labels_info(
              partition, 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))
          if args.generate_json:
              json_out_path = (
                  f"{args.output_dir}/{partition}_targets.json"
              )
              import json
  
              with g_pathmgr.open(json_out_path, "w") as fp:
                  json.dump(output_dict, fp)
              logger.info("Saved Json to: {}".format(json_out_path))
      logger.info("DONE!")
  
file_path: vissl/extra_scripts/datasets/create_imagenet_data_files.py
imports: import argparse
  import logging
  import os
  import sys
  import numpy
  from iopath.common.file_io import g_pathmgr
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types