def METHOD_NAME(self, encoder_states, indices):
    """
    Reorder the encoder states.
    See ``TorchGeneratorModel.reorder_encoder_states`` for a description.
    """
    enc, mask = encoder_states
    if not torch.is_tensor(indices):
        indices = torch.LongTensor(indices).to(enc.device)
    enc = torch.index_select(enc, 0, indices)
    if mask is not None:
        mask = torch.index_select(mask, 0, indices)
    return enc, mask