def METHOD_NAME(self, masks, boxes):
    boxes = boxes.convert("xyxy")
    im_w, im_h = boxes.size
    res = [
        paste_mask_in_image(mask[0], box, im_h, im_w, self.threshold, self.padding)
        for mask, box in zip(masks, boxes.bbox)
    ]
    if len(res) > 0:
        res = torch.stack(res, dim=0)[:, None]
    else:
        res = masks.new_empty((0, 1, masks.shape[-2], masks.shape[-1]))
    return res