code: def _write_voc_results_files(json_dataset, all_boxes, salt):
      filenames = []
      image_set_path = voc_info(json_dataset)["image_set_path"]
      assert os.path.exists(
          image_set_path
      ), "Image set path does not exist: {}".format(image_set_path)
      with open(image_set_path, "r") as f:
          image_index = [x.strip() for x in f.readlines()]
      # Sanity check that order of images in json dataset matches order in the
      # image set
      roidb = json_dataset.get_roidb()
      for i, entry in enumerate(roidb):
          index = os.path.splitext(os.path.split(entry["image"])[1])[0]
          assert index == image_index[i]
      for cls_ind, cls in enumerate(json_dataset.classes):
          if cls == "__background__":
              continue
          logger.info("Writing VOC results for: {}".format(cls))
          filename = _get_voc_results_file_template(
              json_dataset, salt
          ).format(cls)
          filenames.append(filename)
          assert len(all_boxes[cls_ind]) == len(image_index)
          with open(filename, "wt") as f:
              for im_ind, index in enumerate(image_index):
                  dets = all_boxes[cls_ind][im_ind]
                  if type(dets) == list:
                      assert (
                          len(dets) == 0
                      ), "dets should be numpy.ndarray or empty list"
                      continue
                  # the VOCdevkit expects 1-based indices
                  for k in range(dets.shape[0]):
                      f.write(
                          "{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}\n".format(
                              index,
                              dets[k, -1],
                              dets[k, 0] + 1,
                              dets[k, 1] + 1,
                              dets[k, 2] + 1,
                              dets[k, 3] + 1,
                          )
                      )
      return filenames
  
file_path: dense-pose/detectron/datasets/voc_dataset_evaluator.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import logging
  import numpy
  import os
  import shutil
  import uuid
  from detectron.core.config import cfg
  from detectron.datasets.dataset_catalog import get_devkit_dir
  from detectron.datasets.voc_eval import voc_eval
  from detectron.utils.io import save_object
label_desc: Use image node_id 2 for calling a global function with example usage: _write_voc_results_files(json_dataset, all_boxes, salt) and returns: filenames