import re


def undo_bpe(seq: str) -> str:
    """Undo the BPE splits to make Bleu comparable.

    :param seq: The string with encoded tokens in it.

    :returns: The string with BPE splits collapsed.
    """
    # BPE token is @@ this removes it if it is at the end of a word or the end
    # of the sequence.
    return re.sub(r"@@( | ?$)", "", seq)