code: def generate_scale(im, target_shape, keep_ratio=True):
      """
      Args:
          im (np.ndarray): image (np.ndarray)
      Returns:
          im_scale_x: the resize ratio of X
          im_scale_y: the resize ratio of Y
      """
      origin_shape = im.shape[:2]
      if keep_ratio:
          im_size_min = np.min(origin_shape)
          im_size_max = np.max(origin_shape)
          target_size_min = np.min(target_shape)
          target_size_max = np.max(target_shape)
          im_scale = float(target_size_min) / float(im_size_min)
          if np.round(im_scale * im_size_max) > target_size_max:
              im_scale = float(target_size_max) / float(im_size_max)
          im_scale_x = im_scale
          im_scale_y = im_scale
      else:
          resize_h, resize_w = target_shape
          im_scale_y = resize_h / float(origin_shape[0])
          im_scale_x = resize_w / float(origin_shape[1])
      return im_scale_y, im_scale_x
  
imports: import os
  import argparse
  import time
  import sys
  import cv2
  import numpy
  import paddle
  from paddle.inference import Config
  from paddle.inference import create_predictor
  from ppdet.core.workspace import load_config, create
  from ppdet.metrics import COCOMetric
  from post_process import PPYOLOEPostProcess
label_desc: Use image node_id 2 for calling a global function with example usage: generate_scale(im, target_shape, keep_ratio) and returns: im_scale_y,  im_scale_x