code: def build_file_list(args):
      if args.level == 2:
  
          def key_func(x):
              return "/".join(x.split("/")[-2:])
  
      else:
  
          def key_func(x):
              return x.split("/")[-1]
  
      if args.format == "rawframes":
          frame_info = parse_directory(
              args.frame_path,
              key_func=key_func,
              rgb_prefix=args.rgb_prefix,
              flow_x_prefix=args.flow_x_prefix,
              flow_y_prefix=args.flow_y_prefix,
              level=args.level,
          )
      else:
          if args.level == 1:
              video_list = glob.glob(osp.join(args.frame_path, "*"))
          elif args.level == 2:
              video_list = glob.glob(
                  osp.join(args.frame_path, "*", "*")
              )
          frame_info = {
              osp.relpath(x.split(".")[0], args.frame_path): (x, -1, -1)
              for x in video_list
          }
  
      if args.dataset == "ucf101":
          split_tp = parse_ucf101_splits(args)
      elif args.dataset == "kinetics400":
          split_tp = parse_kinetics_splits(args)
      assert len(split_tp) == args.num_split
  
      out_path = args.out_list_path
      if len(split_tp) > 1:
          for i, split in enumerate(split_tp):
              lists = build_split_list(
                  split_tp[i], frame_info, shuffle=args.shuffle
              )
              filename = "{}_train_split_{}_{}.txt".format(
                  args.dataset, i + 1, args.format
              )
              with open(osp.join(out_path, filename), "w") as f:
                  f.writelines(lists[0][0])
              filename = "{}_val_split_{}_{}.txt".format(
                  args.dataset, i + 1, args.format
              )
              with open(osp.join(out_path, filename), "w") as f:
                  f.writelines(lists[0][1])
      else:
          lists = build_split_list(
              split_tp[0], frame_info, shuffle=args.shuffle
          )
          filename = "{}_{}_list_{}.txt".format(
              args.dataset, args.subset, args.format
          )
          if args.subset == "train":
              ind = 0
          elif args.subset == "val":
              ind = 1
          elif args.subset == "test":
              ind = 2
          with open(osp.join(out_path, filename), "w") as f:
              f.writelines(lists[0][ind])
  
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 10 for calling a global function with example usage: build_file_list(args) and returns: str, x