§
    *�’jI  ã                  óÔ   — d dl mZ d dlZd dlZd dlm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)ÚAny)ÚSelf)ÚTensorÚnn)ÚModule)ÚfullnameÚimport_from_stringc                  óÄ   ‡ — e Zd ZU dZg d¢Zded<   ddiZded<   d	 ej        ¦   «         d
d
dd
dfd3ˆ fd„Z	d4d„Z
d5d„Zˆ fd „Zd	d!œd6d%„Ze	 	 	 	 	 	 	 d7d8d2„¦   «         Zˆ xZS )9Ú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``.
        use_residual: If True, add a residual connection from the input to the projected output.
            When ``in_features != out_features``, the residual is projected through a separate
            ``nn.Linear(in_features, out_features, bias=False)``. Defaults to False.
    )Úin_featuresÚout_featuresÚbiasÚactivation_functionÚmodule_input_nameÚmodule_output_nameÚuse_residualz	list[str]Úconfig_keysr   Fzdict[str, bool]Ú_DEFAULT_CONFIG_VALUESTNÚ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|| _        |	| _        |	r"||k    rt          j        ||d¬¦  «        | _        |�t          j        |¦  «        | j	        _        |�"|r"t          j        |¦  «        | j	        _        d S d S d S )N)r   F)ÚsuperÚ__init__r   r   r   r   ÚIdentityr   ÚLinearÚlinearr   r   r   ÚresidualÚ	ParameterÚweight)Úselfr   r   r   r   r   r   r   r   r   Ú	__class__s             €úVC:\Projects\DSCons\.venv\Lib\site-packages\sentence_transformers\base\modules\dense.pyr"   zDense.__init__:   sþ   ø€ õ 	‰Œ×ÒÑÔÐØ&ˆÔØ(ˆÔØˆŒ	Ø4GÐ4O¥2¤;¡=¤= =ÐUhˆÔ Ý”i ¨\ÀÐEÑEÔEˆŒØ!2ˆÔØ8JÐ8VÐ"4Ð"4Ð\mˆÔØ(ˆÔØð 	M˜K¨<Ò7Ð7ÝœI k°<ÀeÐLÑLÔLˆDŒMàÐ"Ý!#¤¨kÑ!:Ô!:ˆDŒKÔàÐ  TÐ Ý!œ|¨IÑ6Ô6ˆDŒKÔÐÐð !Ð Ð Ð ó    Úfeaturesúdict[str, Tensor]c                óê   — || j                  }|                      |                      |¦  «        ¦  «        }| j        r,| j        | j        k    r|n|                      |¦  «        }||z   }||| j        <   |S ©N)r   r   r%   r   r   r   r&   r   )r)   r-   ÚxÚoutr&   s        r+   ÚforwardzDense.forwardX   sx   € Ø�TÔ+Ô,ˆØ×&Ò& t§{¢{°1¡~¤~Ñ6Ô6ˆØÔð 	!Ø Ô,°Ô0AÒAÐA�q�qÀtÇ}Â}ÐUVÑGWÔGWˆHØ˜‘.ˆCØ,/ˆ�Ô(Ñ)Øˆr,   Úreturnc                ó   — | j         S r0   )r   )r)   s    r+   Úget_embedding_dimensionzDense.get_embedding_dimensiona   s   € ØÔ Ð r,   c                ó  •— t          ¦   «                              ¦   «         }t          | j        ¦  «        |d<   | j                             ¦   «         D ]4\  }}|                     |¦  «        |k    r|                     |d ¦  «         Œ5|S )Nr   )r!   Úget_config_dictr
   r   r   ÚitemsÚgetÚpop)r)   ÚconfigÚkeyÚdefaultr*   s       €r+   r8   zDense.get_config_dictd   s   ø€ Ý‘”×(Ò(Ñ*Ô*ˆÝ(0°Ô1IÑ(JÔ(JˆÐ$Ñ%Ø Ô7×=Ò=Ñ?Ô?ð 	&ð 	&‰LˆC�Ø�zŠz˜#‰Œ 'Ò)Ð)Ø—
’
˜3 Ñ%Ô%Ð%øØˆr,   ©Úsafe_serializationÚoutput_pathr@   ÚNonec               ó^   — |                       |¦  «         |                      ||¬¦  «         d S )Nr?   )Úsave_configÚsave_torch_weights)r)   rA   r@   ÚargsÚkwargss        r+   Úsavez
Dense.savel   s6   € Ø×Ò˜Ñ%Ô%Ð%Ø×Ò Ð@RÐÑSÔSÐSÐSÐSr,   Ú Úmodel_name_or_pathÚ	subfolderÚtokenúbool | str | NoneÚcache_folderÚrevisionÚlocal_files_onlyÚtrust_remote_codeÚinit_defaultsúdict[str, Any] | Noner   c	                óÌ  ‡— |||||dœ}
 | j         dd|i|
