code: def get_image(roidb, scale=False):
      """
      preprocess image and return processed roidb
      :param roidb: a list of roidb
      :return: list of img as in mxnet format
      roidb add new item['im_info']
      0 --- x (width, second dim of im)
      |
      y (height, first dim of im)
      """
      num_images = len(roidb)
      processed_ims = []
      processed_roidb = []
      for i in range(num_images):
          roi_rec = roidb[i]
          if "stream" in roi_rec:
              im = cv2.imdecode(roi_rec["stream"], cv2.IMREAD_COLOR)
          else:
              assert os.path.exists(
                  roi_rec["image"]
              ), "{} does not exist".format(roi_rec["image"])
              im = cv2.imread(roi_rec["image"])
          if roidb[i]["flipped"]:
              im = im[:, ::-1, :]
          new_rec = roi_rec.copy()
          if scale:
              scale_range = config.TRAIN.SCALE_RANGE
              im_scale = np.random.uniform(
                  scale_range[0], scale_range[1]
              )
              im = cv2.resize(
                  im,
                  None,
                  None,
                  fx=im_scale,
                  fy=im_scale,
                  interpolation=cv2.INTER_LINEAR,
              )
          elif not config.ORIGIN_SCALE:
              scale_ind = random.randrange(len(config.SCALES))
              target_size = config.SCALES[scale_ind][0]
              max_size = config.SCALES[scale_ind][1]
              im, im_scale = resize(
                  im, target_size, max_size, stride=config.IMAGE_STRIDE
              )
          else:
              im_scale = 1.0
          im_tensor = transform(
              im, config.PIXEL_MEANS, config.PIXEL_STDS
          )
          if "boxes_mask" in roi_rec:
              im = im.astype(np.float32)
              boxes_mask = roi_rec["boxes_mask"].copy() * im_scale
              boxes_mask = boxes_mask.astype(np.int)
              for j in range(boxes_mask.shape[0]):
                  m = boxes_mask[j]
                  im_tensor[:, :, m[1] : m[3], m[0] : m[2]] = 0.0
                  # print('find mask', m, file=sys.stderr)
          processed_ims.append(im_tensor)
          new_rec["boxes"] = roi_rec["boxes"].copy() * im_scale
          if config.TRAIN.IMAGE_ALIGN > 0:
              if (
                  im_tensor.shape[2] % config.TRAIN.IMAGE_ALIGN != 0
                  or im_tensor.shape[3] % config.TRAIN.IMAGE_ALIGN != 0
              ):
                  new_height = (
                      math.ceil(
                          float(im_tensor.shape[2])
                          / config.TRAIN.IMAGE_ALIGN
                      )
                      * config.TRAIN.IMAGE_ALIGN
                  )
                  new_width = (
                      math.ceil(
                          float(im_tensor.shape[3])
                          / config.TRAIN.IMAGE_ALIGN
                      )
                      * config.TRAIN.IMAGE_ALIGN
                  )
                  new_im_tensor = np.zeros(
                      (1, 3, int(new_height), int(new_width))
                  )
                  new_im_tensor[
                      :,
                      :,
                      0 : im_tensor.shape[2],
                      0 : im_tensor.shape[3],
                  ] = im_tensor
                  print(
                      im_tensor.shape,
                      new_im_tensor.shape,
                      file=sys.stderr,
                  )
                  im_tensor = new_im_tensor
          # print('boxes', new_rec['boxes'], file=sys.stderr)
          im_info = [im_tensor.shape[2], im_tensor.shape[3], im_scale]
          new_rec["im_info"] = im_info
          processed_roidb.append(new_rec)
      return processed_ims, processed_roidb
  
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 5 for calling a global function with example usage: get_image(roidb, scale) and returns: processed_ims,  processed_roidb