def convert_txt_to_inds(txt, char2ind, eos=False, sos=False):
    """

    Args:
        txt: Array of chars to convert to inds.
        char2ind: Lookup dict from chars to inds.

    Returns: The converted chars, i.e. array of ints.

    """
    txt_to_inds = [char2ind[ch] for ch in txt]
    if eos:
        txt_to_inds.append(char2ind['<EOS>'])
    if sos:
        txt_to_inds.insert(0, char2ind['<SOS>'])
    return txt_to_inds