§
    ‚Štj8  ã                   ó$  — d Z ddlmZ ddlZddlmZ ddlmZmZmZm	Z	m
Z
mZmZ  G d„ de¦  «        Z G d„ d	ej        ¦  «        Z G d
„ dej        ¦  «        Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )z:
Time series distributional output classes and utilities.
é    )ÚCallableN)Únn)ÚAffineTransformÚDistributionÚIndependentÚNegativeBinomialÚNormalÚStudentTÚTransformedDistributionc                   óh   ‡ — e Zd Zddefˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zˆ xZ	S )	ÚAffineTransformedNr   Úbase_distributionc                 ó®   •— |€dn|| _         |€dn|| _        t          ¦   «                              |t	          | j        | j         |¬¦  «        g¦  «         d S )Ng      ð?ç        ©ÚlocÚscaleÚ	event_dim)r   r   ÚsuperÚ__init__r   )Úselfr   r   r   r   Ú	__class__s        €ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/time_series_utils.pyr   zAffineTransformed.__init__#   s[   ø€ Ø!˜M�S�S¨uˆŒ
Ø˜+�3�3¨3ˆŒå‰Œ×ÒÐ*­_ÀÄÐQUÔQ[ÐgpÐ-qÑ-qÔ-qÐ,rÑsÔsÐsÐsÐsó    c                 ó:   — | j         j        | j        z  | j        z   S )z7
        Returns the mean of the distribution.
        )Ú	base_distÚmeanr   r   ©r   s    r   r   zAffineTransformed.mean)   s   € ð
 Œ~Ô" T¤ZÑ/°$´(Ñ:Ð:r   c                 ó0   — | j         j        | j        dz  z  S )z;
        Returns the variance of the distribution.
        é   )r   Úvariancer   r   s    r   r!   zAffineTransformed.variance0   s   € ð
 Œ~Ô&¨¬°Q©Ñ6Ð6r   c                 ó4   — | j                              ¦   «         S )zE
        Returns the standard deviation of the distribution.
        )r!   Úsqrtr   s    r   ÚstddevzAffineTransformed.stddev7   s   € ð
 Œ}×!Ò!Ñ#Ô#Ð#r   )NNr   )
Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr   r!   r$   Ú__classcell__©r   s   @r   r   r   "   s¢   ø€ € € € € ðtð t¨,ð tð tð tð tð tð tð ð;ð ;ñ „Xð;ð ð7ð 7ñ „Xð7ð ð$ð $ñ „Xð$ð $ð $ð $ð $r   r   c            	       ó–   ‡ — e Zd Zdedeeef         dedeej	                 f         ddfˆ fd„Z
dej	        deej	                 fd	„Zˆ xZS )
ÚParameterProjectionÚin_featuresÚargs_dimÚ
domain_map.ÚreturnNc                 óÆ   •‡—  t          ¦   «         j        di |¤Ž || _        t          j        ˆfd„|                     ¦   «         D ¦   «         ¦  «        | _        || _        d S )Nc                 ó:   •— g | ]}t          j        ‰|¦  «        ‘ŒS © )r   ÚLinear)Ú.0Údimr-   s     €r   ú
<listcomp>z0ParameterProjection.__init__.<locals>.<listcomp>E   s%   ø€ Ð"\Ð"\Ð"\À3¥2¤9¨[¸#Ñ#>Ô#>Ð"\Ð"\Ð"\r   r3   )r   r   r.   r   Ú
ModuleListÚvaluesÚprojr/   )r   r-   r.   r/   Úkwargsr   s    `   €r   r   zParameterProjection.__init__@   se   øø€ ð 	�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Ø ˆŒÝ”MÐ"\Ð"\Ð"\Ð"\È(Ï/Ê/ÑJ[ÔJ[Ð"\Ñ"\Ô"\Ñ]Ô]ˆŒ	Ø$ˆŒˆˆr   Úxc                 ó>   ‡— ˆfd„| j         D ¦   «         } | j        |Ž S )Nc                 ó&   •— g | ]} |‰¦  «        ‘ŒS r3   r3   )r5   r:   r<   s     €r   r7   z/ParameterProjection.forward.<locals>.<listcomp>I   s!   ø€ Ð:Ð:Ð:¨˜D˜D ™GœGÐ:Ð:Ð:r   )r:   r/   )r   r<   Úparams_unboundeds    ` r   ÚforwardzParameterProjection.forwardH   s/   ø€ Ø:Ð:Ð:Ð:°´	Ð:Ñ:Ô:ÐàˆtŒÐ 0Ð1Ð1r   )r%   r&   r'   ÚintÚdictÚstrr   ÚtupleÚtorchÚTensorr   r@   r)   r*   s   @r   r,   r,   ?   s¤   ø€ € € € € ð%Øð%Ø*.¨s°C¨x¬.ð%ØFNÈsÐTYÐZ_ÔZfÔTgÐOgÔFhð%à	ð%ð %ð %ð %ð %ð %ð2˜œð 2¨%°´Ô*=ð 2ð 2ð 2ð 2ð 2ð 2ð 2ð 2r   r,   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLambdaLayerc                 óV   •— t          ¦   «                              ¦   «          || _        d S ©N)r   r   Úfunction)r   rK   r   s     €r   r   zLambdaLayer.__init__O   s$   ø€ Ý‰Œ×ÒÑÔÐØ ˆŒˆˆr   c                 ó   —  | j         |g|¢R Ž S rJ   )rK   )r   r<   Úargss      r   r@   zLambdaLayer.forwardS   s   € ØˆtŒ}˜QÐ& Ð&Ð&Ð&Ð&r   )r%   r&   r'   r   r@   r)   r*   s   @r   rH   rH   N   sG   ø€ € € € € ð!ð !ð !ð !ð !ð'ð 'ð 'ð 'ð 'ð 'ð 'r   rH   c                   óH  — e Zd ZU eed<   eed<   eeef         ed<   ddeddfd„Zd	„ Z		 	 dd
e
j        dz  de
j        dz  defd„Zedefd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zdedej        fd„Zde
j        fd„Zede
j        de
j        fd„¦   «         ZdS )ÚDistributionOutputÚdistribution_classr-   r.   é   r6   r0   Nc                 óJ   ‡ ‡— ‰‰ _         ˆˆ fd„‰ j        D ¦   «         ‰ _        d S )Nc                 ó2   •— i | ]}|‰‰j         |         z  “ŒS r3   )r.   )r5   Úkr6   r   s     €€r   ú
<dictcomp>z/DistributionOutput.__init__.<locals>.<dictcomp>^   s'   ø€ ÐJÐJÐJ°q˜˜C $¤-°Ô"2Ñ2ÐJÐJÐJr   )r6   r.   )r   r6   s   ``r   r   zDistributionOutput.__init__\   s/   øø€ ØˆŒØJÐJÐJÐJÐJ¸D¼MÐJÑJÔJˆŒˆˆr   c                 ó\   — | j         dk    r
 | j        |Ž S t           | j        |Ž d¦  «        S )NrQ   ©r6   rP   r   )r   Ú
