code: def main(dataset_dir: str):
      yolo_dataset = os.path.join(
          os.path.dirname(dataset_dir),
          os.path.basename(f"{dataset_dir}-yolo"),
      )
      for dir in dirs:
          dir_path = os.path.join(yolo_dataset, dir)
          os.makedirs(dir_path, exist_ok=True)
  
          for sub_dir in sub_dirs:
              os.makedirs(
                  os.path.join(dir_path, sub_dir), exist_ok=True
              )
  
      train_anns = {}
      validation_anns = {}
  
      for dir in dirs:
          dir_path = os.path.join(dataset_dir, dir)
  
          images = [
              file
              for file in os.listdir(os.path.join(dir_path, "images"))
              if file.endswith(".png")
              or file.endswith(".jpg")
              or file.endswith(".jpeg")
          ]
  
          annotations = [
              file
              for file in os.listdir(
                  os.path.join(dir_path, "annotations")
              )
              if file.endswith(".xml")
          ]
  
          for image, annotation in zip(images, annotations):
              shutil.copy(
                  os.path.join(dataset_dir, dir, "images", image),
                  os.path.join(yolo_dataset, dir, "images", image),
              )
  
              ann_list = convert_annotation(
                  os.path.join(
                      dataset_dir, dir, "annotations", annotation
                  )
              )
              if dir == "train":
                  train_anns[annotation] = ann_list
              elif dir == "validation":
                  validation_anns[annotation] = ann_list
  
      all_classes = sorted(classes)
  
      for k, v in {
          "train": train_anns,
          "validation": validation_anns,
      }.items():
          for anns_k, anns_v in v.items():
              output_ann_path = os.path.join(
                  yolo_dataset,
                  k,
                  "annotations",
                  anns_k.replace(".xml", ".txt"),
              )
              anns_str = ""
              for ann in anns_v:
                  class_idx = all_classes.index(ann["class"])
                  bbox = [str(f) for f in ann["bbox"]]
                  anns_str += f"{class_idx} {' '.join(bbox)}\n"
  
              with open(output_ann_path, "w") as ann_writer:
                  ann_writer.write(anns_str)
  
          with open(
              os.path.join(
                  yolo_dataset, k, "annotations", "classes.txt"
              ),
              "w",
          ) as classes_writer:
              classes_writer.write("\n".join(all_classes))
  
file_path: ImageAI/scripts/pascal_voc_to_yolo.py
imports: import glob
  import os
  import argparse
  import pickle
  import xml.etree.ElementTree
  from os import listdir, getcwd
  from os.path import join
  import shutil
label_desc: Use image node_id 3 for calling a global function with example usage: main(dataset_dir) without return types