def METHOD_NAME(cls, func=None):
    """generic_func.register(cls, func) -> func
    Registers a new implementation for the given *cls* on a *generic_func*.
    """
    nonlocal cache_token
    if func is None:
        if isinstance(cls, type):
            return lambda f: METHOD_NAME(cls, f)
        ann = getattr(cls, '__annotations__', {})
        if not ann:
            raise TypeError(
                f"Invalid first argument to `register()`: {cls!r}. "
                f"Use either `@register(some_class)` or plain `@register` "
                f"on an annotated function."
            )
        func = cls
        # only import typing if annotation parsing is necessary
        from typing import get_type_hints
        argname, cls = next(iter(get_type_hints(func).items()))
        if not isinstance(cls, type):
            raise TypeError(
                f"Invalid annotation for {argname!r}. "
                f"{cls!r} is not a class."
            )
    registry[cls] = func
    if cache_token is None and hasattr(cls, '__abstractmethods__'):
        cache_token = get_cache_token()
    dispatch_cache.clear()
    return func