def _compute_box_scale_and_offset_loss(self, input_height, input_width, scale_predictions, offset_predictions):
    'Computes the scale loss of the object detection task.\n\n    Args:\n      input_height: An integer scalar tensor representing input image height.\n      input_width: An integer scalar tensor representing input image width.\n      scale_predictions: A list of float tensors of shape [batch_size,\n        out_height, out_width, 2] representing the prediction heads of the model\n        for object scale (i.e height and width).\n      offset_predictions: A list of float tensors of shape [batch_size,\n        out_height, out_width, 2] representing the prediction heads of the model\n        for object offset.\n\n    Returns:\n      A tuple of two losses:\n        scale_loss: A float scalar tensor representing the object height/width\n          loss normalized by total number of boxes.\n        offset_loss: A float scalar tensor representing the object offset loss\n          normalized by total number of boxes\n    '
    gt_boxes_list = self.groundtruth_lists(fields.BoxListFields.boxes)
    gt_weights_list = self.groundtruth_lists(fields.BoxListFields.weights)
    num_boxes = _to_float32(get_num_instances_from_weights(gt_weights_list))
    num_predictions = float(len(scale_predictions))
    assigner = self._target_assigner_dict[DETECTION_TASK]
    (batch_indices, batch_height_width_targets, batch_offset_targets, batch_weights) = assigner.assign_size_and_offset_targets(height=input_height, width=input_width, gt_boxes_list=gt_boxes_list, gt_weights_list=gt_weights_list)
    batch_weights = tf.expand_dims(batch_weights, (- 1))
    scale_loss = 0
    offset_loss = 0
    localization_loss_fn = self._od_params.localization_loss
    for (scale_pred, offset_pred) in zip(scale_predictions, offset_predictions):
        scale_pred = cn_assigner.get_batch_predictions_from_indices(scale_pred, batch_indices)
        scale_loss += localization_loss_fn(scale_pred, batch_height_width_targets, weights=batch_weights)
        offset_pred = cn_assigner.get_batch_predictions_from_indices(offset_pred, batch_indices)
        offset_loss += localization_loss_fn(offset_pred, batch_offset_targets, weights=batch_weights)
    scale_loss = (tf.reduce_sum(scale_loss) / (num_predictions * num_boxes))
    offset_loss = (tf.reduce_sum(offset_loss) / (num_predictions * num_boxes))
    return (scale_loss, offset_loss)
Computes the scale loss of the object detection task.

Args:
  input_height: An integer scalar tensor representing input image height.
  input_width: An integer scalar tensor representing input image width.
  scale_predictions: A list of float tensors of shape [batch_size,
    out_height, out_width, 2] representing the prediction heads of the model
    for object scale (i.e height and width).
  offset_predictions: A list of float tensors of shape [batch_size,
    out_height, out_width, 2] representing the prediction heads of the model
    for object offset.

Returns:
  A tuple of two losses:
    scale_loss: A float scalar tensor representing the object height/width
      loss normalized by total number of boxes.
    offset_loss: A float scalar tensor representing the object offset loss
      normalized by total number of boxes
def _compute_box_scale_and_offset_loss(self, input_height, input_width, scale_predictions, offset_predictions):
    'Computes the scale loss of the object detection task.\n\n    Args:\n      input_height: An integer scalar tensor representing input image height.\n      input_width: An integer scalar tensor representing input image width.\n      scale_predictions: A list of float tensors of shape [batch_size,\n        out_height, out_width, 2] representing the prediction heads of the model\n        for object scale (i.e height and width).\n      offset_predictions: A list of float tensors of shape [batch_size,\n        out_height, out_width, 2] representing the prediction heads of the model\n        for object offset.\n\n    Returns:\n      A tuple of two losses:\n        scale_loss: A float scalar tensor representing the object height/width\n          loss normalized by total number of boxes.\n        offset_loss: A float scalar tensor representing the object offset loss\n          normalized by total number of boxes\n    '
    gt_boxes_list = self.groundtruth_lists(fields.BoxListFields.boxes)
    gt_weights_list = self.groundtruth_lists(fields.BoxListFields.weights)
    num_boxes = _to_float32(get_num_instances_from_weights(gt_weights_list))
    num_predictions = float(len(scale_predictions))
    assigner = self._target_assigner_dict[DETECTION_TASK]
    (batch_indices, batch_height_width_targets, batch_offset_targets, batch_weights) = assigner.assign_size_and_offset_targets(height=input_height, width=input_width, gt_boxes_list=gt_boxes_list, gt_weights_list=gt_weights_list)
    batch_weights = tf.expand_dims(batch_weights, (- 1))
    scale_loss = 0
    offset_loss = 0
    localization_loss_fn = self._od_params.localization_loss
    for (scale_pred, offset_pred) in zip(scale_predictions, offset_predictions):
        scale_pred = cn_assigner.get_batch_predictions_from_indices(scale_pred, batch_indices)
        scale_loss += localization_loss_fn(scale_pred, batch_height_width_targets, weights=batch_weights)
        offset_pred = cn_assigner.get_batch_predictions_from_indices(offset_pred, batch_indices)
        offset_loss += localization_loss_fn(offset_pred, batch_offset_targets, weights=batch_weights)
    scale_loss = (tf.reduce_sum(scale_loss) / (num_predictions * num_boxes))
    offset_loss = (tf.reduce_sum(offset_loss) / (num_predictions * num_boxes))
    return (scale_loss, offset_loss)