'Override for issubclass(subclass, cls).'

def __subclasscheck__(cls, subclass):

    if (subclass in cls._abc_cache):
        return True
    if (cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter):
        cls._abc_negative_cache = set()
        cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
    elif (subclass in cls._abc_negative_cache):
        return False
    ok = cls.__subclasshook__(subclass)
    if (ok is not NotImplemented):
        assert isinstance(ok, bool)
        if ok:
            cls._abc_cache.add(subclass)
        else:
            cls._abc_negative_cache.add(subclass)
        return ok
    if (cls in getattr(subclass, '__mro__', ())):
        cls._abc_cache.add(subclass)
        return True
    for rcls in cls._abc_registry:
        if issubclass(subclass, rcls):
            cls._abc_cache.add(subclass)
            return True
    for scls in cls.__subclasses__():
        if issubclass(subclass, scls):
            cls._abc_cache.add(subclass)
            return True
    cls._abc_negative_cache.add(subclass)
    return False
