code: def resize_aspect_ratio(img, square_size, interpolation, mag_ratio=1):
      height, width, channel = img.shape
  
      # magnify image size
      target_size = mag_ratio * max(height, width)
  
      # set original image size
      if target_size > square_size:
          target_size = square_size
  
      ratio = target_size / max(height, width)
  
      target_h, target_w = int(height * ratio), int(width * ratio)
  
      # NOTE
      valid_size_heatmap = (int(target_h / 2), int(target_w / 2))
  
      proc = cv2.resize(
          img, (target_w, target_h), interpolation=interpolation
      )
  
      # make canvas and paste image
      target_h32, target_w32 = target_h, target_w
      if target_h % 32 != 0:
          target_h32 = target_h + (32 - target_h % 32)
      if target_w % 32 != 0:
          target_w32 = target_w + (32 - target_w % 32)
      resized = np.zeros(
          (target_h32, target_w32, channel), dtype=np.float32
      )
      resized[0:target_h, 0:target_w, :] = proc
  
      # target_h, target_w = target_h32, target_w32
      # size_heatmap = (int(target_w/2), int(target_h/2))
  
      return resized, ratio, valid_size_heatmap
  
imports: import numpy
  import cv2
  from skimage import io
label_desc: Use image node_id 4 for calling a global function with example usage: resize_aspect_ratio(img, square_size, interpolation, mag_ratio) and returns: resized,  ratio,  valid_size_heatmap