import re


def specop_from_numberedscope(scope):
    """
    An inverse for `match_numbered_scope`.

    Example: 'conv2d_4' will produce 'conv2d'.
    """
    expr = '[_a-zA-Z0-9]+(?=_[0-9]+)'
    match = re.search(expr, scope)
    if match is not None:
        return match.group(0)
    else:
        return scope