def METHOD_NAME(expr, variables):
    identifiers = re.findall(r"\w+", expr)
    # Don't bother counting if we don't have any duplicates in the first place
    if len(identifiers) == len(set(identifiers)):
        return
    identifier_count = Counter(identifiers)
    for identifier, count in identifier_count.items():
        var = variables.get(identifier, None)
        if count > 1 and isinstance(var, Function) and not var.stateless:
            raise NotImplementedError(
                f"The expression '{expr}' contains "
                f"more than one call of {identifier}. This "
                "is currently not supported since "
                f"{identifier} is a stateful function and "
                "its multiple calls might be "
                "treated incorrectly (e.g."
                "'rand() - rand()' could be "
                " simplified to "
                "'0.0')."
            )