class_docstr: A class that allows to mix different types of adapters in a single model.
  
  Note: This class should usually not be initialized directly. Instead, use `get_peft_model` with the argument
  `mixed=True`.
  
  Args:
      model (:obj:`nn.Module`):
          The model to be tuned.
      config (:obj:`PeftConfig`):
          The config of the model to be tuned. The adapter type must be compatible.
      adapter_name (:obj:`str`):
          The name of the first adapter.
class_docstr_tok: ["A","class","that","allows","to","mix","different","types","of","adapters","in","a","single","model",".","Note",":","This","class","should","usually","not","be","initialized","directly",".","Instead",",","use","`","get_peft_model","`","with","the","argument","`","mixed=True","`",".","Args",":","model","(",":","obj",":","`","nn.Module","`",")",":","The","model","to","be","tuned",".","config","(",":","obj",":","`","PeftConfig","`",")",":","The","config","of","the","model","to","be","tuned",".","The","adapter","type","must","be","compatible",".","adapter_name","(",":","obj",":","`","str","`",")",":","The","name","of","the","first","adapter","."]
code: def _replace_module(
      self, parent, child_name, new_module, child
  ) -> None:
      setattr(parent, child_name, new_module)
      # It's not necessary to set requires_grad here, as that is handled by
      # _mark_only_adapters_as_trainable
  
      # child layer wraps the original module, unpack it
      if hasattr(child, "base_layer"):
          child = child.get_base_layer()
      elif hasattr(child, "quant_linear_module"):
          # TODO maybe not necessary to have special treatment?
          child = child.quant_linear_module
  
      if not hasattr(new_module, "base_layer"):
          new_module.weight = child.weight
          if hasattr(child, "bias"):
              new_module.bias = child.bias
  
      if getattr(child, "state", None) is not None:
          if hasattr(new_module, "base_layer"):
              new_module.base_layer.state = child.state
          else:
              new_module.state = child.state
          new_module.to(child.weight.device)
  
      # dispatch to correct device
      for name, module in new_module.named_modules():
          if any(prefix in name for prefix in PREFIXES):
              module.to(child.weight.device)
          if "ranknum" in name:
              module.to(child.weight.device)
  
imports: from __future__ import annotations
  import warnings
  from typing import Any, Optional, Union
  from torch import nn
  from tqdm import tqdm
  from peft.tuners import adalora, loha, lokr, lora, oft
  from peft.tuners.tuners_utils import BaseTuner, BaseTunerLayer, check_target_module_exists
  from peft.utils import TRANSFORMERS_MODELS_TO_LORA_TARGET_MODULES_MAPPING, ModulesToSaveWrapper, PeftType, _get_submodules, get_auto_gptq_quant_linear
label_desc: Use image node_id 5 for calling the MixedModel obj's underlying member method code with example usage: obj._replace_module(parent, child_name, new_module, child) without return types