§
    ŠŠtj*  ã                   ó  — U d dl mZmZ d dlmZ d dlmZmZmZm	Z	m
Z
 d dlZd dlmc mZ d dlmZmZ d dlmZ d dlmZmZmZmZ dZee         ed	<   g d
¢Zdeez  deedf         fd„Zdeeez           dedz  dedz  defd„Z dededefd„Z!d+dede"defd„Z#dedefd„Z$d+dede"defd„Z% e
dd¬¦  «        Z& e
d d¬!¦  «        Z' G d"„ d#ee&e'f         ¦  «        Z( G d$„ d%e(e&e'f         e)¦  «        Z*d,d&ed'edefd(„Z+d,d)ed'edefd*„Z,dS )-é    )ÚCallableÚSequence)Úupdate_wrapper)ÚAnyÚFinalÚGenericÚoverloadÚTypeVarN)ÚSymIntÚTensor©Úis_tensor_like)Ú_dtypeÚ_NumberÚDeviceÚNumberg¶oüŒxâ?Úeuler_constant)Úbroadcast_allÚlogits_to_probsÚclamp_probsÚprobs_to_logitsÚlazy_propertyÚtril_matrix_to_vecÚvec_to_tril_matrixÚvaluesÚreturn.c                  ó”  ‡— t          d„ | D ¦   «         ¦  «        st          d¦  «        ‚t          d„ | D ¦   «         ¦  «        syt          t          j        ¦   «         ¬¦  «        Š| D ]9}t          |t          j        ¦  «        rt          |j        |j        ¬¦  «        Š nŒ:ˆfd„| D ¦   «         }t          j	        |Ž S t          j	        | Ž S )aÌ  
    Given a list of values (possibly containing numbers), returns a list where each
    value is broadcasted based on the following rules:

    - `torch.*Tensor` instances are broadcasted as per :ref:`broadcasting-semantics`.
    - Number instances (scalars) are upcast to tensors having
      the same size and type as the first tensor passed to `values`.  If all the
      values are scalars, then they are upcasted to scalar Tensors.

    Args:
        values (list of `Number`, `torch.*Tensor` or objects implementing __torch_function__)

    Raises:
        ValueError: if any of the values is not a `Number` instance,
            a `torch.*Tensor` instance, or an instance implementing __torch_function__
    c              3   ó^   K  — | ](}t          |¦  «        pt          |t          ¦  «        V — Œ)d S ©N)r   Ú
