def extend_instance(cls, base: object, mixin: Type[Any]):
        """Apply mixins to a class instance after creation.

        Args:
            base (object): Base module instance.
            mixin: (Type[Any]): Adapter class type to mixin.
        """
        base_cls = base.__class__
        base_cls_name = base.__class__.__name__
        base.__class__ = type(
            base_cls_name, (mixin, base_cls),
            {})  # mixin needs to go first for our forward() logic to work
Apply mixins to a class instance after creation.

        Args:
            base (object): Base module instance.
            mixin: (Type[Any]): Adapter class type to mixin.
        
mmpretrain/models/multimodal/flamingo/utils.py