code: def resize_contain(src, size, fill=0):
      """Resize the image to fit in the given area while keeping aspect ratio.
  
      If both the height and the width in `size` are larger than
      the height and the width of input image, the image is placed on
      the center with an appropriate padding to match `size`.
      Otherwise, the input image is scaled to fit in a canvas whose size
      is `size` while preserving aspect ratio.
  
      Parameters
      ----------
      src : mxnet.nd.NDArray
          The original image with HWC format.
      size : tuple
          Tuple of length 2 as (width, height).
      fill : int or float or array-like
          The value(s) for padded borders. If `fill` is numerical type, RGB channels
          will be padded with single value. Otherwise `fill` must have same length
          as image channels, which resulted in padding with per-channel values.
  
      Returns
      -------
      mxnet.nd.NDArray
          Augmented image.
      tuple
          Tuple of (offset_x, offset_y, scaled_x, scaled_y)
  
      """
      h, w, c = src.shape
      ow, oh = size
      scale_h = oh / h
      scale_w = ow / w
      scale = min(min(scale_h, scale_w), 1)
      scaled_x = int(w * scale)
      scaled_y = int(h * scale)
      if scale < 1:
          src = mx.image.imresize(src, scaled_x, scaled_y)
  
      off_y = (oh - scaled_y) // 2 if scaled_y < oh else 0
      off_x = (ow - scaled_x) // 2 if scaled_x < ow else 0
  
      # make canvas
      if isinstance(fill, numeric_types):
          dst = nd.full(shape=(oh, ow, c), val=fill, dtype=src.dtype)
      else:
          fill = nd.array(fill, ctx=src.context)
          if not c == fill.size:
              raise ValueError(
                  "Channel and fill size mismatch, {} vs {}".format(
                      c, fill.size
                  )
              )
          dst = nd.repeat(fill, repeats=oh * ow).reshape((oh, ow, c))
  
      dst[off_y : off_y + scaled_y, off_x : off_x + scaled_x, :] = src
      return dst, (off_x, off_y, scaled_x, scaled_y)
  
file_path: gluon-cv/gluoncv/data/transforms/image.py
imports: from __future__ import division
  import random
  import numpy
  import mxnet
  from mxnet import nd
  from mxnet.base import numeric_types
label_desc: Use image node_id 7 for calling a global function with example usage: resize_contain(src, size, fill) and returns: dst,  off_x,  off_y,  scaled_x,  scaled_y