isinstancer   ©Ú.0Úvs     úW/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/distributions/utils.pyú	<genexpr>z broadcast_all.<locals>.<genexpr>,   s9   è è € ÐKÐK¸q�~˜aÑ Ô Ð:¥J¨qµ'Ñ$:Ô$:ÐKÐKÐKÐKÐKÐKó    ziInput arguments must all be instances of Number, torch.Tensor or objects implementing __torch_function__.c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r   r   r!   s     r$   r%   z broadcast_all.<locals>.<genexpr>1   s*   è è € Ð1Ð1 Q�~˜aÑ Ô Ð1Ð1Ð1Ð1Ð1Ð1r&   )Údtype©r(   Údevicec                 óV   •— g | ]%}t          |¦  «        r|nt          j        |fi ‰¤Ž‘Œ&S © )r   ÚtorchÚtensor)r"   r#   Úoptionss     €r$   ú
<listcomp>z!broadcast_all.<locals>.<listcomp>7   sI   ø€ ð 
ð 
ð 
ØGH• Ñ"Ô"ÐBˆAˆA­¬°QÐ(BÐ(B¸'Ð(BÐ(Bð
ð 
ð 
r&   )
ÚallÚ
ValueErrorÚdictr-   Úget_default_dtyper    r   r(   r*   Úbroadcast_tensors)r   ÚvalueÚ
new_valuesr/   s      @r$   r   r      sÿ   ø€ õ" ÐKÐKÀFÐKÑKÔKÑKÔKð 
ÝðGñ
ô 
ð 	
õ Ð1Ð1¨&Ð1Ñ1Ô1Ñ1Ô1ð 	4Ý"&­UÔ-DÑ-FÔ-FÐ"GÑ"GÔ"GˆØð 	ð 	ˆEÝ˜%¥¤Ñ.Ô.ð Ý U¤[¸¼ÐFÑFÔF�Ø�ðð
ð 
ð 
ð 
ØLRð
ñ 
ô 
ˆ
õ Ô&¨
Ð3Ð3ÝÔ" FÐ+Ð+r&   Úshaper(   r*   c                 ó  — t           j                             ¦   «         r?t          j        t          j        | ||¬¦  «        t          j        | ||¬¦  «        ¦  «        S t          j        | ||¬¦  «                             ¦   «         S )Nr)   )r-   Ú_CÚ_get_tracing_stateÚnormalÚzerosÚonesÚemptyÚnormal_)r8   r(   r*   s      r$   Ú_standard_normalrA   >   s{   € õ
 „x×"Ò"Ñ$Ô$ð 
åŒ|ÝŒK˜ U°6Ð:Ñ:Ô:ÝŒJ�u E°&Ð9Ñ9Ô9ñ
ô 
ð 	
õ Œ;�u E°&Ð9Ñ9Ô9×AÒAÑCÔCÐCr&   r6   Údimc                 óˆ   — |dk    r| S | j         d| …         dz   }|                      |¦  «                             d¦  «        S )zÎ
    Sum out ``dim`` many rightmost dimensions of a given tensor.

    Args:
        value (Tensor): A tensor of ``.dim()`` at least ``dim``.
        dim (int): The number of rightmost dims to sum out.
    r   N)éÿÿÿÿrD   )r8   ÚreshapeÚsum)r6   rB   Úrequired_shapes      r$   Ú_sum_rightmostrH   L   sI   € ð ˆa‚x€xØˆØ”[  3 $ Ô'¨%Ñ/€NØ�=Š=˜Ñ(Ô(×,Ò,¨RÑ0Ô0Ð0r&   FÚlogitsÚ	is_binaryc                 óZ   — |rt          j        | ¦  «        S t          j        | d¬¦  «        S )a  
    Converts a tensor of logits into probabilities. Note that for the
    binary case, each value denotes log odds, whereas for the
    multi-dimensional case, the values along the last dimension denote
    the log probabilities (possibly unnormalized) of the events.
    rD   )rB   )r-   ÚsigmoidÚFÚsoftmax)rI   rJ   s     r$   r   r   Z   s1   € ð ð %ÝŒ}˜VÑ$Ô$Ð$ÝŒ9�V Ð$Ñ$Ô$Ð$r&   Úprobsc                 ór   — t          j        | j        ¦  «        j        }|                      |d|z
  ¬¦  «        S )a   Clamps the probabilities to be in the open interval `(0, 1)`.

    The probabilities would be clamped between `eps` and `1 - eps`,
    and `eps` would be the smallest representable positive number for the input data type.

    Args:
        probs (Tensor): A tensor of probabilities.

    Returns:
        Tensor: The clamped probabilities.

    Examples:
        >>> probs = torch.tensor([0.0, 0.5, 1.0])
        >>> clamp_probs(probs)
        tensor([1.1921e-07, 5.0000e-01, 1.0000e+00])

        >>> probs = torch.tensor([0.0, 0.5, 1.0], dtype=torch.float64)
        >>> clamp_probs(probs)
        tensor([2.2204e-16, 5.0000e-01, 1.0000e+00], dtype=torch.float64)

    é   )ÚminÚmax)r-   Úfinfor(   ÚepsÚclamp)rO   rU   s     r$   r   r   f   s2   € õ, Œ+�e”kÑ
"Ô
"Ô
&€CØ�;Š;˜3 A¨¡Gˆ;Ñ,Ô,Ð,r&   c                 ó    — t          | ¦  «        }|r*t          j        |¦  «        t          j        | ¦  «        z
  S t          j        |¦  «        S )a$  
    Converts a tensor of probabilities into logits. For the binary case,
    this denotes the probability of occurrence of the event indexed by `1`.
    For the multi-dimensional case, the values along the last dimension
    denote the probabilities of occurrence of each of the events.
    )r   r-   ÚlogÚlog1p)rO   rJ   Ú
