'Compute loss function.
Args:
prediction_tensor: A float tensor of shape [batch_size, num_anchors, 4]
representing the decoded predicted boxes
target_tensor: A float tensor of shape [batch_size, num_anchors, 4]
representing the decoded target boxes
weights: a float tensor of shape [batch_size, num_anchors]
Returns:
loss: a (scalar) tensor representing the value of the loss function'

def _compute_loss(self, prediction_tensor, target_tensor, weights):

    predicted_boxes = box_list.BoxList(tf.reshape(prediction_tensor, [(-1), 4]))
    target_boxes = box_list.BoxList(tf.reshape(target_tensor, [(-1), 4]))
    per_anchor_iou_loss = (1.0 - box_list_ops.matched_iou(predicted_boxes, target_boxes))
    return tf.reduce_sum((tf.reshape(weights, [(-1)]) * per_anchor_iou_loss))