distr_argss     r   Ú_base_distributionz%DistributionOutput._base_distribution`   s8   € ØŒ8�qŠ=ˆ=Ø*�4Ô*¨JÐ7Ð7åÐ6˜tÔ6¸
ÐCÀQÑGÔGÐGr   r   r   c                 óh   — |                       |¦  «        }|€|€|S t          |||| j        ¬¦  «        S )Nr   )rY   r   r   )r   rX   r   r   Údistrs        r   ÚdistributionzDistributionOutput.distributionf   s>   € ð ×'Ò'¨
Ñ3Ô3ˆØˆ;˜5˜=ØˆLå$ U°¸5ÈDÌNÐ[Ñ[Ô[Ð[r   c                 ó,   — | j         dk    rdn| j         fS )zo
        Shape of each individual event contemplated by the distributions that this object constructs.
        rQ   r3   )r6   r   s    r   Úevent_shapezDistributionOutput.event_shaper   s   € ð
 ”X ’]�]ˆrˆr¨¬¨Ð3r   c                 ó*   — t          | j        ¦  «        S )z�
        Number of event dimensions, i.e., length of the `event_shape` tuple, of the distributions that this object
        constructs.
        )Úlenr^   r   s    r   r   zDistributionOutput.event_dimy   s   € õ �4Ô#Ñ$Ô$Ð$r   c                 ó   — dS )zÇ
        A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By
        default 0.0. This value will be used when padding data series.
        r   r3   r   s    r   Úvalue_in_supportz#DistributionOutput.value_in_support�   s	   € ð ˆsr   c                 óT   — t          || j        t          | j        ¦  «        ¬¦  «        S )z~
        Return the parameter projection layer that maps the input to the appropriate parameters of the distribution.
        )r-   r.   r/   )r,   r.   rH   r/   )r   r-   s     r   Úget_parameter_projectionz+DistributionOutput.get_parameter_projection‰   s0   € õ #Ø#Ø”]Ý" 4¤?Ñ3Ô3ð
ñ 
ô 
ð 	
r   rM   c                 ó   — t          ¦   «         ‚)a  
        Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the
        correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a
        distribution of the right event_shape.
        )ÚNotImplementedError)r   rM   s     r   r/   zDistributionOutput.domain_map“   s   € õ "Ñ#Ô#Ð#r   r<   c                 ó`   — | t          j        t          j        | ¦  «        dz   ¦  «        z   dz  S )z²
        Helper to map inputs to the positive orthant by applying the square-plus operation. Reference:
        https://twitter.com/jon_barron/status/1387167648669048833
        g      @ç       @)rE   r#   Úsquare)r<   s    r   Ú
