§
    ™Štj„  ã                  óÀ   — d dl mZ d dlZd dlmZ 	 d dlmZ n# e$ r	 d dlmZ Y nw xY wd dl	m
Z
mZ d dlmZ d dlmZmZ  ej        e¦  «        Z G d„ d	e¦  «        ZdS )
é    )ÚannotationsN)ÚCallable)ÚSelf)ÚTensorÚnn)ÚModule)ÚfullnameÚimport_from_stringc                  ó®   ‡ — e Zd ZU dZg d¢Zded<   d ej        ¦   «         ddddfd.ˆ fd„Zd/d„Z	d0d„Z
ˆ fd„Zddœd1d!„Ze	 	 	 	 	 	 d2d3d-„¦   «         Zˆ xZS )4ÚDensea  Applies a linear transformation with an optional activation function.

    Passes the embedding through a feed-forward layer (``nn.Linear`` + activation), useful for
    dimensionality reduction or projecting embeddings into a different space.

    Args:
        in_features: Size of the input dimension.
        out_features: Size of the output dimension.
        bias: Whether to include a bias vector in the linear layer.
        activation_function: Activation function applied after the linear layer.
            If ``None``, uses ``nn.Identity()``. Defaults to ``nn.Tanh()``.
        init_weight: Initial value for the weight matrix of the linear layer.
        init_bias: Initial value for the bias vector of the linear layer.
        module_input_name: The key in the features dictionary to read the input from.
            Defaults to ``"sentence_embedding"``.
        module_output_name: The key in the features dictionary to store the output in.
            If ``None``, uses the same key as ``module_input_name``.
    )Úin_featuresÚout_featuresÚbiasÚactivation_functionÚmodule_input_nameÚmodule_output_namez	list[str]Úconfig_keysTNÚsentence_embeddingr   Úintr   r   Úboolr   ú!Callable[[Tensor], Tensor] | NoneÚinit_weightúTensor | NoneÚ	init_biasr   Ústrr   ú
str | Nonec	                ó’  •— t          ¦   «                              ¦   «          || _        || _        || _        |€t          j        ¦   «         n|| _        t          j        |||¬¦  «        | _	        || _
        |�|n|| _        |�t          j        |¦  «        | j	        _        |�"|r"t          j        |¦  «        | j	        _        d S d S d S )N)r   )ÚsuperÚ__init__r   r   r   r   ÚIdentityr   ÚLinearÚlinearr   r   Ú	ParameterÚweight)
Úselfr   r   r   r   r   r   r   r   Ú	__class__s
            €úf/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sentence_transformers/base/modules/dense.pyr   zDense.__init__0   sË   ø€ õ 	‰Œ×ÒÑÔÐØ&ˆÔØ(ˆÔØˆŒ	Ø4GÐ4O¥2¤;¡=¤= =ÐUhˆÔ Ý”i ¨\ÀÐEÑEÔEˆŒØ!2ˆÔØ8JÐ8VÐ"4Ð"4Ð\mˆÔàÐ"Ý!#¤¨kÑ!:Ô!:ˆDŒKÔàÐ  TÐ Ý!œ|¨IÑ6Ô6ˆDŒKÔÐÐð !Ð Ð Ð ó    Úfeaturesúdict[str, Tensor]c           	     ó    — |                      | j        |                      |                      || j                 ¦  «        ¦  «        i¦  «         |S ©N)Úupdater   r   r"   r   )r%   r)   s     r'   ÚforwardzDense.forwardJ   sM   € Ø�ŠØÔ$ d×&>Ò&>¸t¿{º{È8ÐTXÔTjÔKkÑ?lÔ?lÑ&mÔ&mÐnñ	
