Yes, it works. But I think there is a more efficient method. 
Maybe I could scatter the sentences which dim is (11, 20) to (2, 6, 10), which sentence length is smaller than 6 should be padded. Then pooling (2, 6, 10) to (2, 1, 10), and then reshape to (2, 10).
So I want to know one quick method to get the scatter index from sentence_split_flag or sentence_segment.