class_docstr: Creates temporary XML files from masks for testing. Intended to be used
  as a context so that the XML files are automatically deleted when the
  execution goes out of scope.
  
  Example:
  
      >>> with BBFromMasks(root="/tmp/datasets/MVTec", datast_name="MVTec"):
      >>>     tests_case()
  
  Args:
      root (str, optional): Path to the dataset location. Defaults to "datasets/MVTec".
      dataset_name (str, optional): Name of the dataset to write to the XML file. Defaults to "MVTec".
docstr: Create the contents of the annotation file in Pascal VOC format.
  
  Args:
      boxes (List[List[List[np.int]]]): The calculated pox corners from the masks
      path_tree (List[str]): The entire filepath of the mask.png image split into a list
      image_size (Tuple[int, int]): Tuple of image size for writing into annotation
  
  Returns:
      ET.Element: annotation root element
docstr_tok: ["Create","the","contents","of","the","annotation","file","in","Pascal","VOC","format",".","Args",":","boxes","(","List","[","List","[","List","[","np.int","]","]","]",")",":","The","calculated","pox","corners","from","the","masks","path_tree","(","List","[","str","]",")",":","The","entire","filepath","of","the","mask.png","image","split","into","a","list","image_size","(","Tuple","[","int",",","int","]",")",":","Tuple","of","image","size","for","writing","into","annotation","Returns",":","ET.Element",":","annotation","root","element"]
code: def _create_xml_contents(
      self,
      boxes: List[List[List[np.int]]],
      path_tree: List[str],
      image_size: Tuple[int, int],
  ) -> ET.Element:
      """Create the contents of the annotation file in Pascal VOC format.
  
      Args:
          boxes (List[List[List[np.int]]]): The calculated pox corners from the masks
          path_tree (List[str]): The entire filepath of the mask.png image split into a list
          image_size (Tuple[int, int]): Tuple of image size for writing into annotation
  
      Returns:
          ET.Element: annotation root element
      """
      annotation = ET.Element("annotation")
      ET.SubElement(annotation, "folder").text = path_tree[-2]
      ET.SubElement(annotation, "filename").text = path_tree[-1]
  
      source = ET.SubElement(annotation, "source")
      ET.SubElement(source, "database").text = self.dataset_name
      ET.SubElement(source, "annotation").text = "PASCAL VOC"
  
      size = ET.SubElement(annotation, "size")
      ET.SubElement(size, "width").text = str(image_size[0])
      ET.SubElement(size, "height").text = str(image_size[1])
      ET.SubElement(size, "depth").text = "1"
      for box in boxes:
          object = ET.SubElement(annotation, "object")
          ET.SubElement(object, "name").text = "anomaly"
          ET.SubElement(object, "difficult").text = "1"
          bndbox = ET.SubElement(object, "bndbox")
          ET.SubElement(bndbox, "xmin").text = str(box[0][0])
          ET.SubElement(bndbox, "ymin").text = str(box[0][1])
          ET.SubElement(bndbox, "xmax").text = str(box[1][0])
          ET.SubElement(bndbox, "ymax").text = str(box[1][1])
  
      return annotation
  
file_path: anomalib/tests/helpers/detection.py
imports: import os
  import xml.etree.ElementTree
  from glob import glob
  from typing import List, Tuple
  import cv2
  import numpy
label_desc: Use image node_id 4 for calling the BBFromMasks obj's underlying member method code with example usage: obj._create_xml_contents(boxes, path_tree, image_size) and returns: annotation