§
    ®˜ºh[  ã                   ó>  — U d dl mZ d dlmZ d dlmZmZmZ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ef         deedf         fd„Z deee!ef                  de	e         de	e         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 )-é    )ÚSequence)Úupdate_wrapper)ÚAnyÚCallableÚFinalÚGenericÚOptionalÚoverloadÚTypeVarÚUnionN)Ú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     úa/var/www/html/services/rag-service/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>0   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>6   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_valuesr1   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_)r:   r*   r,   s      r&   Ú_standard_normalrC   =   s{   € õ
 „x×"Ò"Ñ$Ô$ð 
åŒ|ÝŒK˜ U°6Ð:Ñ:Ô:ÝŒJ�u E°&Ð9Ñ9Ô9ñ
ô 
ð 	
õ Œ;�u E°&Ð9Ñ9Ô9×AÒAÑCÔCÐCr(   r8   Ú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)éÿÿÿÿrF   )r:   ÚreshapeÚsum)r8   rD   Úrequired_shapes      r&   Ú_sum_rightmostrJ   K   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.
    rF   )rD   )r/   ÚsigmoidÚFÚsoftmax)rK   rL   s     r&   r   r   Y   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)rQ   rW   s     r&   r   r   e   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)rQ   rL   Ú
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edf         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!   )rb   r   ©Úselfrb   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.   ©re   rg   rh   s      r&   Ú__get__zlazy_property.__get__œ   s	   € ð /2¨cr(   c                 ó   — d S r!   r.   rj   s      r&   rk   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_propertyrb   r/   Úenable_gradÚsetattrÚ__name__)re   rg   rh   r8   s       r&   rk   zlazy_property.__get__¤   s«   € ð ÐÝ.¨t¬|Ñ<Ô<Ð<ÝÔÑ Ô ð 	+ð 	+Ø—L’L Ñ*Ô*ˆEð	+ð 	+ð 	+ñ 	+ô 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+øøøð 	+ð 	+ð 	+ð 	+å�˜$œ,Ô/°Ñ7Ô7Ð7Øˆs   ªAÁAÁAr!   )rq   Ú
__module__Ú__qualname__Ú__doc__r   r]   r_   rf   r
   r   rk   r   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ð 9=ðð Ø˜a ˜gœðØ25ðà	0ðð ð ð ð ð r(   r   c                   ó4   — e Zd ZdZdeegef         ddfd„ZdS )rn   zžWe want lazy properties to look like multiple things.

    * property when Sphinx autodoc looks
    * lazy_property when Distribution validate_args looks
    rb   r   Nc                 ó<   — t                                | |¦  «         d S r!   )Úpropertyrf   rd   s     r&   rf   z$_lazy_property_and_property.__init__¶   s   € Ý×Ò˜$ Ñ(Ô(Ð(Ð(Ð(r(   )rq   rr   rs   rt   r   r]   r_   rf   r.   r(   r&   rn   rn   ¯   sK   € € € € € ðð ð) ¨!¨¨a¨Ô 0ð )°Tð )ð )ð )ð )ð )ð )r(   rn   Ú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.
    rF   zdiag (z) provided is outside [z, rS   z].©r,   .)r:   r/   r<   r=   r4   Úaranger,   Úview)rx   ry   Únr|   Ú	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.
    rS   é   é   rF   é   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.Nr{   .)r:   Úabsr/   rV   r*   rW   r<   r=   Úroundr4   r"   r   ÚitemÚ	new_zerosÚSizer|   r,   r}   )r€   ry   r~   rW   rx   r|   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   Ú	functoolsr   Útypingr   r   r   r   r	   r
   r   r   r/   Útorch.nn.functionalÚnnÚ
functionalrO   r   r   Útorch.overridesr   Útorch.typesr   r   r   r   r   ÚfloatÚ__annotations__Ú__all__Útupler   ÚintrC   rJ   Úboolr   r   r   r]   r_   r   rw   rn   r   r   r.   r(   r&   ú<module>r˜      s,  ðØ $Ð $Ð $Ð $Ð $Ð $Ð $Ø $Ð $Ð $Ð $Ð $Ð $Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ Tà €€€Ø Ð Ð Ð Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  Ø *Ð *Ð *Ð *Ð *Ð *Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7ð  6€��e”Ð 5Ð 5Ñ 5ðð ð €ð,˜5 ¨ Ô0ð ,°U¸6À3¸;Ô5Gð ,ð ,ð ,ð ,ðDDØ�E˜#˜v˜+Ô&Ô'ðDà�FÔðDð �VÔð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(   