code: def create_object_detection_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)
      num_class = int(args.num_class)
      grid_size = int(args.grid_size)
      shuffle = args.shuffle == "true"
      num_anchor = int(args.num_anchor)
  
      if width % grid_size != 0:
          logger.log(99, 'width" must be divisible by grid_size.')
          return
      if height % grid_size != 0:
          logger.log(99, "height must be divisible by grid_size.")
          return
  
      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...")
  
      def create_file_list(dir=""):
          result = []
          items = os.listdir(os.path.join(source_dir, dir))
          for item in items:
              if os.path.isdir(os.path.join(source_dir, dir, item)):
                  result.extend(
                      create_file_list(os.path.join(dir, item))
                  )
              elif re.search(
                  "\.(bmp|jpg|jpeg|png|gif|tif|tiff)",
                  os.path.splitext(item)[1],
                  re.IGNORECASE,
              ):
                  result.append(os.path.join(dir, item))
          return result
  
      file_list = create_file_list()
  
      if len(file_list) == 0:
          logger.critical(
              "No image file found in the subdirectory of the input directory."
          )
          return False
  
      # calc anchor
      logger.log(99, "Calculating anchors...")
      anchors = get_anchors(source_dir, file_list, num_anchor)
  
      # create output data
      logger.log(99, "Creating output images...")
      process_args = [
          (
              data,
              source_dir,
              dest_dir,
              width,
              height,
              mode,
              ch,
              num_class,
              grid_size,
              anchors,
          )
          for data in file_list
      ]
      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()
  
      file_list = [
          os.path.join(".", "data", file) for file in file_list
      ]
      file_list = [
          file
          for file in file_list
          if os.path.exists(
              os.path.join(dest_dir, os.path.splitext(file)[0] + ".png")
          )
      ]
      if len(file_list) == 0:
          logger.critical("No image and label file created correctly.")
          return False
  
      logger.log(99, "Creating CSV files...")
      if shuffle:
          import random
  
          random.shuffle(file_list)
  
      csv_data_num = [(len(file_list) * (100 - test_data_ratio)) // 100]
      csv_data_num.append(len(file_list) - 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:
              file_list_2 = file_list[data_head : data_head + data_num]
              data_head += data_num
  
              with open(csv_file_name, "w") as f:
                  writer = csv.writer(f, lineterminator="\n")
                  writer.writerow(["x:image", "y:label", "r:region"])
                  for file in file_list_2:
                      base_file_name = os.path.splitext(file)[0]
                      writer.writerow(
                          [
                              file,
                              os.path.splitext(file)[0] + "_label.csv",
                              os.path.splitext(file)[0] + "_region.csv",
                          ]
                      )
  
      logger.log(99, "Dataset was successfully created.")
      return True
  
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 4 for calling a global function with example usage: create_object_detection_dataset_command(args) and returns: True, False, result, False, False