import re
import base64


def unmask_annotations(text_with_masked_annotations):
    """Reverts a previous masking of all annotations."""

    return re.sub(
        r"@neanno_masked_annotation:(?P<base64string>.*?)@",
        lambda match: base64.b64decode(match.group("base64string")).decode(),
        text_with_masked_annotations,
    )