Injects an instance (self) of type (classkey)
    with all functions registered to (classkey)

    call this in the __init__ class function

    Args:
        self: the class instance
        classkey: key for a class, preferably the class type itself, but it
            doesnt have to be

    SeeAlso:
        make_class_method_decorator

    Example:
        >>> # DISABLE_DOCTEST
        >>> # DOCTEST_DISABLE
        >>> utool.make_class_method_decorator(InvertedIndex)(smk_debug.invindex_dbgstr)
        >>> utool.inject_instance(invindex)

def inject_instance(self, classkey=None, allow_override=False,
                    verbose=VERBOSE_CLASS, strict=True):
    """
    Injects an instance (self) of type (classkey)
    with all functions registered to (classkey)

    call this in the __init__ class function

    Args:
        self: the class instance
        classkey: key for a class, preferably the class type itself, but it
            doesnt have to be

    SeeAlso:
        make_class_method_decorator

    Example:
        >>> # DISABLE_DOCTEST
        >>> # DOCTEST_DISABLE
        >>> utool.make_class_method_decorator(InvertedIndex)(smk_debug.invindex_dbgstr)
        >>> utool.inject_instance(invindex)
    """
    import utool as ut
    if verbose:
        print('[util_class] begin inject_instance')
    try:
        if classkey is None:
            # Probably should depricate this block of code
            # It tries to do too much
            classkey = self.__class__
            if classkey == 'ibeis.gui.models_and_views.IBEISTableView':
                # HACK HACK HACK
                # from guitool.__PYQT__ import QtGui  # NOQA
                from guitool.__PYQT__ import QtWidgets  # NOQA
                classkey = QtWidgets.QAbstractItemView
            if len(__CLASSTYPE_ATTRIBUTES__[classkey]) == 0:
                print('[utool] Warning: no classes of type %r are registered' % (classkey,))
                print('[utool] type(self)=%r, self=%r' % (type(self), self)),
                print('[utool] Checking to see if anybody else was registered...')
                print('[utool] __CLASSTYPE_ATTRIBUTES__ = ' +
                      ut.repr4(__CLASSTYPE_ATTRIBUTES__.keys()))
                for classtype_, _ in six.iteritems(__CLASSTYPE_ATTRIBUTES__):
                    isinstance(self, classtype_)
                    classkey = classtype_
                    print('[utool] Warning: using subclass=%r' % (classtype_,))
                    break
        func_list = __CLASSTYPE_ATTRIBUTES__[classkey]
        if verbose:
            print('[util_class] injecting %d methods\n   with classkey=%r\n   into %r'
                  % (len(func_list), classkey, self,))
        for func in func_list:
            if VERBOSE_CLASS:
                print('[util_class] * injecting %r' % (func,))
            method_name = None
            # Allow user to register tuples for aliases
            if isinstance(func, tuple):
                func, method_name = func
            inject_func_as_method(self, func, method_name=method_name,
                                  allow_override=allow_override, verbose=verbose)
    except Exception as ex:
        ut.printex(ex, 'ISSUE WHEN INJECTING %r' % (classkey,),
                      iswarning=not strict)
        if strict:
            raise