¤Ž}d|v re|s|d                              d¦  «        r! t          |d         ¦  «        ¦   «         |d<   n't                               d|d         › d�¦  «         |d= t          t          j        | ¦  «        j        ¦  «        Št          |¦  «        ‰z
  }|r^t                               d| j	        › dt          |¦  «        › d	|›d
| j	        › d�	¦  «         ˆfd„|                     ¦   «         D ¦   «         }|pi                      ¦   «         D ]\  }}|                     ||¦  «         Œ | di |¤Ž} | j        d||dœ|
¤Ž}|S )N)rK   rL   rN   rO   rP   rJ   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.zIgnoring unrecognized z config key(s) z from z : not constructor parameters of ú.c                ó$   •— i | ]\  }}|‰v ¯	||“ŒS © rW   )Ú.0r=   ÚvalueÚaccepted_paramss      €r+   ú
<dictcomp>zDense.load.<locals>.<dictcomp>™   s)   ø€ Ð\Ð\Ð\¡Z S¨%ÀSÈOÐE[ÐE[�c˜5ÐE[ÐE[ÐE[r,   )rJ   ÚmodelrW   )Úload_configÚ
startswithr   ÚloggerÚwarningÚsetÚinspectÚ	signatureÚ
parametersÚ__name__Úsortedr9   Ú
setdefaultÚload_torch_weights)ÚclsrJ   rK   rL   rN   rO   rP   rQ   rR   rG   Ú
hub_kwargsr<   Úunexpected_keysr=   rY   r\   rZ   s                   @r+   Úloadz
Dense.loadp   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õ �gÔ/°Ñ4Ô4Ô?Ñ@Ô@ˆÝ˜f™+œ+¨Ñ7ˆØð 	]Ý�NŠNðY¨¬ð Yð YÅfÈ_ÑF]ÔF]ð Yð YØ%ðYð YØILÌðYð Yð Yñô ð ð ]Ð\Ð\Ð\°6·<²<±>´>Ð\Ñ\Ô\ˆFà(Ð.¨B×5Ò5Ñ7Ô7ð 	*ð 	*‰JˆC�Ø×Ò˜c 5Ñ)Ô)Ð)Ð)Ø����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.   )r4   r   )rA   r   r@   r   r4   rB   )rI   NNNFFN)rJ   r   rK   r   rL   rM   rN   r   rO   r   rP   r   rQ   r   rR   rS   r4   r   )re   Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r   ÚTanhr"   r3   r6   r8   rH   Úclassmethodrl   Ú__classcell__)r*   s   @r+   r   r      s]  ø€ € € € € € ðð ð,ð ð €Kð ð ð ñ ð 	˜ð/Ðð ð ð ñ ð ØAHÀÄÁÄØ%)Ø#'Ø!5Ø)-Ø"ð7ð 7ð 7ð 7ð 7ð 7ð 7ð<ð ð ð ð!ð !ð !ð !ðð ð ð ð ð HLð Tð Tð Tð Tð Tð Tð ð Ø#'Ø#'Ø#Ø!&Ø"'Ø/3ð.ð .ð .ð .ñ „[ð.ð .ð .ð .ð .r,   r   )Ú
__future__r   rb   ÚloggingÚcollections.abcr   Útypingr   r   ÚImportErrorÚtyping_extensionsÚtorchr   r   Ú)sentence_transformers.base.modules.moduler	   Úsentence_transformers.utilr
   r   Ú	getLoggerre   r_   r   rW   r,   r+   ú<module>r~      s.  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð ð'ØÐÐÐÐÐÐøØð 'ð 'ð 'Ø&Ð&Ð&Ð&Ð&Ð&Ð&Ð&ð'øøøð Ð Ð Ð Ð Ð Ð Ð à <Ð <Ð <Ð <Ð <Ð <Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cà	ˆÔ	˜8Ñ	$Ô	$€ðJð Jð Jð Jð JˆFñ Jô Jð Jð Jð Js   œ# £1°1