'Samples a mini-batch of proposals to be sent to the box classifier.
Helper function for self._postprocess_rpn.
Args:
proposal_boxlist: A BoxList containing K proposal boxes in absolute
coordinates.
groundtruth_boxlist: A Boxlist containing N groundtruth object boxes in
absolute coordinates.
groundtruth_classes_with_background: A tensor with shape
`[N, self.num_classes + 1]` representing groundtruth classes. The
classes are assumed to be k-hot encoded, and include background as the
zero-th class.
Returns:
a BoxList contained sampled proposals.'

def _sample_box_classifier_minibatch(self, proposal_boxlist, groundtruth_boxlist, groundtruth_classes_with_background):

    (cls_targets, cls_weights, _, _, _) = self._detector_target_assigner.assign(proposal_boxlist, groundtruth_boxlist, groundtruth_classes_with_background)
    cls_weights += tf.to_float(tf.equal(tf.reduce_sum(cls_weights), 0))
    positive_indicator = tf.greater(tf.argmax(cls_targets, axis=1), 0)
    sampled_indices = self._second_stage_sampler.subsample(tf.cast(cls_weights, tf.bool), self._second_stage_batch_size, positive_indicator)
    return box_list_ops.boolean_mask(proposal_boxlist, sampled_indices)
