code: def generate_list(args):
      separator = args.separator
      dataset_root = args.dataset_root
      if abs(sum(args.split) - 1.0) > 1e-8:
          raise ValueError(
              "The sum of input params `--split` should be 1"
          )
  
      image_dir = os.path.join(dataset_root, args.images_dir_name)
      label_dir = os.path.join(dataset_root, args.labels_dir_name)
      image_files = get_files(
          image_dir, args.format[0], args.postfix[0]
      )
      label_files = get_files(
          label_dir, args.format[1], args.postfix[1]
      )
  
      if not image_files:
          warnings.warn("No files in {}".format(image_dir))
      if not label_files:
          warnings.warn("No files in {}".format(label_dir))
  
      num_images = len(image_files)
      num_label = len(label_files)
      if num_images != num_label:
          raise Exception(
              "Number of images = {}, number of labels = {}."
              "The number of images is not equal to number of labels, "
              "Please check your dataset!".format(num_images, num_label)
          )
  
      image_files = np.array(image_files)
      label_files = np.array(label_files)
      state = np.random.get_state()
      np.random.shuffle(image_files)
      np.random.set_state(state)
      np.random.shuffle(label_files)
  
      start = 0
      num_split = len(args.split)
      dataset_name = ["train", "val", "test"]
      for i in range(num_split):
          dataset_split = dataset_name[i]
          print("Creating {}.txt...".format(dataset_split))
          if args.split[i] > 1.0 or args.split[i] < 0:
              raise ValueError(
                  "{} dataset percentage should be 0~1.".format(
                      dataset_split
                  )
              )
  
          file_list = os.path.join(dataset_root, dataset_split + ".txt")
          with open(file_list, "w") as f:
              num = round(args.split[i] * num_images)
              end = start + num
              if i == num_split - 1:
                  end = num_images
              for item in range(start, end):
                  left = image_files[item].replace(dataset_root, "")
                  if left[0] == os.path.sep:
                      left = left.lstrip(os.path.sep)
  
                  try:
                      right = label_files[item].replace(
                          dataset_root, ""
                      )
                      if right[0] == os.path.sep:
                          right = right.lstrip(os.path.sep)
                      line = left + separator + right + "\n"
                  except:
                      line = left + "\n"
  
                  f.write(line)
                  print(line)
              start = end
  
file_path: PaddleSeg/tools/data/split_dataset_list.py
imports: import glob
  import os.path
  import argparse
  import warnings
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: generate_list(args) without return types