code: def paste_masks_in_image(masks, boxes, img_shape, padding=1):
      # type: (Tensor, Tensor, Tuple[int, int], int) -> Tensor
  
      # pytorch官方说对mask进行expand能够略微提升mAP
      # refer to: https://github.com/pytorch/vision/issues/5845
      masks, scale = expand_masks(masks, padding=padding)
      boxes = expand_boxes(boxes, scale).to(dtype=torch.int64)
      im_h, im_w = img_shape
  
      if torchvision._is_tracing():
          return _onnx_paste_mask_in_image_loop(
              masks,
              boxes,
              torch.scalar_tensor(im_h, dtype=torch.int64),
              torch.scalar_tensor(im_w, dtype=torch.int64),
          )[:, None]
      res = [
          paste_mask_in_image(m[0], b, im_h, im_w)
          for m, b in zip(masks, boxes)
      ]
      if len(res) > 0:
          ret = torch.stack(res, dim=0)[:, None]  # [num_obj, 1, H, W]
      else:
          ret = masks.new_empty((0, 1, im_h, im_w))
      return ret
  
imports: import math
  from typing import List, Tuple, Dict, Optional
  import torch
  from torch import nn, Tensor
  import torch.nn.functional
  import torchvision
  from .image_list import ImageList
label_desc: Use image node_id 11 for calling a global function with example usage: paste_masks_in_image(masks, boxes, img_shape, padding) and returns: ret, _onnx_paste_mask_in_image_loop