'Encodes a box collection with respect to an anchor collection.
Args:
boxes: BoxList holding N boxes to be encoded.
anchors: BoxList of anchors.
Returns:
a tensor representing N anchor-encoded boxes of the format
[ty, tx, tl].'

def _encode(self, boxes, anchors):

    (ycenter_a, xcenter_a, ha, wa) = anchors.get_center_coordinates_and_sizes()
    la = tf.sqrt((ha * wa))
    (ycenter, xcenter, h, w) = boxes.get_center_coordinates_and_sizes()
    l = tf.sqrt((h * w))
    la += EPSILON
    l += EPSILON
    tx = ((xcenter - xcenter_a) / la)
    ty = ((ycenter - ycenter_a) / la)
    tl = tf.log((l / la))
    if self._scale_factors:
        ty *= self._scale_factors[0]
        tx *= self._scale_factors[1]
        tl *= self._scale_factors[2]
    return tf.transpose(tf.stack([ty, tx, tl]))
