code: def get_target_size_and_valid_box_ratios(
      anchor_range, box_ratio_p2, box_ratio_p98
  ):
      """get_scale_and_ratios"""
      (
          anchor_better_low,
          anchor_better_high,
      ) = anchor_range  # (60., 512.)
      anchor_center = np.sqrt(anchor_better_high * anchor_better_low)
  
      anchor_log_range = np.log10(anchor_better_high) - np.log10(
          anchor_better_low
      )
      box_ratio_log_range = np.log10(box_ratio_p98) - np.log10(
          box_ratio_p2
      )
      logger.info(
          "anchor_log_range:{}, box_ratio_log_range:{}".format(
              anchor_log_range, box_ratio_log_range
          )
      )
  
      box_cut_num = int(np.ceil(box_ratio_log_range / anchor_log_range))
      box_ratio_log_window = box_ratio_log_range / box_cut_num
      logger.info(
          "box_cut_num:{}, box_ratio_log_window:{}".format(
              box_cut_num, box_ratio_log_window
          )
      )
  
      image_target_sizes = []
      valid_ratios = []
      for i in range(box_cut_num):
          # # method1: align center
          # box_ratio_log_center = np.log10(p2) + 0.5 * box_ratio_log_window + i * box_ratio_log_window
          # box_ratio_center = np.power(10, box_ratio_log_center)
          # scale = anchor_center / box_ratio_center
          # method2: align left low
          box_ratio_low = np.power(
              10, np.log10(box_ratio_p2) + i * box_ratio_log_window
          )
          image_target_size = anchor_better_low / box_ratio_low
  
          image_target_sizes.append(int(image_target_size))
          valid_ratio = anchor_range / image_target_size
          valid_ratios.append(valid_ratio.tolist())
  
          logger.info("Box cut {}".format(i))
          logger.info("box_ratio_low: {}".format(box_ratio_low))
          logger.info("image_target_size: {}".format(image_target_size))
          logger.info("valid_ratio: {}".format(valid_ratio))
  
      return image_target_sizes, valid_ratios
  
file_path: PaddleDetection/tools/sniper_params_stats.py
imports: import sys
  import json
  import logging
  import numpy
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 3 for calling a global function with example usage: get_target_size_and_valid_box_ratios(anchor_range, box_ratio_p2, box_ratio_p98) and returns: image_target_sizes,  valid_ratios