code: def paste_mask(masks, boxes, im_h, im_w, assign_on_cpu=False):
      """
      Paste the mask prediction to the original image.
      """
      x0_int, y0_int = 0, 0
      x1_int, y1_int = im_w, im_h
      x0, y0, x1, y1 = paddle.split(boxes, 4, axis=1)
      N = masks.shape[0]
      img_y = paddle.arange(y0_int, y1_int) + 0.5
      img_x = paddle.arange(x0_int, x1_int) + 0.5
  
      img_y = (img_y - y0) / (y1 - y0) * 2 - 1
      img_x = (img_x - x0) / (x1 - x0) * 2 - 1
      # img_x, img_y have shapes (N, w), (N, h)
  
      if assign_on_cpu:
          paddle.set_device("cpu")
      gx = img_x[:, None, :].expand(
          [N, paddle.shape(img_y)[1], paddle.shape(img_x)[1]]
      )
      gy = img_y[:, :, None].expand(
          [N, paddle.shape(img_y)[1], paddle.shape(img_x)[1]]
      )
      grid = paddle.stack([gx, gy], axis=3)
      img_masks = F.grid_sample(masks, grid, align_corners=False)
      return img_masks[:, 0]
  
imports: import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register
  from ppdet.modeling.bbox_utils import nonempty_bbox
  from .transformers import bbox_cxcywh_to_xyxy
label_desc: Use image node_id 1 for calling a global function with example usage: paste_mask(masks, boxes, im_h, im_w, assign_on_cpu) and returns: img_masks