import tensorflow as tf


        targets_dx = (gt_boxes_urx - bboxes_urx)/(bboxes_width * variances[0])
        targets_dy = (gt_boxes_ury - bboxes_ury)/(bboxes_height * variances[0])

        targets_dw = tf.log(gt_boxes_width / bboxes_width) / variances[1]
        targets_dh = tf.log(gt_boxes_height / bboxes_height) / variances[1]

        targets = tf.concat(
            [targets_dx, targets_dy, targets_dw, targets_dh], axis=1)

        return targets


def decode(roi, deltas, variances=None):
    with tf.name_scope('BoundingBoxTransform/decode'):
        (roi_width, roi_height,
         roi_urx, roi_ury) = get_width_upright(roi)

        dx, dy, dw, dh = tf.split(deltas, 4, axis=1)

        if variances is None:
            variances = [1., 1.]

        pred_ur_x = dx * roi_width * variances[0] + roi_urx
        pred_ur_y = dy * roi_height * variances[0] + roi_ury
        pred_w = tf.exp(dw * variances[1]) * roi_width
        pred_h = tf.exp(dh * variances[1]) * roi_height

