code: def rasterize_polygons_within_box(poly, box, resolution):
      w, h = box[2] - box[0], box[3] - box[1]
      polygons = [np.asarray(p, dtype=np.float64) for p in poly]
      for p in polygons:
          p[0::2] = p[0::2] - box[0]
          p[1::2] = p[1::2] - box[1]
  
      ratio_h = resolution / max(h, 0.1)
      ratio_w = resolution / max(w, 0.1)
  
      if ratio_h == ratio_w:
          for p in polygons:
              p *= ratio_h
      else:
          for p in polygons:
              p[0::2] *= ratio_w
              p[1::2] *= ratio_h
  
      # 3. Rasterize the polygons with coco api
      mask = polygons_to_mask(polygons, resolution, resolution)
      mask = paddle.to_tensor(mask, dtype="int32")
      return mask
  
file_path: PaddleDetection/ppdet/modeling/proposal_generator/target.py
imports: import numpy
  import paddle
  from ..bbox_utils import bbox2delta, bbox_overlaps
label_desc: Use image node_id 7 for calling a global function with example usage: rasterize_polygons_within_box(poly, box, resolution) and returns: mask