Ë
    óÍ:j[  ã                   óî  — 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.y),é    )Ú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 «       «      s¤t        t        j                  «       ¬«      }| D ]?  }t        |t        j                  «      sŒt        |j                  |j                  ¬«      } n | D �cg c]%  }t        |«      r|nt        j                  |fi |¤Ž‘Œ' }}t        j                  |Ž S t        j                  | Ž S c c}w )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   óV   K  — | ]!  }t        |«      xs t        |t        «      –— Œ# y ­w©N)r   Ú
isinstancer   ©Ú.0Úvs     ún/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/torch/distributions/utils.pyú	<genexpr>z broadcast_all.<locals>.<genexpr>+   s$   è ø€ ÒK¸qŒ~˜aÓ Ò:¤J¨q´'Ó$:Ó:ÑKùs   ‚')ziInput arguments must all be instances of Number, torch.Tensor or objects implementing __torch_function__.c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr!   r   r#   s     r&   r'   z broadcast_all.<locals>.<genexpr>0   s   è ø€ Ò1 QŒ~˜a× Ñ1ùs   ‚)Údtype©r)   Údevice)ÚallÚ
ValueErrorÚdictÚtorchÚget_default_dtyper"   r   r)   r+   r   ÚtensorÚbroadcast_tensors)r   ÚoptionsÚvaluer%   Ú
new_valuess        r&   r   r      sÝ   € ô  ÑKÀFÔKÔKÜðGó
ð 	
ô Ñ1¨&Ô1Ô1Ü"&¬U×-DÑ-DÓ-FÔ"GˆØò 	ˆEÜ˜%¤§¡Õ.Ü U§[¡[¸¿¹ÔF�Ùð	ð
 MSö
ØGH” Ô"‰A¬¯©°QÑ(B¸'Ñ(BÑBð
ˆ
ð 
ô ×&Ñ&¨
Ð3Ð3Ü×"Ñ" FÐ+Ð+ùò	
s   Â*C&Úshaper)   r+   c                 ó  — t         j                  j                  «       rBt        j                  t        j                  | ||¬«      t        j
                  | ||¬«      «      S t        j                  | ||¬«      j                  «       S )Nr*   )r/   Ú_CÚ_get_tracing_stateÚnormalÚzerosÚonesÚemptyÚnormal_)r6   r)   r+   s      r&   Ú_standard_normalr?   =   sc   € ô
 ‡x�x×"Ñ"Ô$ä�|‰|Ü�K‰K˜ U°6Ô:Ü�J‰J�u E°&Ô9ó
ð 	
ô �;‰;�u E°&Ô9×AÑAÓCÐCó    r4   Údimc                 óv   — |dk(  r| S | j                   d|  dz   }| j                  |«      j                  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)éÿÿÿÿrC   )r6   ÚreshapeÚsum)r4   rA   Úrequired_shapes      r&   Ú_sum_rightmostrG   K   sA   € ð ˆa‚xØˆØ—[‘[  3 $Ð'¨%Ñ/€NØ�=‰=˜Ó(×,Ñ,¨RÓ0Ð0r@   ÚlogitsÚ	is_binaryc                 ó^   — |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.
    rC   )rA   )r/   ÚsigmoidÚFÚsoftmax)rH   rI   s     r&   r   r   Y   s'   € ñ Ü�}‰}˜VÓ$Ð$Ü�9‰9�V Ô$Ð$r@   Úprobsc                 ó€   — t        j                  | 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)rN   rT   s     r&   r   r   e   s3   € ô, �+‰+�e—k‘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)rN   rI   Ú
ps_clampeds      r&   r   r      s?   € ô ˜UÓ#€JÙÜ�y‰y˜Ó$¤u§{¡{°J°;Ó'?Ñ?Ð?Ü�9‰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
y)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                 ó*   — || _         t        | |«       y 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                  ó   — y r!   © ©rb   rd   re   s      r&   Ú__get__zlazy_property.__get__œ   s   € ð /2r@   c                  ó   — y r!   rg   rh   s      r&   ri   zlazy_property.__get__¡   s   € Ø?Br@   z%R | _lazy_property_and_property[T, R]c                 óê   — |€t        | j                  «      S t        j                  «       5  | j                  |«      }d d d «       t	        || j                  j
                  «       |S # 1 sw Y   Œ,xY wr!   )Ú_lazy_property_and_propertyr_   r/   Úenable_gradÚsetattrÚ__name__)rb   rd   re   r4   s       r&   ri   zlazy_property.__get__¤   sc   € ð ÐÜ.¨t¯|©|Ó<Ð<Ü×ÑÓ ñ 	+Ø—L‘L Ó*ˆE÷	+ä�˜$Ÿ,™,×/Ñ/°Ô7Øˆ÷	+ð 	+ús   ¬A)Á)A2r!   )ro   Ú
