code: def init(
      model: PreTrainedModel,
      adapters_config: Optional[ModelAdaptersConfig] = None,
  ) -> None:
      if isinstance(model, ModelAdaptersMixin):
          return model
  
      # First, replace original module classes with their adapters counterparts
      model_name = get_module_name(model.config.model_type)
      modules_with_adapters = importlib.import_module(
          f".{model_name}.modeling_{model_name}", "adapters.models"
      )
      submodules = list(model.modules())
  
      # Replace the base model class
      replace_with_adapter_class(
          submodules.pop(0), modules_with_adapters
      )
  
      # Check if the base model class derives from ModelUsingSubmodelsAdaptersMixin
      if isinstance(model, ModelUsingSubmodelsAdaptersMixin):
          # Before initializing the submodels, make sure that adapters_config is set for the whole model.
          # Otherwise, it would not be shared between the submodels.
          init_adapters_config(model, model.config, adapters_config)
          adapters_config = model.adapters_config
          model.init_submodels()
          submodules = []
  
      # Change the class of all child modules to their adapters class
      for module in submodules:
          replace_with_adapter_class(module, modules_with_adapters)
  
      # Next, check if model class itself is not replaced and has an adapter-supporting base class
      if not isinstance(model, ModelAdaptersMixin):
          if hasattr(model, "base_model_prefix") and hasattr(
              model, model.base_model_prefix
          ):
              base_model = getattr(model, model.base_model_prefix)
              if isinstance(base_model, ModelAdaptersMixin):
                  # Create new wrapper model class
                  model_class_name = model.__class__.__name__
                  model_class = type(
                      model_class_name,
                      (
                          EmbeddingAdaptersWrapperMixin,
                          ModelWithHeadsAdaptersMixin,
                          model.__class__,
                      ),
                      {},
                  )
                  model.__class__ = model_class
  
      # Finally, initialize adapters
      model.init_adapters(model.config, adapters_config)
  
file_path: adapters/src/adapters/wrappers/model.py
imports: import importlib
  import os
  from typing import Any, Optional, Type, Union
  from torch import nn
  from transformers import PreTrainedModel
  from transformers.models.auto.auto_factory import getattribute_from_module
  from transformers.models.auto.configuration_auto import model_type_to_module_name
  from ..configuration import ModelAdaptersConfig
  from ..model_mixin import EmbeddingAdaptersWrapperMixin, ModelAdaptersMixin, ModelUsingSubmodelsAdaptersMixin, ModelWithHeadsAdaptersMixin
  from ..models import MODEL_MIXIN_MAPPING
  from .configuration import init_adapters_config
label_desc: Use image node_id 3 for calling a global function with example usage: init(model, adapters_config) and returns: model