
    oi&                        % S SK Jr  S SKJrJrJr  S SKrSSKJr  \(       a  SSK	J
r
  SSKJr  0 rS\S	'   0 rS
\S'   0 rS
\S'   0 rS\S'   SS jr   S           SS jjrg)    )annotations)TYPE_CHECKINGAnyOptionalN   )PeftType)
PeftConfig)	BaseTunerz dict[PeftType, type[PeftConfig]]PEFT_TYPE_TO_CONFIG_MAPPINGzdict[PeftType, type[BaseTuner]]PEFT_TYPE_TO_TUNER_MAPPING PEFT_TYPE_TO_MIXED_MODEL_MAPPINGzdict[PeftType, str]PEFT_TYPE_TO_PREFIX_MAPPINGc                &    [         U S      " S0 U D6$ )z
Returns a Peft config object from a dictionary.

Args:
    config_dict (`Dict[str, Any]`): Dictionary containing the configuration parameters.
	peft_type )r   )config_dicts    F/home/james-whalen/.local/lib/python3.13/site-packages/peft/mapping.pyget_peft_configr   $   s     '{;'?@O;OO    c                    U R                   (       d  U R                  (       a  [        S5      eU R                  [        R                  5       ;  a  [        SU R                   S35      e[        U R                     nU" XX#US9nUR                  $ )a,  
Create PEFT layers and inject them into the model in-place.

Currently the API does not support prompt learning methods and adaption prompt.

This function is similar to [`get_peft_model`] but it does not return a [`PeftModel`] instance. Instead, it returns
the original, mutated instance of the passed model.

Args:
    peft_config (`PeftConfig`):
        Configuration object containing the parameters of the PEFT model.
    model (`torch.nn.Module`):
        The input model where the adapter will be injected.
    adapter_name (`str`, `optional`, defaults to `"default"`):
        The name of the adapter to be injected, if not provided, the default adapter name is used ("default").
    low_cpu_mem_usage (`bool`, `optional`, defaults to `False`):
        Create empty adapter weights on meta device. Useful to speed up the loading process.
    state_dict (`dict`, *optional*, defaults to `None`)
        If a `state_dict` is passed here, the adapters will be injected based on the entries of the state_dict.
        This can be useful when the exact `target_modules` of the PEFT method is unknown, for instance because the
        checkpoint was created without meta data. Note that the values from the `state_dict` are not used, only the
        keys are used to determine the correct layers that should be adapted.
zN`create_and_replace` does not support prompt learning and adaption prompt yet.z+`inject_adapter_in_model` does not support z" yet. Please use `get_peft_model`.)adapter_namelow_cpu_mem_usage
state_dict)is_prompt_learningis_adaption_prompt
ValueErrorr   r   keysmodel)peft_configr   r   r   r   	tuner_cls
peft_models          r   inject_adapter_in_modelr"   /   s    < %%)G)Gijj$>$C$C$EE9+:O:O9PPrs
 	
 +;+@+@AI gqJ r   )r   zdict[str, Any]returnr	   )defaultFN)r   r	   r   torch.nn.Moduler   strr   boolr   z!Optional[dict[str, torch.Tensor]]r#   r%   )
__future__r   typingr   r   r   torchutilsr   configr	   tuners.tuners_utilsr
   r   __annotations__r   r   r   r   r"   r   r   r   <module>r/      s    # / /   ". AC = B>@ ; @DF  "A F35 0 5P "#48--- - 	-
 2- -r   