__module__Ú__qualname__Ú__doc__r   rZ   r\   rc   r
   r   ri   r   rg   r@   r&   r   r   �   s�   „ ñð& ¨!¨¨a¨Ñ 0ð &°Tó &ð à.2ñ2Øð2Ø(+ð2à	,ò2ó ð2ð ÙB ÐB¨SÐB¸AÒBó ØBð 9=ñØ˜a ˜g™ðØ25ðà	0ôr@   r   c                   ó,   — e Zd ZdZdeegef   ddfd„Zy)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                 ó0   — t         j                  | |«       y r!   )Úpropertyrc   ra   s     r&   rc   z$_lazy_property_and_property.__init__¶   s   € Ü×Ñ˜$ Õ(r@   )ro   rp   rq   rr   r   rZ   r\   rc   rg   r@   r&   rl   rl   ¯   s%   „ ñð) ¨!¨¨a¨Ñ 0ð )°Tô )r@   rl   ÚmatÚdiagc           	      ó.  — | j                   d   }t        j                  j                  «       s$|| k  s||k\  rt	        d|› d| › d|dz
  › d�«      ‚t        j
                  || 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.
    rC   zdiag (z) provided is outside [z, rP   z].©r+   .)r6   r/   r8   r9   r-   Úaranger+   Úview)rv   rw   Únrz   Ú	tril_maskÚvecs         r&   r   r   º   s›   € ð
 	�	‰	�"‰€AÜ�8‰8×&Ñ&Ô(¨d°a°Rªi¸4À1º9Ü˜6 $ Ð'>À¸r¸dÀ"ÀQÈÁUÀGÈ2ÐNÓOÐOÜ�\‰\˜! C§J¡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                  j                  «       s0t        |«      |z
  |kD  rt        d| j                   d   › d�d	z   «      ‚t        |t        j                  «      rt        |j                  «       «      n
t        |«      }| j                  | j                   d
d t        j                  ||f«      z   «      }t        j                  || 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.
    rP   é   é   rC   é   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   .)r6   Úabsr/   rS   r)   rT   r8   r9   Úroundr-   r"   r   ÚitemÚ	new_zerosÚSizerz   r+   r{   )r~   rw   r|   rT   rv   rz   r}   s          r&   r   r   È   sV  € ð ˆa�$‰h‰,ˆØ��D‘‰L˜QÑ  S§Y¡Y¨r¡]Ñ!2Ñ2°Q¼¸T»±]ÀdÈQÁhÑ5OÑOÐTWÑ
Wñ	Xà	ñ	
€Aô �+‰+�c—i‘iÓ
 ×
$Ñ
$€CÜ�8‰8×&Ñ&Ô(¬e°A«h¸©l¸SÒ.@ÜØ,¨S¯Y©Y°r©]¨OÐ;YÐZØCñDó
ð 	
ô & a¬¯©Ô6Œˆa�f‰f‹hŒ¼EÀ!»H€AØ
�-‰-˜Ÿ	™	 # 2˜¬¯©°Q¸°FÓ);Ñ;Ó
<€CÜ�\‰\˜! C§J¡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Ú
functionalrL   r   r   Útorch.overridesr   Útorch.typesr   r   r   r   r   ÚfloatÚ__annotations__Ú__all__Útupler   Úintr?   rG   Úboolr   r   r   rZ   r\   r   ru   rl   r   r   rg   r@   r&   ú<module>r–      s†  ðÞ $Ý $ß T× TÓ Tã ß Ð ß  Ý *ß 7Ó 7ð  6€��e‘Ó 5ò€ð,˜5 ¨ Ñ0ð ,°U¸6À3¸;Ñ5Gó ,ðDDØ�E˜#˜v˜+Ñ&Ñ'ðDà�FÑðDð �VÑðDð ó	Dð1˜&ð 1 sð 1¨vó 1ñ	%˜Fð 	%¨tð 	%Àó 	%ð-�vð - &ó -ñ4
!˜6ð 
!¨dð 
!¸vó 
!ñ ˆC˜tÔ$€ÙˆC˜4Ô €ô�G˜A˜q˜D‘Mô ô>) -°°1°Ñ"5°xô )ñ˜Fð ¨#ð °fó ñ˜Fð ¨#ð °fô r@   