def __instancecheck__(cls, instance):
    """
        Return True if instance is an instance of cls.

        We need to override the default isinstance check because
        ``type(function.Function(...))`` is ``function.Function``, but
        type(function.Function) is ``_BackendSelector`` and so by default
        ``isinstance(function.Function(...), function.Function)`` is False.
        """
    return isinstance(instance, cls._backend.__dict__[cls.__name__])
