def METHOD_NAME(cls):
    """generic_func.dispatch(cls) -> <function implementation>
    Runs the dispatch algorithm to return the best available implementation
    for the given *cls* registered on *generic_func*.
    """
    nonlocal cache_token
    if cache_token is not None:
        current_token = get_cache_token()
        if cache_token != current_token:
            dispatch_cache.clear()
            cache_token = current_token
    try:
        impl = dispatch_cache[cls]
    except KeyError:
        try:
            impl = registry[cls]
        except KeyError:
            impl = _find_impl(cls, registry)
        dispatch_cache[cls] = impl
    return impl