code: def _correct_boxes(dets, w, h, netw, neth, relative):
      new_w, new_h = (
          (netw, (h * netw) // w)
          if (netw / w < neth / h)
          else ((w * neth // h), neth)
      )
      for det in dets:
          b = det["bbox"]
          b = b._replace(
              x=(b.x - (netw - new_w) / 2 / netw) / (new_w / netw)
          )
          b = b._replace(
              y=(b.y - (neth - new_h) / 2 / neth) / (new_h / neth)
          )
          b = b._replace(w=b.w * netw / new_w)
          b = b._replace(h=b.h * neth / new_h)
          if not relative:
              b = b._replace(x=b.x * w)
              b = b._replace(w=b.w * w)
              b = b._replace(y=b.y * h)
              b = b._replace(h=b.h * h)
          det["bbox"] = b
      return dets
  
imports: from __future__ import division
  import math
  from collections import namedtuple
  from functools import cmp_to_key
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: _correct_boxes(dets, w, h, netw, neth, relative) and returns: dets