def METHOD_NAME(namespace: Any, function: Callable[..., Any]) -> Callable[..., str]:
    """
    Return a function that generates a string key.
    Based on a given function as well as arguments to the returned function itself.
    This is used by :meth:`.CacheRegion.cache_on_arguments` to generate a cache key from a decorated function.
    """
    if namespace is None:
        namespace = (function.__module__, function.__name__)
    else:
        namespace = (function.__module__, function.__name__, namespace)
    args = inspect.getfullargspec(function)
    ignore_first_argument = args[0] and args[0][0] in ("self", "cls")
    def generate_key(*args: Any, **kw: Any) -> str:
        if kw:
            raise ValueError("key creation function does not accept keyword arguments.")
        parts: list[str] = []
        parts.extend(namespace)
        if ignore_first_argument:
            args = args[1:]
        new_args: list[str] = [
            arg for arg in args if pyramid.interfaces.IRequest not in zope.interface.implementedBy(type(arg))
        ]
        parts.extend(map(str, map(map_dbobject, new_args)))
        return "|".join(parts)
    return generate_key