ô 	
ð 	
ð ˆr(   Úreturnc                ó   — | j         S r,   )r   )r%   s    r'   Úget_embedding_dimensionzDense.get_embedding_dimensionP   s   € ØÔ Ð r(   c                óv   •— t          ¦   «                              ¦   «         }t          | j        ¦  «        |d<   |S )Nr   )r   Úget_config_dictr	   r   )r%   Úconfigr&   s     €r'   r3   zDense.get_config_dictS   s3   ø€ Ý‘”×(Ò(Ñ*Ô*ˆÝ(0°Ô1IÑ(JÔ(JˆÐ$Ñ%Øˆr(   ©Úsafe_serializationÚoutput_pathr6   ÚNonec               ó^   — |                       |¦  «         |                      ||¬¦  «         d S )Nr5   )Úsave_configÚsave_torch_weights)r%   r7   r6   ÚargsÚkwargss        r'   Úsavez
Dense.saveX   s6   € Ø×Ò˜Ñ%Ô%Ð%Ø×Ò Ð@RÐÑSÔSÐSÐSÐSr(   Ú FÚmodel_name_or_pathÚ	subfolderÚtokenúbool | str | NoneÚcache_folderÚrevisionÚlocal_files_onlyÚtrust_remote_coder   c                ó6  — |||||dœ}	 | j         dd|i|	¤Ž}
d|
v re|s|
d                              d¦  «        r! t          |
d         ¦  «        ¦   «         |
d<   n't                               d|
d         › d�¦  «         |
d=  | di |
¤Ž} | j        d||dœ|	¤Ž}|S )	N)rA   rB   rD   rE   rF   r@   r   ztorch.zActivation function path 'zÁ' is not trusted, falling back to the default activation function (Tanh). Please load the model with `trust_remote_code=True` to allow loading custom activation functions via the configuration.)r@   Úmodel© )Úload_configÚ
startswithr
   ÚloggerÚwarningÚload_torch_weights)Úclsr@   rA   rB   rD   rE   rF   rG   r=   Ú
hub_kwargsr4   rI   s               r'   Úloadz
Dense.load\   s  € ð #ØØ(Ø Ø 0ð
ð 
ˆ
ð !�”ÐUÐUÐ4FÐUÈ*ÐUÐUˆØ  FÐ*Ð*Ø ð 	2 FÐ+@Ô$A×$LÒ$LÈXÑ$VÔ$Vð 	2Ø0aÕ0BÀ6ÐJ_ÔC`Ñ0aÔ0aÑ0cÔ0c�Ð,Ñ-Ð-å—’ð7°Ð8MÔ1Nð 7ð 7ð 7ñô ð ð Ð0Ð1Ø����f��ˆØ&�Ô&ÐhÐ:LÐTYÐhÐhÐ]gÐhÐhˆØˆr(   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r)   r*   )r/   r   )r7   r   r6   r   r/   r8   )r?   NNNFF)r@   r   rA   r   rB   rC   rD   r   rE   r   rF   r   rG   r   r/   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   ÚTanhr   r.   r1   r3   r>   ÚclassmethodrR   Ú__classcell__)r&   s   @r'   r   r      s4  ø€ € € € € € ðð ð&ð ð €Kð ð ð ñ ð ØAHÀÄÁÄØ%)Ø#'Ø!5Ø)-ð7ð 7ð 7ð 7ð 7ð 7ð 7ð4ð ð ð ð!ð !ð !ð !ðð ð ð ð ð
 HLð Tð Tð Tð Tð Tð Tð ð Ø#'Ø#'Ø#Ø!&Ø"'ð ð  ð  ð  ñ „[ð ð  ð  ð  ð  r(   r   )Ú
__future__r   ÚloggingÚcollections.abcr   Útypingr   ÚImportErrorÚtyping_extensionsÚtorchr   r   Ú)sentence_transformers.base.modules.moduler   Úsentence_transformers.utilr	   r
   Ú	getLoggerrS   rM   r   rJ   r(   r'   ú<module>re      s  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø $Ð $Ð $Ð $Ð $Ð $ð'ØÐÐÐÐÐÐøØð 'ð 'ð 'Ø&Ð&Ð&Ð&Ð&Ð&Ð&Ð&ð'øøøð Ð Ð Ð Ð Ð Ð Ð à <Ð <Ð <Ð <Ð <Ð <Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cà	ˆÔ	˜8Ñ	$Ô	$€ðjð jð jð jð jˆFñ jô jð jð jð js   ’ ™'¦'