def removesuffix(x, suffix):
    """Backport of `removesuffix` from PEP-616 (Python 3.9+)"""

    if len(suffix) > 0 and x.endswith(suffix):
        return x[: -len(suffix)]
    else:
        return x
Backport of `removesuffix` from PEP-616 (Python 3.9+)
keras/src/utils/python_utils.py