code: def build_file_list(args):
      if not os.path.exists(args.anno_root):
          raise ValueError(
              "Please download annotations and set anno_root variable."
          )
  
      dataset_name = "something-something-v2"
      with open(
          os.path.join(args.anno_root, "%s-labels.json" % dataset_name)
      ) as f:
          data = json.load(f)
      categories = []
      for i, (cat, idx) in enumerate(data.items()):
          assert i == int(idx)  # make sure the rank is right
          categories.append(cat)
  
      with open("category.txt", "w") as f:
          f.write("\n".join(categories))
  
      dict_categories = {}
      for i, category in enumerate(categories):
          dict_categories[category] = i
  
      files_input = [
          os.path.join(
              args.anno_root, "%s-validation.json" % dataset_name
          ),
          os.path.join(args.anno_root, "%s-train.json" % dataset_name),
          os.path.join(args.anno_root, "%s-test.json" % dataset_name),
      ]
      files_output = [
          os.path.join(args.anno_root, "val_videofolder.txt"),
          os.path.join(args.anno_root, "train_videofolder.txt"),
          os.path.join(args.anno_root, "test_videofolder.txt"),
      ]
      for filename_input, filename_output in zip(
          files_input, files_output
      ):
          with open(filename_input) as f:
              data = json.load(f)
          folders = []
          idx_categories = []
          for item in data:
              folders.append(item["id"])
              if "test" not in filename_input:
                  idx_categories.append(
                      dict_categories[
                          item["template"]
                          .replace("[", "")
                          .replace("]", "")
                      ]
                  )
              else:
                  idx_categories.append(0)
          output = []
          for i in range(len(folders)):
              curFolder = folders[i]
              curIDX = idx_categories[i]
              # counting the number of frames in each video folders
              dir_files = os.listdir(
                  os.path.join(args.frame_root, curFolder)
              )
              if len(dir_files) == 0:
                  print("video decoding fails at %s", (curFolder))
                  sys.exit()
              output.append(
                  "%s %d %d" % (curFolder, len(dir_files), curIDX)
              )
              print("%d/%d" % (i, len(folders)))
          with open(filename_output, "w") as f:
              f.write("\n".join(output))
  
file_path: gluon-cv/scripts/datasets/somethingsomethingv2.py
imports: import os
  import sys
  import threading
  import argparse
  import json
label_desc: Use image node_id 6 for calling a global function with example usage: build_file_list(args) without return types