ps_clampeds      r$   r   r   €   sK   € õ ˜UÑ#Ô#€JØð @ÝŒy˜Ñ$Ô$¥u¤{°J°;Ñ'?Ô'?Ñ?Ð?ÝŒ9�ZÑ Ô Ð r&   ÚTT)ÚcontravariantÚR)Ú	covariantc                   ó    — e Zd ZdZdeegef         ddfd„Ze	 dddde	ddfd	„¦   «         Z
eddede	defd
„¦   «         Z
	 ddedz  de	ddfd„Z
dS )r   zø
    Used as a decorator for lazy loading of class attributes. This uses a
    non-data descriptor that calls the wrapped method to compute the property on
    first call; thereafter replacing the wrapped method into an instance
    attribute.
    Úwrappedr   Nc                 ó4   — || _         t          | |¦  «         d S r   )r`   r   ©Úselfr`   s     r$   Ú__init__zlazy_property.__init__™   s   € Ø)0ˆŒÝ�t˜WÑ%Ô%Ð%Ð%Ð%r&   ÚinstanceÚobj_typez!_lazy_property_and_property[T, R]c                 ó   — d S r   r,   ©rc   re   rf   s      r$   Ú__get__zlazy_property.__get__�   s	   € ð /2¨cr&   c                 ó   — d S r   r,   rh   s      r$   ri   zlazy_property.__get__¢   s   € Ø?B¸sr&   z%R | _lazy_property_and_property[T, R]c                 óè   — |€t          | j        ¦  «        S t          j        ¦   «         5  |                      |¦  «        }d d d ¦  «         n# 1 swxY w Y   t	          || j        j        |¦  «         |S r   )Ú_lazy_property_and_propertyr`   r-   Úenable_gradÚsetattrÚ__name__)rc   re   rf   r6   s       r$   ri   zlazy_property.__get__¥   s«   € ð ÐÝ.¨t¬|Ñ<Ô<Ð<ÝÔÑ Ô ð 	+ð 	+Ø—L’L Ñ*Ô*ˆEð	+ð 	+ð 	+ñ 	+ô 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+øøøð 	+ð 	+ð 	+ð 	+å�˜$œ,Ô/°Ñ7Ô7Ð7Øˆs   ªAÁAÁAr   )ro   Ú
