'Computes encoded object locations and corresponding confidences.
Args:
image_features: A float tensor of shape [batch_size, height, width,
channels] containing features for a batch of images.
num_predictions_per_location: an integer representing the number of box
predictions to be made per spatial location in the feature map.
Returns:
A dictionary containing the following tensors.
box_encodings: A float tensor of shape [batch_size, num_anchors, 1,
code_size] representing the location of the objects, where
num_anchors = feat_height * feat_width * num_predictions_per_location
class_predictions_with_background: A float tensor of shape
[batch_size, num_anchors, num_classes + 1] representing the class
predictions for the proposals.'

def _predict(self, image_features, num_predictions_per_location):

    features_depth = static_shape.get_depth(image_features.get_shape())
    depth = max(min(features_depth, self._max_depth), self._min_depth)
    num_class_slots = (self.num_classes + 1)
    net = image_features
    with slim.arg_scope(self._conv_hyperparams):
        with slim.arg_scope([slim.dropout], is_training=self._is_training):
            if ((depth > 0) and (self._num_layers_before_predictor > 0)):
                for i in range(self._num_layers_before_predictor):
                    net = slim.conv2d(net, depth, [1, 1], scope=('Conv2d_%d_1x1_%d' % (i, depth)))
            with slim.arg_scope([slim.conv2d], activation_fn=None, normalizer_fn=None, normalizer_params=None):
                box_encodings = slim.conv2d(net, (num_predictions_per_location * self._box_code_size), [self._kernel_size, self._kernel_size], scope='BoxEncodingPredictor')
                if self._use_dropout:
                    net = slim.dropout(net, keep_prob=self._dropout_keep_prob)
                class_predictions_with_background = slim.conv2d(net, (num_predictions_per_location * num_class_slots), [self._kernel_size, self._kernel_size], scope='ClassPredictor')
                if self._apply_sigmoid_to_scores:
                    class_predictions_with_background = tf.sigmoid(class_predictions_with_background)
    combined_feature_map_shape = shape_utils.combined_static_and_dynamic_shape(image_features)
    box_encodings = tf.reshape(box_encodings, tf.stack([combined_feature_map_shape[0], ((combined_feature_map_shape[1] * combined_feature_map_shape[2]) * num_predictions_per_location), 1, self._box_code_size]))
    class_predictions_with_background = tf.reshape(class_predictions_with_background, tf.stack([combined_feature_map_shape[0], ((combined_feature_map_shape[1] * combined_feature_map_shape[2]) * num_predictions_per_location), num_class_slots]))
    return {BOX_ENCODINGS: box_encodings, CLASS_PREDICTIONS_WITH_BACKGROUND: class_predictions_with_background}
