code: def create_image_classification_dataset_command(args):
      # settings
      source_dir = args.sourcedir
      dest_dir = args.outdir
      width = int(args.width)
      height = int(args.height)
      mode = args.mode
      ch = int(args.channel)
      shuffle = args.shuffle == "true"
  
      dest_csv_file_name = [os.path.join(args.outdir, args.file1)]
      if args.file2:
          dest_csv_file_name.append(
              os.path.join(args.outdir, args.file2)
          )
      test_data_ratio = int(args.ratio2) if args.ratio2 else 0
  
      if args.sourcedir == args.outdir:
          logger.critical(
              "Input directory and output directory are same."
          )
          return False
  
      # create file list
      logger.log(99, "Creating file list...")
      dirs = os.listdir(args.sourcedir)
      dirs = [
          d
          for d in dirs
          if os.path.isdir(os.path.join(args.sourcedir, d))
      ]
      dirs.sort()
      if len(dirs) == 0:
          logger.critical(
              "Subdirectory not found in the input directory."
          )
          return False
      # print(dirs)
  
      labels = []
      label_index = -1
      csv_data = []
      pbar = tqdm.tqdm(total=100, unit="%")
      last = 0
      for i, dir in enumerate(dirs):
          # print(dir)
          full_path = os.path.join(args.sourcedir, dir)
          files = os.listdir(full_path)
          files = [
              f
              for f in files
              if os.path.isfile(os.path.join(full_path, f))
          ]
          files.sort()
          found = False
          for i2, file in enumerate(files):
              file_name = os.path.join(full_path, file)
              if re.search(
                  "\.(bmp|jpg|jpeg|png|gif|tif|tiff)",
                  os.path.splitext(file_name)[1],
                  re.IGNORECASE,
              ):
                  if not found:
                      labels.append(dir)
                      label_index += 1
                      found = True
                  csv_data.append(
                      [os.path.join(".", dir, file), label_index]
                  )
              current = round(
                  100
                  * (
                      float(i) / len(dirs)
                      + float(i2) / (len(dirs) * len(files))
                  )
              )
              if last < current:
                  pbar.update(current - last)
                  last = current
      pbar.close()
      if len(csv_data) == 0:
          logger.critical(
              "No image file found in the subdirectory of the input directory."
          )
          return False
  
      # create output data
      logger.log(99, "Creating output images...")
      process_args = [
          (data[0], source_dir, dest_dir, width, height, mode, ch)
          for data in csv_data
      ]
      p = mp.Pool(mp.cpu_count())
      pbar = tqdm.tqdm(total=len(process_args))
      for _ in p.imap_unordered(convert_image, process_args):
          pbar.update()
      pbar.close()
  
      for data in csv_data:
          file_name = os.path.splitext(data[0])[0] + ".png"
          data[0] = (
              file_name
              if os.path.exists(os.path.join(dest_dir, file_name))
              else None
          )
      for data in csv_data[:]:
          if not data[0]:
              csv_data.remove(data)
  
      logger.log(99, "Creating CSV files...")
      if shuffle:
          import random
  
          random.shuffle(csv_data)
  
      csv_data_num = [(len(csv_data) * (100 - test_data_ratio)) // 100]
      csv_data_num.append(len(csv_data) - csv_data_num[0])
      data_head = 0
      for csv_file_name, data_num in zip(
          dest_csv_file_name, csv_data_num
      ):
          if data_num:
              csv_data_2 = csv_data[data_head : data_head + data_num]
              data_head += data_num
  
              csv_data_2.insert(0, ["x:image", "y:label"])
              with open(csv_file_name, "w") as f:
                  writer = csv.writer(f, lineterminator="\n")
                  writer.writerows(csv_data_2)
  
      logger.log(99, "Dataset was successfully created.")
      return True
  
file_path: nnabla/python/src/nnabla/utils/cli/create_image_classification_dataset.py
imports: import csv
  import multiprocessing
  import os
  import re
  import nnabla.logger
  import numpy
  import tqdm
  from nnabla.utils.image_utils import imsave, imread, imresize
label_desc: Use image node_id 2 for calling a global function with example usage: create_image_classification_dataset_command(args) and returns: True, False, False, False