code: def get_ratio_infos(jsonfile, out_img, eval_size, small_stride):
      coco = COCO(annotation_file=jsonfile)
      allannjson = json.load(open(jsonfile, "r"))
      be_im_id = allannjson["annotations"][0]["image_id"]
      be_im_w = []
      be_im_h = []
      ratio_w = []
      ratio_h = []
      im_wid, im_hei = [], []
      for ann in tqdm(allannjson["annotations"]):
          if ann["iscrowd"]:
              continue
          x0, y0, w, h = ann["bbox"][:]
          if be_im_id == ann["image_id"]:
              be_im_w.append(w)
              be_im_h.append(h)
          else:
              im_w = coco.imgs[be_im_id]["width"]
              im_h = coco.imgs[be_im_id]["height"]
              im_wid.append(im_w)
              im_hei.append(im_h)
              im_m_w = np.mean(be_im_w)
              im_m_h = np.mean(be_im_h)
              dis_w = im_m_w / im_w
              dis_h = im_m_h / im_h
              ratio_w.append(dis_w)
              ratio_h.append(dis_h)
              be_im_id = ann["image_id"]
              be_im_w = [w]
              be_im_h = [h]
  
      im_w = coco.imgs[be_im_id]["width"]
      im_h = coco.imgs[be_im_id]["height"]
      im_wid.append(im_w)
      im_hei.append(im_h)
      all_im_m_w = np.mean(im_wid)
      all_im_m_h = np.mean(im_hei)
  
      im_m_w = np.mean(be_im_w)
      im_m_h = np.mean(be_im_h)
      dis_w = im_m_w / im_w
      dis_h = im_m_h / im_h
      ratio_w.append(dis_w)
      ratio_h.append(dis_h)
      mid_w = median(ratio_w)
      mid_h = median(ratio_h)
  
      reg_ratio = []
      ratio_all = ratio_h + ratio_w
      for r in ratio_all:
          if r < 0.2:
              reg_ratio.append(r)
          elif r < 0.4:
              reg_ratio.append(r / 2)
          else:
              reg_ratio.append(r / 4)
      reg_ratio = sorted(reg_ratio)
      max_ratio = reg_ratio[int(0.95 * len(reg_ratio))]
      reg_max = round(max_ratio * eval_size / small_stride)
  
      ratio_w = [i * 1000 for i in ratio_w]
      ratio_h = [i * 1000 for i in ratio_h]
      print(f"Suggested reg_range[1] is {reg_max+1}")
      print(f"Mean of all img_w is {all_im_m_w}")
      print(f"Mean of all img_h is {all_im_m_h}")
      print(f"Median of ratio_w is {mid_w}")
      print(f"Median of ratio_h is {mid_h}")
      print("all_img with box: ", len(ratio_h))
      print("all_ann: ", len(allannjson["annotations"]))
      draw_distribution(ratio_w, ratio_h, out_img)
  
file_path: PaddleSeg/contrib/QualityInspector/tools/det/box_distribution.py
imports: import argparse
  import json
  import matplotlib.pyplot
  import numpy
  from tqdm import tqdm
  from pycocotools.coco import COCO
label_desc: Use image node_id 3 for calling a global function with example usage: get_ratio_infos(jsonfile, out_img, eval_size, small_stride) without return types