code: def parse_kinetics_splits(args):
      level = args.level
      csv_reader = csv.reader(
          open(os.path.join(args.anno_dir, "kinetics_train.csv"))
      )
      # skip the first line
      next(csv_reader)
  
      def convert_label(s):
          return s.replace('"', "").replace(" ", "_")
  
      labels_sorted = sorted(
          set([convert_label(row[0]) for row in csv_reader])
      )
      class_mapping = {
          label: i for i, label in enumerate(labels_sorted)
      }
  
      def list2rec(x, test=False):
          if test:
              vid = "{}_{:06d}_{:06d}".format(
                  x[0], int(x[1]), int(x[2])
              )
              label = -1  # label unknown
              return vid, label
          else:
              vid = "{}_{:06d}_{:06d}".format(
                  x[1], int(x[2]), int(x[3])
              )
              if level == 2:
                  vid = "{}/{}".format(convert_label(x[0]), vid)
              else:
                  assert level == 1
              label = class_mapping[convert_label(x[0])]
              return vid, label
  
      csv_reader = csv.reader(
          open(os.path.join(args.anno_dir, "kinetics_train.csv"))
      )
      next(csv_reader)
      train_list = [list2rec(x) for x in csv_reader]
      csv_reader = csv.reader(
          open(os.path.join(args.anno_dir, "kinetics_val.csv"))
      )
      next(csv_reader)
      val_list = [list2rec(x) for x in csv_reader]
      csv_reader = csv.reader(
          open(os.path.join(args.anno_dir, "kinetics_test.csv"))
      )
      next(csv_reader)
      test_list = [list2rec(x, test=True) for x in csv_reader]
  
      return ((train_list, val_list, test_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 7 for calling a global function with example usage: parse_kinetics_splits(args) and returns: train_list,  val_list,  test_list, s, vid,  label, vid,  label