§
    [zniO"  ã                   óÆ  — d dl Z d dlmZ d dlZd dlmZ d dlmZmZ ddlm	Z	  e	j
        e¦  «        Z G d„ dej        ¦  «        Z G d	„ d
ej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ d e¦  «        Zi d!e“d"ed#d$d%œf“d&e“d'e“d(ed)d*if“d+e“d,e“d-e“d.e“d/e“d0e“d1ej        “d2e“d3ej        “d4ej        “d5e“d6e“d7ej        i¥Z ee¦  «        Z d8„ Z! e!d(¦  «        Z" e!d'¦  «        Z# e!d!¦  «        Z$ e!d&¦  «        Z% e!d0¦  «        Z& e!d5¦  «        Z' e!d/¦  «        Z( e!d.¦  «        Z)dS )9é    N)ÚOrderedDict)Úversion)ÚTensorÚnné   )Úloggingc                   ó2   ‡ — e Zd ZdZˆ fd„Zdedefd„Zˆ xZS )ÚPytorchGELUTanha  
    A fast C implementation of the tanh approximation of the GeLU activation function. See
    https://arxiv.org/abs/1606.08415.

    This implementation is equivalent to NewGELU and FastGELU but much faster. However, it is not an exact numerical
    match due to rounding errors.
    c                 óê   •— t          ¦   «                              ¦   «          t          j        t          j        ¦  «        t          j        d¦  «        k     rt          dt          j        › d�¦  «        ‚d S )Nz1.12.0zYou are using torch==zM, but torch>=1.12.0 is required to use PytorchGELUTanh. Please upgrade torch.)ÚsuperÚ__init__r   ÚparseÚtorchÚ__version__ÚImportError©ÚselfÚ	__class__s    €úx/var/www/html/cool-property-finder/image-detection-backend/venv/lib/python3.11/site-packages/transformers/activations.pyr   zPytorchGELUTanh.__init__%   so   ø€ Ý‰Œ×ÒÑÔÐÝŒ=�Ô*Ñ+Ô+­g¬m¸HÑ.EÔ.EÒEÐEÝð9­Ô(9ð 9ð 9ð 9ñô ð ð FÐEó    ÚinputÚreturnc                 óD   — t           j                             |d¬¦  «        S )NÚtanh)Úapproximate)r   Ú
functionalÚgelu©r   r   s     r   ÚforwardzPytorchGELUTanh.forward-   s   € ÝŒ}×!Ò! %°VÐ!Ñ<Ô<Ð<r   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ú__classcell__©r   s   @r   r
   r
      sd   ø€ € € € € ðð ðð ð ð ð ð=˜Vð =¨ð =ð =ð =ð =ð =ð =ð =ð =r   r
   c                   ó"   — e Zd ZdZdedefd„ZdS )ÚNewGELUActivationzÆ
    Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). Also see
    the Gaussian Error Linear Units paper: https://arxiv.org/abs/1606.08415
    r   r   c                 ó²   — d|z  dt          j        t          j        dt          j        z  ¦  «        |dt          j        |d¦  «        z  z   z  ¦  «        z   z  S )Nç      à?ç      ð?ç       @ç÷Hmâä¦?g      @)r   r   ÚmathÚsqrtÚpiÚpowr   s     r   r   zNewGELUActivation.forward7   sP   € Ø�U‰{˜c¥E¤J­t¬y¸½t¼w¹Ñ/GÔ/GÈ5ÐS[Õ^cÔ^gÐhmÐorÑ^sÔ^sÑSsÑKsÑ/tÑ$uÔ$uÑuÑvÐvr   N©r!   r"   r#   r$   r   r   © r   r   r(   r(   1   sH   € € € € € ðð ð
w˜Vð w¨ð wð wð wð wð wð wr   r(   c                   óJ   ‡ — e Zd ZdZd	defˆ fd„Zdedefd„Zdedefd„Zˆ xZ	S )
ÚGELUActivationa«  
    Original Implementation of the GELU activation function in Google BERT repo when initially created. For
    information: OpenAI GPT's GELU is slightly different (and gives slightly different results): 0.5 * x * (1 +
    torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) This is now written in C in nn.functional
    Also see the Gaussian Error Linear Units paper: https://arxiv.org/abs/1606.08415
    FÚuse_gelu_pythonc                 ó”   •— t          ¦   «                              ¦   «          |r| j        | _        d S t          j        j        | _        d S ©N)r   r   Ú_gelu_pythonÚactr   r   r   )r   r6   r   s     €r   r   zGELUActivation.__init__C   s?   ø€ Ý‰Œ×ÒÑÔÐØð 	*ØÔ(ˆDŒHˆHˆHå”}Ô)ˆDŒHˆHˆHr   r   r   c                 óf   — |dz  dt          j        |t          j        d¦  «        z  ¦  «        z   z  S )Nr*   r+   r,   )r   Úerfr.   r/   r   s     r   r9   zGELUActivation._gelu_pythonJ   s-   € Ø�s‰{˜c¥E¤I¨eµd´iÀ±n´nÑ.DÑ$EÔ$EÑEÑFÐFr   c                 ó,   — |                       |¦  «        S r8   ©r:   r   s     r   r   zGELUActivation.forwardM   ó   € Ø�xŠx˜‰ŒÐr   )F)
