    def box_transform(self, boxes, deltas):
        """
        The box-to-box transform defined in R-CNN. The transformation is parameterized by 4 deltas: (dx, dy, dw, dh). The transformation scales the box’s width and height by exp(dw), exp(dh) and shifts a box’s center by the offset (dx * width, dy * height).
        """
        const_0_5 = 0.5

        (delta_x, delta_y, delta_w, delta_h) = self.apply_weight(deltas)

        boxes_r = ops.reshape()(boxes, [self.num_rois, 4])
        (anchor_x1, anchor_y1, anchor_x2, anchor_y2) = ops.split()(boxes_r, 1, dim=1)
        widths = ops.reshape()(anchor_x2 - anchor_x1, [self.num_rois, 1])
        heights = ops.reshape()(anchor_y2 - anchor_y1, [self.num_rois, 1])

        width_mid = widths * const_0_5
        height_mid = heights * const_0_5
        ctr_x = anchor_x1 + width_mid
        ctr_y = anchor_y1 + height_mid

        pred_ctr_x = (delta_x * widths) + ctr_x

        pred_ctr_y = (delta_y * heights) + ctr_y
        pred_w = ops.exp(delta_w) * widths
        pred_h = ops.exp(delta_h) * heights

        p_x1 = pred_ctr_x - (const_0_5 * pred_w)
        p_y1 = pred_ctr_y - (const_0_5 * pred_h)
        p_x2 = pred_ctr_x + (const_0_5 * pred_w)
        p_y2 = pred_ctr_y + (const_0_5 * pred_h)

        if self.clip_box:
            f_x1, f_y1, f_x2, f_y2 = self.box_clip(p_x1, p_y1, p_x2, p_y2)
            proposals = ops.concatenate()([f_x1, f_y1, f_x2, f_y2], dim=2)
        else:
            proposals = ops.concatenate()([p_x1, p_y1, p_x2, p_y2], dim=2)

        return proposals
The box-to-box transform defined in R-CNN. The transformation is parameterized by 4 deltas: (dx, dy, dw, dh). The transformation scales the box’s width and height by exp(dw), exp(dh) and shifts a box’s center by the offset (dx * width, dy * height).
examples/02_detectron2/modeling/roi_heads/fast_rcnn.py