code: def decode_video(args):
      if not osp.isdir(args.out_dir):
          print("Creating folder: {}".format(args.out_dir))
          os.makedirs(args.out_dir)
      if args.level == 2:
          classes = os.listdir(args.src_dir)
          for classname in classes:
              new_dir = osp.join(args.out_dir, classname)
              if not osp.isdir(new_dir):
                  print("Creating folder: {}".format(new_dir))
                  os.makedirs(new_dir)
  
      print("Reading videos from folder: ", args.src_dir)
      print("Extension of videos: ", args.ext)
      if args.level == 2:
          fullpath_list = glob.glob(args.src_dir + "/*/*." + args.ext)
          done_fullpath_list = glob.glob(args.out_dir + "/*/*")
      elif args.level == 1:
          fullpath_list = glob.glob(args.src_dir + "/*." + args.ext)
          done_fullpath_list = glob.glob(args.out_dir + "/*")
      print("Total number of videos found: ", len(fullpath_list))
      if args.resume:
          fullpath_list = set(fullpath_list).difference(
              set(done_fullpath_list)
          )
          fullpath_list = list(fullpath_list)
          print(
              "Resuming. number of videos to be done: ",
              len(fullpath_list),
          )
  
      if args.level == 2:
          vid_list = list(
              map(
                  lambda p: osp.join("/".join(p.split("/")[-2:])),
                  fullpath_list,
              )
          )
      elif args.level == 1:
          vid_list = list(
              map(lambda p: p.split("/")[-1], fullpath_list)
          )
  
      pool = Pool(args.num_worker)
      if args.flow_type == "tvl1":
          pool.map(
              run_optical_flow,
              zip(fullpath_list, vid_list, range(len(vid_list))),
          )
      elif args.flow_type == "warp_tvl1":
          pool.map(
              run_warp_optical_flow,
              zip(fullpath_list, vid_list, range(len(vid_list))),
          )
      else:
          pool.map(
              dump_frames,
              zip(fullpath_list, vid_list, range(len(vid_list))),
          )
  
imports: import argparse
  import sys
  import os
  import os.path
  import glob
  import fnmatch
  import random
  import zipfile
  from pipes import quote
  from multiprocessing import Pool, current_process
  import csv
label_desc: Use image node_id 5 for calling a global function with example usage: decode_video(args) without return types