squarepluszDistributionOutput.squareplus›   s+   € ð •E”J�uœ|¨A™œ°Ñ4Ñ5Ô5Ñ5¸Ñ<Ð<r   )rQ   ©NN)r%   r&   r'   ÚtypeÚ__annotations__rA   rB   rC   r   rY   rE   rF   r   r\   r(   rD   r^   r   Úfloatrb   r   ÚModulerd   r/   Ústaticmethodrj   r3   r   r   rO   rO   W   s¿  € € € € € € ØÐÐÑØÐÐÑØ�3˜�8ŒnÐÐÑðKð K˜Cð K¨ð Kð Kð Kð KðHð Hð Hð $(Ø%)ð	
\ð 
\ð Œ\˜DÑ ð
\ð Œ|˜dÑ"ð	
\ð
 
ð
\ð 
\ð 
\ð 
\ð ð4˜Uð 4ð 4ð 4ñ „Xð4ð ð%˜3ð %ð %ð %ñ „Xð%ð ð %ð ð ð ñ „Xðð
°Cð 
¸B¼Ið 
ð 
ð 
ð 
ð$ ¤ð $ð $ð $ð $ð ð=�e”lð = u¤|ð =ð =ð =ñ „\ð=ð =ð =r   rO   c                   óŠ   — e Zd ZU dZddddœZeeef         ed<   e	Z
eed<   edej        dej        dej        fd	„¦   «         Zd
S )ÚStudentTOutputz.
    Student-T distribution output class.
    rQ   )Údfr   r   r.   rP   rs   r   r   c                 ó6  — |                       |¦  «                             t          j        |j        ¦  «        j        ¦  «        }d|                       |¦  «        z   }|                     d¦  «        |                     d¦  «        |                     d¦  «        fS )Nrh   éÿÿÿÿ©rj   Ú	clamp_minrE   ÚfinfoÚdtypeÚepsÚsqueeze)Úclsrs   r   r   s       r   r/   zStudentTOutput.domain_map¬   ss   € à—’˜uÑ%Ô%×/Ò/µ´¸E¼KÑ0HÔ0HÔ0LÑMÔMˆØ�3—>’> "Ñ%Ô%Ñ%ˆØ�zŠz˜"‰~Œ~˜sŸ{š{¨2™œ°·²¸bÑ0AÔ0AÐAÐAr   N)r%   r&   r'   Ú__doc__r.   rB   rC   rA   rm   r
   rP   rl   ÚclassmethodrE   rF   r/   r3   r   r   rr   rr   ¤   s—   € € € € € € ðð ð '(°¸AÐ>Ð>€Hˆd�3˜�8ŒnÐ>Ð>Ñ>Ø'Ð˜Ð'Ð'Ñ'àðB˜EœLð B¨u¬|ð BÀEÄLð Bð Bð Bñ „[ðBð Bð Br   rr   c                   óz   — e Zd ZU dZdddœZeeef         ed<   e	Z
eed<   edej        dej        fd„¦   «         Zd	S )
ÚNormalOutputz+
    Normal distribution output class.
    rQ   )r   r   r.   rP   r   r   c                 óÞ   — |                       |¦  «                             t          j        |j        ¦  «        j        ¦  «        }|                     d¦  «        |                     d¦  «        fS ©Nru   rv   )r|   r   r   s      r   r/   zNormalOutput.domain_map»   sQ   € à—’˜uÑ%Ô%×/Ò/µ´¸E¼KÑ0HÔ0HÔ0LÑMÔMˆØ�{Š{˜2‰Œ §¢¨bÑ 1Ô 1Ð1Ð1r   N)r%   r&   r'   r}   r.   rB   rC   rA   rm   r	   rP   rl   r~   rE   rF   r/   r3   r   r   r€   r€   ³   sƒ   € € € € € € ðð ð ()°1Ð5Ð5€Hˆd�3˜�8ŒnÐ5Ð5Ñ5Ø%Ð˜Ð%Ð%Ñ%àð2˜Uœ\ð 2°%´,ð 2ð 2ð 2ñ „[ð2ð 2ð 2r   r€   c                   ó¾   — e Zd ZU dZdddœZeeef         ed<   e	Z
eed<   edej        dej        fd„¦   «         Zd	efd
„Z	 ddej        dz  dej        dz  d	efd„ZdS )ÚNegativeBinomialOutputz6
    Negative Binomial distribution output class.
    rQ   ©Útotal_countÚlogitsr.   rP   r†   r‡   c                 ó€   — |                       |¦  «        }|                     d¦  «        |                     d¦  «        fS r‚   )rj   r{   )r|   r†   r‡   s      r   r/   z!NegativeBinomialOutput.domain_mapÉ   s8   € à—n’n [Ñ1Ô1ˆØ×"Ò" 2Ñ&Ô&¨¯ª°rÑ(:Ô(:Ð:Ð:r   r0   c                 óš   — |\  }}| j         dk    r|                      ||¬¦  «        S t          |                      ||¬¦  «        d¦  «        S )NrQ   r…   rW   )r   rX   r†   r‡   s       r   rY   z)NegativeBinomialOutput._base_distributionÎ   sU   € Ø(Ñˆ�VØŒ8�qŠ=ˆ=Ø×*Ò*°{È6Ð*ÑRÔRÐRå˜t×6Ò6À;ÐW]Ð6Ñ^Ô^Ð`aÑbÔbÐbr   Nr   r   c                 ól   — |\  }}|�||                      ¦   «         z  }|                      ||f¦  «        S rJ   )ÚlogrY   )r   rX   r   r   r†   r‡   s         r   r\   z#NegativeBinomialOutput.distributionØ   s?   € ð )Ñˆ�VàÐà�e—i’i‘k”kÑ!ˆFà×&Ò&¨°VÐ'<Ñ=Ô=Ð=r   rk   )r%   r&   r'   r}   r.   rB   rC   rA   rm   r   rP   rl   r~   rE   rF   r/   r   rY   r\   r3   r   r   r„   r„   Á   sê   € € € € € € ðð ð 01¸AÐ>Ð>€Hˆd�3˜�8ŒnÐ>Ð>Ñ>Ø/Ð˜Ð/Ð/Ñ/àð; U¤\ð ;¸5¼<ð ;ð ;ð ;ñ „[ð;ðc°ð cð cð cð cð Y]ð	>ð 	>Ø$œ|¨dÑ2ð	>ØBGÄ,ÐQUÑBUð	>à	ð	>ð 	>ð 	>ð 	>ð 	>ð 	>r   r„   )r}   Úcollections.abcr   rE   r   Útorch.distributionsr   r   r   r   r	   r
   r   r   ro   r,   rH   rO   rr   r€   r„   r3   r   r   ú<module>rŽ      sß  ððð ð %Ð $Ð $Ð $Ð $Ð $à €€€Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð$ð $ð $ð $ð $Ð/ñ $ô $ð $ð:2ð 2ð 2ð 2ð 2˜"œ)ñ 2ô 2ð 2ð'ð 'ð 'ð 'ð '�"”)ñ 'ô 'ð 'ðJ=ð J=ð J=ð J=ð J=ñ J=ô J=ð J=ðZBð Bð Bð Bð BÐ'ñ Bô Bð Bð2ð 2ð 2ð 2ð 2Ð%ñ 2ô 2ð 2ð >ð  >ð  >ð  >ð  >Ð/ñ  >ô  >ð  >ð  >ð  >r   