r!   r"   r#   r$   Úboolr   r   r9   r   r%   r&   s   @r   r5   r5   ;   s�   ø€ € € € € ðð ð*ð *¨ð *ð *ð *ð *ð *ð *ðG &ð G¨Vð Gð Gð Gð Gð˜Vð ¨ð ð ð ð ð ð ð ð r   r5   c                   ó"   — e Zd ZdZdedefd„ZdS )ÚFastGELUActivationz}
    Applies GELU approximation that is slower than QuickGELU but more accurate. See: https://github.com/hendrycks/GELUs
    r   r   c                 óZ   — d|z  dt          j        |dz  dd|z  |z  z   z  ¦  «        z   z  S )Nr*   r+   g€ÑÓ3Eˆé?r-   )r   r   r   s     r   r   zFastGELUActivation.forwardV   s;   € Ø�U‰{˜c¥E¤J¨u°|Ñ/CÀsÈXÐX]ÑM]Ð`eÑMeÑGeÑ/fÑ$gÔ$gÑgÑhÐhr   Nr2   r3   r   r   rB   rB   Q   sH   € € € € € ðð ði˜Vð i¨ð ið ið ið ið ið ir   rB   c                   ó"   — e Zd ZdZdedefd„ZdS )ÚQuickGELUActivationzr
    Applies GELU approximation that is fast but somewhat inaccurate. See: https://github.com/hendrycks/GELUs
    r   r   c                 ó6   — |t          j        d|z  ¦  «        z  S )Ng¬Zd;û?)r   Úsigmoidr   s     r   r   zQuickGELUActivation.forward_   s   € Ø•u”} U¨U¡]Ñ3Ô3Ñ3Ð3r   Nr2   r3   r   r   rE   rE   Z   s@   € € € € € ðð ð4˜Vð 4¨ð 4ð 4ð 4ð 4ð 4ð 4r   rE   c                   ó<   ‡ — e Zd ZdZdedefˆ fd„Zdedefd„Zˆ xZS )ÚClippedGELUActivationa‚  
    Clip the range of possible GeLU outputs between [min, max]. This is especially useful for quantization purpose, as
    it allows mapping negatives values in the GeLU spectrum. For more information on this trick, please refer to
    https://arxiv.org/abs/2004.09602.

    Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when
    initially created.

    For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 +
    torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))). See https://arxiv.org/abs/1606.08415
    ÚminÚmaxc                 óœ   •— ||k    rt          d|› d|› d�¦  «        ‚t          ¦   «                              ¦   «          || _        || _        d S )Nzmin should be < max (got min: z, max: ú))Ú
ValueErrorr   r   rJ   rK   )r   rJ   rK   r   s      €r   r   zClippedGELUActivation.__init__p   sV   ø€ Ø�Š9ˆ9ÝÐP¸cÐPÐPÈ#ÐPÐPÐPÑQÔQÐQå‰Œ×ÒÑÔÐØˆŒØˆŒˆˆr   Úxr   c                 ó\   — t          j        t          |¦  «        | j        | j        ¦  «        S r8   )r   Úclipr   rJ   rK   )r   rO   s     r   r   zClippedGELUActivation.forwardx   s    € ÝŒz�$˜q™'œ' 4¤8¨T¬XÑ6Ô6Ð6r   )	r!   r"   r#   r$   Úfloatr   r   r   r%   r&   s   @r   rI   rI   c   sw   ø€ € € € € ð
ð 
ð˜Eð ¨ð ð ð ð ð ð ð7˜ð 7 Fð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7r   rI   c                   ó2   ‡ — e Zd ZdZˆ fd„Zdedefd„Zˆ xZS )ÚAccurateGELUActivationzÙ
    Applies GELU approximation that is faster than default and more accurate than QuickGELU. See:
    https://github.com/hendrycks/GELUs

    Implemented along with MEGA (Moving Average Equipped Gated Attention)
    c                 ó”   •— t          ¦   «                              ¦   «          t          j        dt          j        z  ¦  «        | _        d S )Né   )r   r   r.   r/   r0   Úprecomputed_constantr   s    €r   r   zAccurateGELUActivation.__init__„   s7   ø€ Ý‰Œ×ÒÑÔÐÝ$(¤I¨aµ$´'©kÑ$:Ô$:ˆÔ!Ð!Ð!r   r   r   c                 ó~   — d|z  dt          j        | j        |dt          j        |d¦  «        z  z   z  ¦  «        z   z  S )Nr*   r   r-   é   )r   r   rW   r1   r   s     r   r   zAccurateGELUActivation.forwardˆ   sC   € Ø�U‰{˜a¥%¤*¨TÔ-FÈ%ÐRZÕ]bÔ]fÐglÐnoÑ]pÔ]pÑRpÑJpÑ-qÑ"rÔ"rÑrÑsÐsr   r    r&   s   @r   rT   rT   |   sn   ø€ € € € € ðð ð;ð ;ð ;ð ;ð ;ðt˜Vð t¨ð tð tð tð tð tð tð tð tr   rT   c                   ó"   — e Zd ZdZdedefd„ZdS )ÚSiLUActivationaè  
    See Gaussian Error Linear Units (Hendrycks et al., https://arxiv.org/abs/1606.08415) where the SiLU (Sigmoid Linear
    Unit) was originally introduced and coined, and see Sigmoid-Weighted Linear Units for Neural Network Function
    Approximation in Reinforcement Learning (Elfwing et al., https://arxiv.org/abs/1702.03118) and Swish: a Self-Gated
    Activation Function (Ramachandran et al., https://arxiv.org/abs/1710.05941v1) where the SiLU was experimented with
    later.
    r   r   c                 ó@   — t           j                             |¦  «        S r8   )r   r   Úsilur   s     r   r   zSiLUActivation.forward•   s   € ÝŒ}×!Ò! %Ñ(Ô(Ð(r   Nr2   r3   r   r   r[   r[   Œ   s@   € € € € € ðð ð)˜Vð )¨ð )ð )ð )ð )ð )ð )r   r[   c                   óB   ‡ — e Zd ZdZˆ fd„Zdedefd„Zdedefd„Zˆ xZS )ÚMishActivationzÑ
    See Mish: A Self-Regularized Non-Monotonic Activation Function (Misra., https://arxiv.org/abs/1908.08681). Also
    visit the official repository for the paper: https://github.com/digantamisra98/Mish
    c                 óø   •— t          ¦   «                              ¦   «          t          j        t          j        ¦  «        t          j        d¦  «        k     r| j        | _        d S t          j	        j
        | _        d S )Nz1.9.0)r   r   r   r   r   r   Ú_mish_pythonr:   r   r   Úmishr   s    €r   r   zMishActivation.__init__Ÿ   sY   ø€ Ý‰Œ×ÒÑÔÐÝŒ=�Ô*Ñ+Ô+­g¬m¸GÑ.DÔ.DÒDÐDØÔ(ˆDŒHˆHˆHå”}Ô)ˆDŒHˆHˆHr   r   r   c                 ój   — |t          j        t          j                             |¦  «        ¦  «        z  S r8   )r   r   r   r   Úsoftplusr   s     r   ra   zMishActivation._mish_python¦   s'   € Ø•u”z¥"¤-×"8Ò"8¸Ñ"?Ô"?Ñ@Ô@Ñ@Ð@r   c                 ó,   — |                       |¦  «        S r8   r>   r   s     r   r   zMishActivation.forward©   r?   r   )	r!   r"   r#   r$   r   r   ra   r   r%   r&   s   @r   r_   r_   ™   sŒ   ø€ € € € € ðð ð
*ð *ð *ð *ð *ðA &ð A¨Vð Að Að Að Að˜Vð ¨ð ð ð ð ð ð ð ð r   r_   c                   ó"   — e Zd ZdZdedefd„ZdS )ÚLinearActivationz[
    Applies the linear activation function, i.e. forwarding input directly to output.
    r   r   c                 ó   — |S r8   r3   r   s     r   r   zLinearActivation.forward²   s   € Øˆr   Nr2   r3   r   r   rg   rg   ­   s@   € € € € € ðð ð˜Vð ¨ð ð ð ð ð ð r   rg   c                   ó   — e Zd ZdZdd„ZdS )ÚLaplaceActivationzó
    Applies elementwise activation based on Laplace function, introduced in MEGA as an attention activation. See
    https://arxiv.org/abs/2209.10655

    Inspired by squared relu, but with bounded range and gradient for better stability
    ç»¹øÛž æ?ç ^×/ØÒ?c                 ó�   — ||z
                        |t          j        d¦  «        z  ¦  «        }ddt          j        |¦  «        z   z  S )Nr,   r*   r+   )Údivr.   r/   r   r<   )r   r   ÚmuÚsigmas       r   r   zLaplaceActivation.forward¾   s@   € Ø˜‘× Ò  ­¬°3©¬Ñ!7Ñ8Ô8ˆØ�c�EœI eÑ,Ô,Ñ,Ñ-Ð-r   N)rk   rl   ©r!   r"   r#   r$   r   r3   r   r   rj   rj   ¶   s2   € € € € € ðð ð.ð .ð .ð .ð .ð .r   rj   c                   ó   — e Zd ZdZd„ ZdS )ÚReLUSquaredActivationzX
    Applies the relu^2 activation introduced in https://arxiv.org/abs/2109.08668v2
    c                 ól   — t           j                             |¦  «        }t          j        |¦  «        }|S r8   )r   r   Úrelur   Úsquare)r   r   Úrelu_appliedÚsquareds       r   r   zReLUSquaredActivation.forwardÈ   s+   € Ý”}×)Ò)¨%Ñ0Ô0ˆÝ”,˜|Ñ,Ô,ˆØˆr   Nrq   r3   r   r   rs   rs   Ã   s-   € € € € € ðð ðð ð ð ð r   rs   c                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )ÚClassInstantierc                 ó’   •— t          ¦   «                              |¦  «        }t          |t          ¦  «        r|n|i f\  }} |di |¤ŽS )Nr3   )r   Ú__getitem__Ú
isinstanceÚtuple)r   ÚkeyÚcontentÚclsÚkwargsr   s        €r   r|   zClassInstantier.__getitem__Ï   sL   ø€ Ý‘'”'×%Ò% cÑ*Ô*ˆÝ!+¨GµUÑ!;Ô!;ÐN�g�gÀ'È2À‰ˆˆVØˆsˆ}ˆ}�Vˆ}ˆ}Ðr   )r!   r"   r#   r|   r%   r&   s   @r   rz   rz   Î   s8   ø€ € € € € ðð ð ð ð ð ð ð ð r   rz   r   Úgelu_10iöÿÿÿé
   )rJ   rK   Ú	gelu_fastÚgelu_newÚgelu_pythonr6   TÚgelu_pytorch_tanhÚgelu_accurateÚlaplaceÚlinearrb   Ú
quick_geluru   Úrelu2Úrelu6rG   r]   Úswishr   c           	      ó    — | t           v rt           |          S t          d| › dt          t                                ¦   «         ¦  «        › �¦  «        ‚)Nz	function z not found in ACT2FN mapping )ÚACT2FNÚKeyErrorÚlistÚkeys)Úactivation_strings    r   Úget_activationr–   ì   sO   € Ø�FÐ"Ð"ÝÐ'Ô(Ð(åÐhÐ#4ÐhÐhÕSWÕX^×XcÒXcÑXeÔXeÑSfÔSfÐhÐhÑiÔiÐir   )*r.   Úcollectionsr   r   Ú	packagingr   r   r   Úutilsr   Ú
get_loggerr!   ÚloggerÚModuler
   r(   r5   rB   rE   rI   rT   r[   r_   rg   rj   rs   rz   ÚReLUÚReLU6ÚSigmoidÚTanhÚACT2CLSr‘   r–   r‡   r†   r   r…   rŒ   r]   rb   Ú
linear_actr3   r   r   ú<module>r£      sv  ðð €€€Ø #Ð #Ð #Ð #Ð #Ð #à €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ð 
ˆÔ	˜HÑ	%Ô	%€ð=ð =ð =ð =ð =�b”iñ =ô =ð =ð*wð wð wð wð w˜œ	ñ wô wð wðð ð ð ð �R”Yñ ô ð ð,ið ið ið ið i˜œñ iô ið ið4ð 4ð 4ð 4ð 4˜"œ)ñ 4ô 4ð 4ð7ð 7ð 7ð 7ð 7˜BœIñ 7ô 7ð 7ð2tð tð tð tð t˜RœYñ tô tð tð 
)ð 
)ð 
)ð 
)ð 
)�R”Yñ 
)ô 
)ð 
)ðð ð ð ð �R”Yñ ô ð ð(ð ð ð ð �r”yñ ô ð ð
.ð 
.ð 
.ð 
.ð 
.˜œ	ñ 
.ô 
.ð 
.ðð ð ð ð ˜BœIñ ô ð ðð ð ð ð �kñ ô ð ðØ
ˆNðàÐ%¨s¸2Ð'>Ð'>Ð?ðð Ð#ðð Ð!ð	ð
 �NÐ%6¸Ð$=Ð>ðð ˜ðð Ð+ðð Ð ðð Ððð ˆNðð Ð%ðð ˆBŒGðð Ð"ðð ˆRŒXðð ˆrŒzðð  ˆNð!ð" ˆ^ð#ð$ ˆBŒGð%ð €ð( 
ˆ˜Ñ	!Ô	!€ðjð jð jð ˆn˜]Ñ+Ô+€Øˆ>˜*Ñ%Ô%€Ø€~�fÑÔ€ØˆN˜;Ñ'Ô'€	Øˆ^˜LÑ)Ô)€
Ø€~�fÑÔ€Ø€~�fÑÔ€Øˆ^˜HÑ%Ô%€
€
€
r   