def get_seg_states(self, hidden_states, segment_index):
    '\n        Input:\n            hidden_states[batch, seq_len, hidden_dim]\n            segment_index[batch, seq_len]\n        '
    seg_states = torch.zeros(hidden_states.size(0), self.max_segment, hidden_states.size(2)).to(hidden_states.device)
    length = (segment_index == 0).sum(dim=1)
    length_mask = length_to_mask(length, max_len=self.max_segment, dtype=torch.float)
    seg_states[(length_mask == 1), :] = hidden_states[(segment_index == 0), :]
    return (seg_states, length_mask)
Input:
    hidden_states[batch, seq_len, hidden_dim]
    segment_index[batch, seq_len]
def get_seg_states(self, hidden_states, segment_index):
    '\n        Input:\n            hidden_states[batch, seq_len, hidden_dim]\n            segment_index[batch, seq_len]\n        '
    seg_states = torch.zeros(hidden_states.size(0), self.max_segment, hidden_states.size(2)).to(hidden_states.device)
    length = (segment_index == 0).sum(dim=1)
    length_mask = length_to_mask(length, max_len=self.max_segment, dtype=torch.float)
    seg_states[(length_mask == 1), :] = hidden_states[(segment_index == 0), :]
    return (seg_states, length_mask)