in 04_detect_segment/utils_box.py [0:0]
def batch_filter_by_bool_and_pad(rois, mask, max_n):
rois_n = tf.math.count_nonzero(mask, axis=1)
overflow = tf.maximum(rois_n - max_n, 0)
rois = tf.map_fn(lambda rois__mask: filter_by_bool_and_pad(*rois__mask, max_n=max_n), (rois, mask), dtype=tf.float32) # shape [batch, max_n, 4]
rois = tf.reshape(rois, [-1, max_n, 4]) # Tensorflow needs a hint about the shape
return rois, overflow