class_docstr: Creates a Infused Adapter by Inhibiting and Amplifying Inner Activations ((IA)^3) model from a pretrained
  transformers model. The method is described in detail in https://arxiv.org/abs/2205.05638
  
  Args:
      model ([`~transformers.PreTrainedModel`]): The model to be adapted.
      config ([`IA3Config`]): The configuration of the (IA)^3 model.
      adapter_name (`str`): The name of the adapter, defaults to `"default"`.
  
  Returns:
      `torch.nn.Module`: The (IA)^3 model.
  
  Example:
  
      ```py
      >>> from transformers import AutoModelForSeq2SeqLM, ia3Config
      >>> from peft import IA3Model, IA3Config
  
      >>> config = IA3Config(
      ...     peft_type="IA3",
      ...     task_type="SEQ_2_SEQ_LM",
      ...     target_modules=["k", "v", "w0"],
      ...     feedforward_modules=["w0"],
      ... )
  
      >>> model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")
      >>> ia3_model = IA3Model(config, model)
      ```
  
  **Attributes**:
      - **model** ([`~transformers.PreTrainedModel`]) -- The model to be adapted.
      - **peft_config** ([`ia3Config`]): The configuration of the (IA)^3 model.
class_docstr_tok: ["Creates","a","Infused","Adapter","by","Inhibiting","and","Amplifying","Inner","Activations","(","(","IA",")","^3",")","model","from","a","pretrained","transformers","model",".","The","method","is","described","in","detail","in","https",":","\/\/arxiv.org\/abs\/2205.05638","Args",":","model","(","[","`","~transformers.PreTrainedModel","`","]",")",":","The","model","to","be","adapted",".","config","(","[","`","IA3Config","`","]",")",":","The","configuration","of","the","(","IA",")","^3","model",".","adapter_name","(","`","str","`",")",":","The","name","of","the","adapter",",","defaults","to","`","``","default","''","`",".","Returns",":","`","torch.nn.Module","`",":","The","(","IA",")","^3","model",".","Example",":","``","`","py",">",">",">","from","transformers","import","AutoModelForSeq2SeqLM",",","ia3Config",">",">",">","from","peft","import","IA3Model",",","IA3Config",">",">",">","config","=","IA3Config","(","...","peft_type=","''","IA3","''",",","...","task_type=","''","SEQ_2_SEQ_LM","''",",","...","target_modules=","[","``","k","''",",","``","v","''",",","``","w0","''","]",",","...","feedforward_modules=","[","``","w0","''","]",",","...",")",">",">",">","model","=","AutoModelForSeq2SeqLM.from_pretrained","(","``","t5-base","''",")",">",">",">","ia3_model","=","IA3Model","(","config",",","model",")","``","`","*","*","Attributes","*","*",":","-","*","*","model","*","*","(","[","`","~transformers.PreTrainedModel","`","]",")","--","The","model","to","be","adapted",".","-","*","*","peft_config","*","*","(","[","`","ia3Config","`","]",")",":","The","configuration","of","the","(","IA",")","^3","model","."]
docstr: This method merges the IA³ layers into the base model. This is needed if someone wants to use the base model as
  a standalone model.
  
  Args:
      safe_merge (`bool`):
          whether to activate the safe merging check to check if there is any potential Nan in the adapter
          weights
      adapter_names (`List[str]`, *optional*):
          The list of adapter names that should be merged. If None, all active adapters will be merged. Defaults
          to `None`.
  
  Example:
  
  ```py
  >>> from transformers import AutoModelForCausalLM
  >>> from peft import PeftModel
  
  >>> base_model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-40b")
  >>> peft_model_id = "smangrul/falcon-40B-int4-peft-lora-sfttrainer-sample"
  >>> model = PeftModel.from_pretrained(base_model, peft_model_id)
  >>> merged_model = model.merge_and_unload()
  ```
docstr_tok: ["This","method","merges","the","IA\u00b3","layers","into","the","base","model",".","This","is","needed","if","someone","wants","to","use","the","base","model","as","a","standalone","model",".","Args",":","safe_merge","(","`","bool","`",")",":","whether","to","activate","the","safe","merging","check","to","check","if","there","is","any","potential","Nan","in","the","adapter","weights","adapter_names","(","`","List","[","str","]","`",",","*","optional","*",")",":","The","list","of","adapter","names","that","should","be","merged",".","If","None",",","all","active","adapters","will","be","merged",".","Defaults","to","`","None","`",".","Example",":","``","`","py",">",">",">","from","transformers","import","AutoModelForCausalLM",">",">",">","from","peft","import","PeftModel",">",">",">","base_model","=","AutoModelForCausalLM.from_pretrained","(","``","tiiuae\/falcon-40b","''",")",">",">",">","peft_model_id","=","``","smangrul\/falcon-40B-int4-peft-lora-sfttrainer-sample","''",">",">",">","model","=","PeftModel.from_pretrained","(","base_model",",","peft_model_id",")",">",">",">","merged_model","=","model.merge_and_unload","(",")","``","`"]
code: def merge_and_unload(
      self,
      safe_merge: bool = False,
      adapter_names: Optional[List[str]] = None,
  ) -> torch.nn.Module:
      r"""
      This method merges the IA³ layers into the base model. This is needed if someone wants to use the base model as
      a standalone model.
  
      Args:
          safe_merge (`bool`):
              whether to activate the safe merging check to check if there is any potential Nan in the adapter
              weights
          adapter_names (`List[str]`, *optional*):
              The list of adapter names that should be merged. If None, all active adapters will be merged. Defaults
              to `None`.
  
      Example:
  
      ```py
      >>> from transformers import AutoModelForCausalLM
      >>> from peft import PeftModel
  
      >>> base_model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-40b")
      >>> peft_model_id = "smangrul/falcon-40B-int4-peft-lora-sfttrainer-sample"
      >>> model = PeftModel.from_pretrained(base_model, peft_model_id)
      >>> merged_model = model.merge_and_unload()
      ```
      """
      return self._unload_and_optionally_merge(
          safe_merge=safe_merge, adapter_names=adapter_names
      )
  
imports: from __future__ import annotations
  import re
  import warnings
  from dataclasses import asdict
  from enum import Enum
  from typing import List, Optional
  import torch
  from torch import nn
  from transformers.pytorch_utils import Conv1D
  from peft.import_utils import is_bnb_4bit_available, is_bnb_available
  from peft.tuners.tuners_utils import BaseTuner, BaseTunerLayer, check_target_module_exists
  from peft.utils import TRANSFORMERS_MODELS_TO_IA3_FEEDFORWARD_MODULES_MAPPING, TRANSFORMERS_MODELS_TO_IA3_TARGET_MODULES_MAPPING, ModulesToSaveWrapper, _get_submodules
  from .layer import Conv2d, IA3Layer, Linear
label_desc: Use image node_id 16 for calling the IA3Model obj's underlying member method code with example usage: obj.merge_and_unload(safe_merge, adapter_names) and returns: self