def reorder_encoder_states(self, encoder_states, indices):
    (enc, mask) = encoder_states
    if (not torch.is_tensor(indices)):
        indices = torch.LongTensor(indices).to(enc.device)
    enc = torch.index_select(enc, 0, indices)
    mask = torch.index_select(mask, 0, indices)
    return (enc, mask)
def reorder_encoder_states(self, encoder_states, indices):
    (enc, mask) = encoder_states
    if (not torch.is_tensor(indices)):
        indices = torch.LongTensor(indices).to(enc.device)
    enc = torch.index_select(enc, 0, indices)
    mask = torch.index_select(mask, 0, indices)
    return (enc, mask)