code: def mxnet_frame_preprocessing(
      image, base_size, ratio, mean, std, ctx
  ):
      """
      Parameters
      ----------
      image
      base_size
      ratio: aspect ratio
      mean
      std
      ctx
  
      Returns
      -------
  
      """
      image_tensor = mx.nd.array(image, ctx=ctx, dtype=np.uint8)
      float_image = (
          image_tensor.astype(np.float32) / 255.0
          - mean.reshape((1, 1, 3))
      ) / std.reshape((1, 1, 3))
  
      trans_image = float_image.transpose((2, 0, 1))
      out_w, out_h = int(base_size * ratio), int(base_size)
      in_h, in_w, _ = image.shape
      pad_w, pad_h = int(max(in_w, in_h * ratio)), int(
          max(in_h, in_w / ratio)
      )
      pb_w, pb_h = (pad_w - in_w) // 2, (pad_h - in_h) // 2
  
      # do padding
      padded_image = mx.nd.zeros((1, 3, pad_h, pad_w), ctx=ctx)
      padded_image[
          0, :, pb_h : pb_h + in_h, pb_w : pb_w + in_w
      ] = trans_image
  
      # do resizing
      resize_image = mx.nd.contrib.BilinearResize2D(
          padded_image, height=out_h, width=out_w
      )
  
      return resize_image, pad_w, pad_h, (pb_w, pb_h, pad_w, pad_h)
  
imports: import time
  import logging
  from contextlib import contextmanager
  import mxnet
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: mxnet_frame_preprocessing(image, base_size, ratio, mean, std, ctx) and returns: resize_image,  pad_w,  pad_h,  pb_w,  pb_h,  pad_w,  pad_h