code: def create_pascal_voc_xml(
      filename: str = None,
      years: str = "VOC2012",
      source_dict: dict = None,
      objects_list: list = None,
      im_shape: tuple = None,
      save_root: str = os.getcwd(),
      cover: bool = False,
  ):
      if not (filename and source_dict and objects_list and im_shape):
          return
  
      # 0--Parade/0_Parade_marchingband_1_849.jpg -> 0_Parade_marchingband_1_849.xml
      xml_name = filename.split(os.sep)[-1].split(".")[0] + ".xml"
      xml_full_path = os.path.join(save_root, xml_name)
      if os.path.exists(xml_full_path) and (cover is False):
          print(f"{xml_full_path} already exist, skip.")
          return
  
      xml_generator = XMLGenerator(xml_full_path)
  
      # xml root node
      node_root = xml_generator.create_append_node("annotation")
      xml_generator.create_text_node(
          node_name="folder", node_value=years, root_node=node_root
      )
      xml_generator.create_text_node(
          node_name="filename", node_value=filename, root_node=node_root
      )
  
      # source
      node_source = xml_generator.create_append_node(
          "source", root_node=node_root
      )
      xml_generator.create_text_node(
          node_name="database",
          node_value=source_dict["database"],
          root_node=node_source,
      )
      xml_generator.create_text_node(
          node_name="annotation",
          node_value=source_dict["annotation"],
          root_node=node_source,
      )
      xml_generator.create_text_node(
          node_name="image",
          node_value=source_dict["image"],
          root_node=node_source,
      )
  
      # size
      node_size = xml_generator.create_append_node(
          "size", root_node=node_root
      )
      xml_generator.create_text_node(
          node_name="height",
          node_value=str(im_shape[0]),
          root_node=node_size,
      )
      xml_generator.create_text_node(
          node_name="width",
          node_value=str(im_shape[1]),
          root_node=node_size,
      )
      xml_generator.create_text_node(
          node_name="depth",
          node_value=str(im_shape[2]),
          root_node=node_size,
      )
  
      # segmented
      xml_generator.create_text_node(
          node_name="segmented", node_value="0", root_node=node_root
      )
  
      # object
      for i, ob in enumerate(objects_list):
          xml_generator.create_object_node(
              info_dict=ob, root_node=node_root
          )
  
      # XML write
      xml_generator.save_xml()
  
file_path: deep-learning-for-image-processing/others_project/trans_widerface_to_xml/create_xml.py
imports: import copy
  import os
  from xml.dom import minidom
label_desc: Use image node_id 1 for calling a global function with example usage: create_pascal_voc_xml(filename, years, source_dict, objects_list, im_shape, save_root, cover) without return types