__module__Ú__qualname__Ú__doc__r   r[   r]   rd   r	   r   ri   r,   r&   r$   r   r   ‘   sï   € € € € € ðð ð& ¨!¨¨a¨Ô 0ð &°Tð &ð &ð &ð &ð à.2ð2ð 2Øð2Ø(+ð2à	,ð2ð 2ð 2ñ „Xð2ð ØBÐB ÐB¨SÐB¸AÐBÐBÐBñ „XØBð 37ðð Ø˜D™ðØ,/ðà	0ðð ð ð ð ð r&   r   c                   ó4   — e Zd ZdZdeegef         ddfd„ZdS )rl   zžWe want lazy properties to look like multiple things.

    * property when Sphinx autodoc looks
    * lazy_property when Distribution validate_args looks
    r`   r   Nc                 ó<   — t                                | |¦  «         d S r   )Úpropertyrd   rb   s     r$   rd   z$_lazy_property_and_property.__init__·   s   € Ý×Ò˜$ Ñ(Ô(Ð(Ð(Ð(r&   )ro   rp   rq   rr   r   r[   r]   rd   r,   r&   r$   rl   rl   °   sK   € € € € € ðð ð) ¨!¨¨a¨Ô 0ð )°Tð )ð )ð )ð )ð )ð )r&   rl   ÚmatÚdiagc           	      ó:  — | j         d         }t          j                             ¦   «         s*|| k     s||k    rt	          d|› d| › d|dz
  › d�¦  «        ‚t          j        || j        ¬¦  «        }||                     dd¦  «        |dz   z   k     }| d|f         }|S )	z 
    Convert a `D x D` matrix or a batch of matrices into a (batched) vector
    which comprises of lower triangular elements from the matrix in row order.
    rD   zdiag (z) provided is outside [z, rQ   z].©r*   .)r8   r-   r:   r;   r2   Úaranger*   Úview)rv   rw   Únrz   Ú	tril_maskÚvecs         r$   r   r   »   s²   € ð
 	Œ	�"Œ€AÝŒ8×&Ò&Ñ(Ô(ð P¨d°a°Rªi¨i¸4À1º9¸9ÝÐN $ÐNÐNÀ¸rÐNÐNÀQÈÁUÐNÐNÐNÑOÔOÐOÝŒ\˜! C¤JÐ/Ñ/Ô/€FØ˜Ÿš R¨Ñ+Ô+¨t°a©xÑ8Ò8€IØ
ˆc�9ˆnÔ
€CØ€Jr&   r~   c                 ó   — dd|z  z    dd|z  z   dz  d| j         d         z  z   dt          |¦  «        z  |dz   z  z   dz  z   dz  }t          j        | j        ¦  «        j        }t          j                             ¦   «         s7t          |¦  «        |z
  |k    r!t          d| j         d         › d�d	z   ¦  «        ‚t          |t          j        ¦  «        r!t          |                     ¦   «         ¦  «        nt          |¦  «        }|                      | j         d
d…         t          j        ||f¦  «        z   ¦  «        }t          j        || j        ¬¦  «        }||                     dd¦  «        |dz   z   k     }| |d|f<   |S )z•
    Convert a vector or a batch of vectors into a batched `D x D`
    lower triangular matrix containing elements from the vector in row order.
    rQ   é   é   rD   é   g      à?zThe size of last dimension is z which cannot be expressed as z3the lower triangular part of a square D x D matrix.Nry   .)r8   Úabsr-   rT   r(   rU   r:   r;   Úroundr2   r    r   ÚitemÚ	new_zerosÚSizerz   r*   r{   )r~   rw   r|   rU   rv   rz   r}   s          r$   r   r   É   sv  € ð ˆa�$‰h‰,ˆØ��D‘‰L˜QÑ  S¤Y¨r¤]Ñ!2Ñ2°Q½¸T¹¼±]ÀdÈQÁhÑ5OÑOÐTWÑ
Wñ	Xà	ñ	
€Aõ Œ+�c”iÑ
 Ô
 Ô
$€CÝŒ8×&Ò&Ñ(Ô(ð 
­e°A©h¬h¸©l¸SÒ.@Ð.@ÝØZ¨S¬Y°r¬]ÐZÐZÐZØCñDñ
ô 
ð 	
õ & a­¬Ñ6Ô6ÐD�ˆa�fŠf‰hŒh‰Œˆ½EÀ!¹H¼H€AØ
�-Š-˜œ	 # 2 #œ­¬°Q¸°FÑ);Ô);Ñ;Ñ
<Ô
<€CÝŒ\˜! C¤JÐ/Ñ/Ô/€FØ˜Ÿš R¨Ñ+Ô+¨t°a©xÑ8Ò8€IØ€CˆˆYˆÑØ€Jr&   )F)r   )-Úcollections.abcr   r   Ú	functoolsr   Útypingr   r   r   r	   r
   r-   Útorch.nn.functionalÚnnÚ
functionalrM   r   r   Útorch.overridesr   Útorch.typesr   r   r   r   r   ÚfloatÚ__annotations__Ú__all__Útupler   ÚintrA   rH   Úboolr   r   r   r[   r]   r   ru   rl   r   r   r,   r&   r$   ú<module>r–      s  ðØ .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø $Ð $Ð $Ð $Ð $Ð $Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9à €€€Ø Ð Ð Ð Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  Ø *Ð *Ð *Ð *Ð *Ð *Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7ð  6€��e”Ð 5Ð 5Ñ 5ðð ð €ð ,˜6 F™?ð  ,¨u°V¸S°[Ô/Að  ,ð  ,ð  ,ð  ,ðFDØ�C˜&‘LÔ!ðDà�D‰=ðDð �T‰MðDð ð	Dð Dð Dð Dð1˜&ð 1 sð 1¨vð 1ð 1ð 1ð 1ð	%ð 	%˜Fð 	%¨tð 	%Àð 	%ð 	%ð 	%ð 	%ð-�vð - &ð -ð -ð -ð -ð4
!ð 
!˜6ð 
!¨dð 
!¸vð 
!ð 
!ð 
!ð 
!ð €GˆC˜tÐ$Ñ$Ô$€Ø€GˆC˜4Ð Ñ Ô €ðð ð ð ð �G˜A˜q˜D”Mñ ô ð ð>)ð )ð )ð )ð ) -°°1°Ô"5°xñ )ô )ð )ðð ˜Fð ¨#ð °fð ð ð ð ðð ˜Fð ¨#ð °fð ð ð ð ð ð r&   