class_docstr: This is the configuration class to store the configuration of a [`LoraModel`].
  
  Args:
      r (`int`):
          Lora attention dimension (the "rank").
      target_modules (`Optional[Union[List[str], str]]`):
          The names of the modules to apply the adapter to. If this is specified, only the modules with the specified
          names will be replaced. When passing a string, a regex match will be performed. When passing a list of
          strings, either an exact match will be performed or it is checked if the name of the module ends with any
          of the passed strings. If this is specified as 'all-linear', then all linear/Conv1D modules are chosen,
          excluding the output layer. If this is not specified, modules will be chosen according to the model
          architecture. If the architecture is not known, an error will be raised -- in this case, you should specify
          the target modules manually.
      lora_alpha (`int`):
          The alpha parameter for Lora scaling.
      lora_dropout (`float`):
          The dropout probability for Lora layers.
      fan_in_fan_out (`bool`):
          Set this to True if the layer to replace stores weight like (fan_in, fan_out). For example, gpt-2 uses
          `Conv1D` which stores weights like (fan_in, fan_out) and hence this should be set to `True`.
      bias (`str`):
          Bias type for LoRA. Can be 'none', 'all' or 'lora_only'. If 'all' or 'lora_only', the corresponding biases
          will be updated during training. Be aware that this means that, even when disabling the adapters, the model
          will not produce the same output as the base model would have without adaptation.
      use_rslora (`bool`):
          When set to True, uses <a href='https://doi.org/10.48550/arXiv.2312.03732'>Rank-Stabilized LoRA</a> which
          sets the adapter scaling factor to `lora_alpha/math.sqrt(r)`, since it was proven to work better.
          Otherwise, it will use the original default value of `lora_alpha/r`.
      modules_to_save (`List[str]`):
          List of modules apart from adapter layers to be set as trainable and saved in the final checkpoint.
      init_lora_weights (`bool` | `Literal["gaussian", "loftq"]`):
          How to initialize the weights of the adapter layers. Passing True (default) results in the default
          initialization from the reference implementation from Microsoft. Passing 'gaussian' results in Gaussian
          initialization scaled by the LoRA rank for linear and layers. Setting the initialization to False leads to
          completely random initialization and is discouraged. Pass `'loftq'` to use LoftQ initialization.
      layers_to_transform (`Union[List[int], int]`):
          The layer indices to transform. If a list of ints is passed, it will apply the adapter to the layer indices
          that are specified in this list. If a single integer is passed, it will apply the transformations on the
          layer at this index.
      layers_pattern (`str`):
          The layer pattern name, used only if `layers_to_transform` is different from `None`.
      rank_pattern (`dict`):
          The mapping from layer names or regexp expression to ranks which are different from the default rank
          specified by `r`.
      alpha_pattern (`dict`):
          The mapping from layer names or regexp expression to alphas which are different from the default alpha
          specified by `lora_alpha`.
      megatron_config (`Optional[dict]`):
          The TransformerConfig arguments for Megatron. It is used to create LoRA's parallel linear layer. You can
          get it like this, `core_transformer_config_from_args(get_args())`, these two functions being from Megatron.
          The arguments will be used to initialize the TransformerConfig of Megatron. You need to specify this
          parameter when you want to apply LoRA to the ColumnParallelLinear and RowParallelLinear layers of megatron.
      megatron_core (`Optional[str]`):
          The core module from Megatron to use, defaults to `"megatron.core"`.
      loftq_config (`Optional[LoftQConfig]`):
          The configuration of LoftQ. If this is not None, then LoftQ will be used to quantize the backbone weights
          and initialize Lora layers. Also pass `init_lora_weights='loftq'`. Note that you should not pass a
          quantized model in this case, as LoftQ will quantize the model itself.
code: def __post_init__(self):
      self.peft_type = PeftType.LORA
      self.target_modules = (
          set(self.target_modules)
          if isinstance(self.target_modules, list)
          else self.target_modules
      )
      # if target_modules is a regex expression, then layers_to_transform should be None
      if (
          isinstance(self.target_modules, str)
          and self.layers_to_transform is not None
      ):
          raise ValueError(
              "`layers_to_transform` cannot be used when `target_modules` is a str."
          )
  
      # if target_modules is a regex expression, then layers_pattern should be None
      if (
          isinstance(self.target_modules, str)
          and self.layers_pattern is not None
      ):
          raise ValueError(
              "`layers_pattern` cannot be used when `target_modules` is a str."
          )
  
      # handle init_lora_weights and loftq_config
      if self.init_lora_weights == "loftq":
          import importlib
  
          if not importlib.util.find_spec("scipy"):
              raise ImportError(
                  "The required package 'scipy' is not installed. Please install it to continue."
              )
          if self.loftq_config is None:
              raise ValueError(
                  "`loftq_config` must be specified when `init_lora_weights` is 'loftq'."
              )
  
      # convert loftq_config to dict
      if self.loftq_config and not isinstance(self.loftq_config, dict):
          self.loftq_config = vars(self.loftq_config)
  
file_path: peft/src/peft/tuners/lora/config.py
imports: from __future__ import annotations
  from dataclasses import dataclass, field
  from typing import List, Literal, Optional, Union
  from peft.config import PeftConfig
  from peft.utils import PeftType
label_desc: Use image node_id 1 for calling the LoraConfig obj's underlying member method code with example usage: obj.__post_init__() without return types