code: def resize(im, target_size, max_size, stride=0, min_size=0):
      """
      only resize input image to target size and return scale
      :param im: BGR image input by opencv
      :param target_size: one dimensional size (the short side)
      :param max_size: one dimensional max size (the long side)
      :param stride: if given, pad the image to designated stride
      :return:
      """
      im_shape = im.shape
      im_size_min = np.min(im_shape[0:2])
      im_size_max = np.max(im_shape[0:2])
      im_scale = float(target_size) / float(im_size_min)
      # prevent bigger axis from being more than max_size:
      if np.round(im_scale * im_size_max) > max_size:
          im_scale = float(max_size) / float(im_size_max)
          if (
              min_size > 0
              and np.round(im_scale * im_size_min) < min_size
          ):
              im_scale = float(min_size) / float(im_size_min)
      im = cv2.resize(
          im,
          None,
          None,
          fx=im_scale,
          fy=im_scale,
          interpolation=cv2.INTER_LINEAR,
      )
  
      if stride == 0:
          return im, im_scale
      else:
          # pad to product of stride
          im_height = int(np.ceil(im.shape[0] / float(stride)) * stride)
          im_width = int(np.ceil(im.shape[1] / float(stride)) * stride)
          im_channel = im.shape[2]
          padded_im = np.zeros((im_height, im_width, im_channel))
          padded_im[: im.shape[0], : im.shape[1], :] = im
          return padded_im, im_scale
  
imports: from __future__ import print_function
  import numpy
  import cv2
  import os
  import math
  import sys
  import random
  from ..config import config
label_desc: Use image node_id 12 for calling a global function with example usage: resize(im, target_size, max_size, stride, min_size) and returns: im,  im_scale, padded_im,  im_scale