
    9i[                        % S SK Jr  S SKJr  S SKJrJrJrJrJ	r	J
r
JrJr  S SKrS SKJs  Jr  S SKJrJr  S SKJr  S SKJrJrJrJr  Sr\\   \S	'   / S
QrS\\\4   S\\S4   4S jr S\\\!\4      S\	\   S\	\   S\4S jr"S\S\!S\4S jr#S*S\S\$S\4S jjr%S\S\4S jr&S*S\S\$S\4S jjr'\" SSS9r(\" SSS 9r) " S! S"\\(\)4   5      r* " S# S$\*\(\)4   \+5      r,S+S%\S&\!S\4S' jjr-S+S(\S&\!S\4S) jjr.g),    )Sequence)update_wrapper)AnyCallableFinalGenericOptionaloverloadTypeVarUnionN)SymIntTensoris_tensor_like)_dtype_NumberDeviceNumbergox?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                     [        S U  5       5      (       d  [        S5      e[        S U  5       5      (       d  [        [        R                  " 5       S9nU  HB  n[        U[        R                  5      (       d  M$  [        UR                  UR                  S9n  O   U  Vs/ s H,  n[        U5      (       a  UO[        R                  " U40 UD6PM.     nn[        R                  " U6 $ [        R                  " U 6 $ s  snf )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   f   #    U  H'  n[        U5      =(       d    [        U[        5      v   M)     g 7fN)r   
isinstancer   .0vs     Y/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/distributions/utils.py	<genexpr> broadcast_all.<locals>.<genexpr>+   s$     KFq~a :Jq'$::Fs   /1ziInput arguments must all be instances of Number, torch.Tensor or objects implementing __torch_function__.c              3   8   #    U  H  n[        U5      v   M     g 7fr!   r   r#   s     r&   r'   r(   0   s     1&Q~a  &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      KFKKKG
 	
 1&111"&U-D-D-F"GE%..U[[F 
 MS
LRq""AQ(B'(BBF 	 
 &&
33""F++	
s   "3C=shaper*   r,   c           	         [         R                  R                  5       (       a=  [         R                  " [         R                  " XUS9[         R
                  " XUS95      $ [         R                  " XUS9R                  5       $ )Nr+   )r0   _C_get_tracing_statenormalzerosonesemptynormal_)r7   r*   r,   s      r&   _standard_normalr@   =   s`    
 xx""$$||KK6:JJu&9
 	
 ;;u&9AACC    r5   dimc                 x    US:X  a  U $ U R                   SU*  S-   nU R                  U5      R                  S5      $ )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   )r7   reshapesum)r5   rB   required_shapes      r&   _sum_rightmostrH   K   sA     ax[[3$'%/N==(,,R00rA   logits	is_binaryc                 f    U(       a  [         R                  " U 5      $ [        R                  " U SS9$ )z
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   )r0   sigmoidFsoftmax)rI   rJ   s     r&   r   r   Y   s'     }}V$$99V$$rA   probsc                 |    [         R                  " U R                  5      R                  nU R	                  USU-
  S9$ )ah  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)r0   finfor*   epsclamp)rO   rU   s     r&   r   r   e   s3    , ++ekk
"
&
&C;;3AG;,,rA   c                     [        U 5      nU(       a.  [        R                  " U5      [        R                  " U* 5      -
  $ [        R                  " U5      $ )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   r0   loglog1p)rO   rJ   
ps_clampeds      r&   r   r      s?     U#Jyy$u{{J;'???99Z  rA   TT)contravariantR)	covariantc                       \ rS rSrSrS\\/\4   SS4S jr\	 SSSS\
SS	4S
 jj5       r\	SS\S\
S\4S jj5       r SS\\S4   S\
SS4S jjrSrg)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                 &    Xl         [        X5        g r!   )ra   r   selfra   s     r&   __init__lazy_property.__init__   s    )0t%rA   instanceobj_typez!_lazy_property_and_property[T, R]c                     g r!    rd   rg   rh   s      r&   __get__lazy_property.__get__   s     /2rA   c                     g r!   rj   rk   s      r&   rl   rm      s    ?BrA   z%R | _lazy_property_and_property[T, R]c                     Uc  [        U R                  5      $ [        R                  " 5          U R                  U5      nS S S 5        [	        XR                  R
                  W5        U$ ! , (       d  f       N0= fr!   )_lazy_property_and_propertyra   r0   enable_gradsetattr__name__)rd   rg   rh   r5   s       r&   rl   rm      sZ     .t||<< LL*E !,,//7 ! s   A**
A8)ra   r!   )rs   
__module____qualname____firstlineno____doc__r   r[   r]   re   r
   r   rl   r   __static_attributes__rj   rA   r&   r   r      s    &!a 0 &T & .222(+2	,2 2 BBSBAB B 9=ag25	0 rA   r   c                   6    \ rS rSrSrS\\/\4   SS4S jrSr	g)rp      zWe want lazy properties to look like multiple things.

* property when Sphinx autodoc looks
* lazy_property when Distribution validate_args looks
ra   r   Nc                 .    [         R                  X5        g r!   )propertyre   rc   s     r&   re   $_lazy_property_and_property.__init__   s    $(rA   rj   )
rs   rt   ru   rv   rw   r   r[   r]   re   rx   rj   rA   r&   rp   rp      s%    )!a 0 )T )rA   rp   matdiagc           	      0   U R                   S   n[        R                  R                  5       (       d$  X* :  d  X:  a  [	        SU SU*  SUS-
   S35      e[        R
                  " X R                  S9nX3R                  SS5      US-   -   :  nU SU4   nU$ )	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,   .)r7   r0   r9   r:   r.   aranger,   view)r~   r   nr   	tril_maskvecs         r&   r   r      s    
 			"A88&&((dRi496$'>rd"QUG2NOO\\!JJ/FR+tax88I
c9n
CJrA   r   c                    SSU-  -   * SSU-  -   S-  SU R                   S   -  -   S[        U5      -  US-   -  -   S-  -   S-  n[        R                  " U R                  5      R
                  n[        R                  R                  5       (       d1  [        U5      U-
  U:  a  [        SU R                   S    S3S	-   5      e[        U[        R                  5      (       a  [        UR                  5       5      O
[        U5      nU R                  U R                   S
S [        R                  " X"45      -   5      n[        R                  " X R                   S9nXUR#                  SS5      US-   -   :  nXSU4'   U$ )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.Nr   .)r7   absr0   rT   r*   rU   r9   r:   roundr.   r"   r   item	new_zerosSizer   r,   r   )r   r   r   rU   r~   r   r   s          r&   r   r      sT    a$h,DLQSYYr]!22QT]dQh5OOTW
W	X		
A ++cii
 
$
$C88&&((eAhlS.@,SYYr]O;YZCD
 	
 &a66affhE!HA
--		#2QF);;
<C\\!JJ/FR+tax88IYJrA   )F)r   )/collections.abcr   	functoolsr   typingr   r   r   r   r	   r
   r   r   r0   torch.nn.functionalnn
functionalrM   r   r   torch.overridesr   torch.typesr   r   r   r   r   float__annotations____all__tupler   intr@   rH   boolr   r   r   r[   r]   r   r|   rp   r   r   rj   rA   r&   <module>r      s   $ $ T T T      * 7 7  6e 5,50 ,U63;5G ,DDE#v+&'DFD VD 	D1& 1s 1v 1	%F 	%t 	% 	%-v -& -4
!6 
!d 
!v 
! Ct$C4 GAqDM >)-1"5x )F # f F # f rA   