
    [ThM                        S SK JrJrJr   S SKr/ SQr " S S5      r " S S\5      rS r " S	 S
\	\5      r
 " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      r " S' S(\5      r " S) S*\5      r " S+ S,\5      r " S- S.\5      r " S/ S0\5      r " S1 S2\5      r " S3 S4\5      r " S5 S6\5      r  " S7 S8\5      r!\" 5       r"\
r#\r$\" 5       r%\" 5       r&\" S 5      r'\" S95      r(\r)\" 5       r*\$" \*S95      r+\" S:5      r,\" S:5      r-\r.\r/\r0\r1\" S:S;5      r2\r3\r4\" 5       r5\" 5       r6\" 5       r7\" 5       r8\" 5       r9\" 5       r:\" 5       r;\" 5       r<\ r=\!r>g)<    )AnyCallableOptionalN)
Constraintbooleancatcorr_cholesky	dependentdependent_propertygreater_thangreater_than_eqindependentinteger_intervalintervalhalf_open_intervalis_dependent	less_thanlower_choleskylower_triangularmultinomialnonnegativenonnegative_integerone_hotpositivepositive_semidefinitepositive_definitepositive_integerrealreal_vectorsimplexsquarestack	symmetricunit_intervalc                   ,    \ rS rSrSrSrSrS rS rSr	g)	r   M   a  
Abstract base class for constraints.

A constraint object represents a region over which a variable is valid,
e.g. within which a variable can be optimized.

Attributes:
    is_discrete (bool): Whether constrained space is discrete.
        Defaults to False.
    event_dim (int): Number of rightmost dimensions that together define
        an event. The :meth:`check` method will remove this many dimensions
        when computing validity.
Fr   c                     [         e)z{
Returns a byte tensor of ``sample_shape + batch_shape`` indicating
whether each event in value satisfies this constraint.
)NotImplementedErrorselfvalues     W/var/www/auris/envauris/lib/python3.13/site-packages/torch/distributions/constraints.pycheckConstraint.check_   s
    
 "!    c                 :    U R                   R                  SS  S-   $ )N   z())	__class____name__r*   s    r,   __repr__Constraint.__repr__f   s    ~~&&qr*T11r/    N)
r3   
__module____qualname____firstlineno____doc__is_discrete	event_dimr-   r5   __static_attributes__r7   r/   r,   r   r   M   s     KI"2r/   r   c                   |   ^  \ rS rSrSr\\S.U 4S jjr\S\4S j5       r	\S\
4S j5       r\\S.S jrS	 rS
rU =r$ )
_Dependentj   a!  
Placeholder for variables whose support depends on other variables.
These variables obey no simple coordinate-wise constraints.

Args:
    is_discrete (bool): Optional value of ``.is_discrete`` in case this
        can be computed statically. If not provided, access to the
        ``.is_discrete`` attribute will raise a NotImplementedError.
    event_dim (int): Optional value of ``.event_dim`` in case this
        can be computed statically. If not provided, access to the
        ``.event_dim`` attribute will raise a NotImplementedError.
r<   r=   c                :   > Xl         X l        [        TU ]  5         g N)_is_discrete
_event_dimsuper__init__)r*   r<   r=   r2   s      r,   rH   _Dependent.__init__x   s    '#r/   returnc                 V    U R                   [        L a  [        S5      eU R                   $ )Nz,.is_discrete cannot be determined statically)rE   NotImplementedr(   r4   s    r,   r<   _Dependent.is_discrete}   s(    .%&TUU   r/   c                 V    U R                   [        L a  [        S5      eU R                   $ )Nz*.event_dim cannot be determined statically)rF   rL   r(   r4   s    r,   r=   _Dependent.event_dim   s$    ??n,%&RSSr/   c                h    U[         L a  U R                  nU[         L a  U R                  n[        XS9$ )zo
Support for syntax to customize static attributes::

    constraints.dependent(is_discrete=True, event_dim=1)
rB   )rL   rE   rF   r@   )r*   r<   r=   s      r,   __call___Dependent.__call__   s3     .(++K&IkGGr/   c                     [        S5      e)Nz1Cannot determine validity of dependent constraint)
ValueErrorr*   xs     r,   r-   _Dependent.check   s    LMMr/   rF   rE   )r3   r8   r9   r:   r;   rL   rH   propertyboolr<   intr=   rQ   r-   r>   __classcell__r2   s   @r,   r@   r@   j   sh     '5  
 !T ! !
 3  
 '5 
HN Nr/   r@   c                 "    [        U [        5      $ )a  
Checks if ``constraint`` is a ``_Dependent`` object.

Args:
    constraint : A ``Constraint`` object.

Returns:
    ``bool``: True if ``constraint`` can be refined to the type ``_Dependent``, False otherwise.

Examples:
    >>> import torch
    >>> from torch.distributions import Bernoulli
    >>> from torch.distributions.constraints import is_dependent

    >>> dist = Bernoulli(probs=torch.tensor([0.6], requires_grad=True))
    >>> constraint1 = dist.arg_constraints["probs"]
    >>> constraint2 = dist.arg_constraints["logits"]

    >>> for constraint in [constraint1, constraint2]:
    >>>     if is_dependent(constraint):
    >>>         continue
)
isinstancer@   )
constraints    r,   r   r      s    . j*--r/   c            
          ^  \ rS rSrSr S\\S.S\\S\4      S\\	   S\\
   S	S4U 4S
 jjjjrS\S\4   S	S 4S jrSrU =r$ )_DependentProperty   a  
Decorator that extends @property to act like a `Dependent` constraint when
called on a class and act like a property when called on an object.

Example::

    class Uniform(Distribution):
        def __init__(self, low, high):
            self.low = low
            self.high = high

        @constraints.dependent_property(is_discrete=False, event_dim=0)
        def support(self):
            return constraints.interval(self.low, self.high)

Args:
    fn (Callable): The function to be decorated.
    is_discrete (bool): Optional value of ``.is_discrete`` in case this
        can be computed statically. If not provided, access to the
        ``.is_discrete`` attribute will raise a NotImplementedError.
    event_dim (int): Optional value of ``.event_dim`` in case this
        can be computed statically. If not provided, access to the
        ``.event_dim`` attribute will raise a NotImplementedError.
NrB   fn.r<   r=   rJ   c                <   > [         TU ]  U5        X l        X0l        g rD   )rG   rH   rE   rF   )r*   rd   r<   r=   r2   s       r,   rH   _DependentProperty.__init__   s     	'#r/   c                 >    [        XR                  U R                  S9$ )z
Support for syntax to customize static attributes::

    @constraints.dependent_property(is_discrete=True, event_dim=1)
    def support(self): ...
rB   )rb   rE   rF   )r*   rd   s     r,   rQ   _DependentProperty.__call__   s      "--
 	
r/   rX   rD   )r3   r8   r9   r:   r;   rL   r   r   r   rZ   r[   rH   rQ   r>   r\   r]   s   @r,   rb   rb      s    6 ,0	$ '5#1	$Xc3h'(	$ d^		$
 C=	$ 
	$ 	$	
8CH- 	
2F 	
 	
r/   rb   c                   h   ^  \ rS rSrSrU 4S jr\S\4S j5       r\S\	4S j5       r
S rS rS	rU =r$ )
_IndependentConstraint   z
Wraps a constraint by aggregating over ``reinterpreted_batch_ndims``-many
dims in :meth:`check`, so that an event is valid only if all its
independent entries are valid.
c                    > [        U[        5      (       d   e[        U[        5      (       d   eUS:  d   eXl        X l        [
        TU ]  5         g Nr   )r_   r   r[   base_constraintreinterpreted_batch_ndimsrG   rH   )r*   rn   ro   r2   s      r,   rH   _IndependentConstraint.__init__   sO    /:66663S9999(A---.)B&r/   rJ   c                 .    U R                   R                  $ rD   )rn   r<   r4   s    r,   r<   "_IndependentConstraint.is_discrete   s    ##///r/   c                 H    U R                   R                  U R                  -   $ rD   )rn   r=   ro   r4   s    r,   r=    _IndependentConstraint.event_dim   s    ##--0N0NNNr/   c                    U R                   R                  U5      nUR                  5       U R                  :  aB  U R                   R                  U R                  -   n[        SU SUR                  5        35      eUR                  UR                  S UR                  5       U R                  -
   S-   5      nUR                  S5      nU$ )NzExpected value.dim() >= z	 but got rw   )	rn   r-   dimro   r=   rT   reshapeshapeall)r*   r+   resultexpecteds       r,   r-   _IndependentConstraint.check   s    %%++E2::<$888++558V8VVH*8*Ieiik]K  LLH6::<$*H*HHIEQ
 Br/   c                     U R                   R                  SS   S[        U R                  5       SU R                   S3$ )Nr1   (z, ))r2   r3   reprrn   ro   r4   s    r,   r5   _IndependentConstraint.__repr__  sA    ..))!"-.aT5I5I0J/K2dNlNlMmmnoor/   )rn   ro   )r3   r8   r9   r:   r;   rH   rY   rZ   r<   r[   r=   r-   r5   r>   r\   r]   s   @r,   rj   rj      sW     0T 0 0 O3 O Op pr/   rj   c                   "    \ rS rSrSrSrS rSrg)_Booleani  z'
Constrain to the two values `{0, 1}`.
Tc                     US:H  US:H  -  $ )Nr   r1   r7   r)   s     r,   r-   _Boolean.check  s    
uz**r/   r7   N)r3   r8   r9   r:   r;   r<   r-   r>   r7   r/   r,   r   r     s     K+r/   r   c                   &    \ rS rSrSrSrSrS rSrg)_OneHoti  z
Constrain to one-hot vectors.
Tr1   c                     US:H  US:H  -  nUR                  S5      R                  S5      nUR                  S5      U-  $ )Nr   r1   rw   )sumeqr{   )r*   r+   
is_booleanis_normalizeds       r,   r-   _OneHot.check  s@    qjUaZ0
		"((+~~b!M11r/   r7   N)	r3   r8   r9   r:   r;   r<   r=   r-   r>   r7   r/   r,   r   r     s     KI2r/   r   c                   <   ^  \ rS rSrSrSrU 4S jrS rS rSr	U =r
$ )_IntegerIntervali%  z@
Constrain to an integer interval `[lower_bound, upper_bound]`.
Tc                 :   > Xl         X l        [        TU ]  5         g rD   lower_boundupper_boundrG   rH   r*   r   r   r2   s      r,   rH   _IntegerInterval.__init__,      &&r/   c                 P    US-  S:H  U R                   U:*  -  XR                  :*  -  $ Nr1   r   r   r   r)   s     r,   r-   _IntegerInterval.check1  s0    QY!^ 0 0E 9:eGWGW>WX	
r/   c                 x    U R                   R                  SS  nUSU R                   SU R                   S3-  nU$ Nr1   (lower_bound=z, upper_bound=r   r2   r3   r   r   r*   
fmt_strings     r,   r5   _IntegerInterval.__repr__6  J    ^^,,QR0
D,,-^D<L<L;MQO	

 r/   r   r3   r8   r9   r:   r;   r<   rH   r-   r5   r>   r\   r]   s   @r,   r   r   %  s#     K


 r/   r   c                   <   ^  \ rS rSrSrSrU 4S jrS rS rSr	U =r
$ )_IntegerLessThani>  z9
Constrain to an integer interval `(-inf, upper_bound]`.
Tc                 .   > Xl         [        TU ]	  5         g rD   r   rG   rH   r*   r   r2   s     r,   rH   _IntegerLessThan.__init__E      &r/   c                 0    US-  S:H  XR                   :*  -  $ r   r   r)   s     r,   r-   _IntegerLessThan.checkI      	Q5,<,<#<==r/   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ Nr1   z(upper_bound=r   r2   r3   r   r   s     r,   r5   _IntegerLessThan.__repr__L  8    ^^,,QR0
d&6&6%7q99
r/   r   r   r]   s   @r,   r   r   >  #     K> r/   r   c                   <   ^  \ rS rSrSrSrU 4S jrS rS rSr	U =r
$ )_IntegerGreaterThaniR  z8
Constrain to an integer interval `[lower_bound, inf)`.
Tc                 .   > Xl         [        TU ]	  5         g rD   r   rG   rH   r*   r   r2   s     r,   rH   _IntegerGreaterThan.__init__Y  r   r/   c                 0    US-  S:H  XR                   :  -  $ r   r   r)   s     r,   r-   _IntegerGreaterThan.check]  r   r/   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ Nr1   r   r   r2   r3   r   r   s     r,   r5   _IntegerGreaterThan.__repr__`  r   r/   r   r   r]   s   @r,   r   r   R  r   r/   r   c                       \ rS rSrSrS rSrg)_Realif  z>
Trivially constrain to the extended real line `[-inf, inf]`.
c                 
    X:H  $ rD   r7   r)   s     r,   r-   _Real.checkk  s
    ~r/   r7   N)r3   r8   r9   r:   r;   r-   r>   r7   r/   r,   r   r   f  s    r/   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )_GreaterThanio  z5
Constrain to a real half line `(lower_bound, inf]`.
c                 .   > Xl         [        TU ]	  5         g rD   r   r   s     r,   rH   _GreaterThan.__init__t  r   r/   c                      U R                   U:  $ rD   r   r)   s     r,   r-   _GreaterThan.checkx  s    %''r/   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ r   r   r   s     r,   r5   _GreaterThan.__repr__{  r   r/   r   
r3   r8   r9   r:   r;   rH   r-   r5   r>   r\   r]   s   @r,   r   r   o      ( r/   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )_GreaterThanEqi  z5
Constrain to a real half line `[lower_bound, inf)`.
c                 .   > Xl         [        TU ]	  5         g rD   r   r   s     r,   rH   _GreaterThanEq.__init__  r   r/   c                      U R                   U:*  $ rD   r   r)   s     r,   r-   _GreaterThanEq.check  s    5((r/   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ r   r   r   s     r,   r5   _GreaterThanEq.__repr__  r   r/   r   r   r]   s   @r,   r   r     s    ) r/   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )	_LessThani  z6
Constrain to a real half line `[-inf, upper_bound)`.
c                 .   > Xl         [        TU ]	  5         g rD   r   r   s     r,   rH   _LessThan.__init__  r   r/   c                     XR                   :  $ rD   r   r)   s     r,   r-   _LessThan.check  s    ''''r/   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ r   r   r   s     r,   r5   _LessThan.__repr__  r   r/   r   r   r]   s   @r,   r   r     r   r/   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )	_Intervali  z<
Constrain to a real interval `[lower_bound, upper_bound]`.
c                 :   > Xl         X l        [        TU ]  5         g rD   r   r   s      r,   rH   _Interval.__init__  r   r/   c                 >    U R                   U:*  XR                  :*  -  $ rD   r   r)   s     r,   r-   _Interval.check  s!      E)e7G7G.GHHr/   c                 x    U R                   R                  SS  nUSU R                   SU R                   S3-  nU$ r   r   r   s     r,   r5   _Interval.__repr__  r   r/   r   r   r]   s   @r,   r   r     s    
I r/   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )_HalfOpenIntervali  z<
Constrain to a real interval `[lower_bound, upper_bound)`.
c                 :   > Xl         X l        [        TU ]  5         g rD   r   r   s      r,   rH   _HalfOpenInterval.__init__  r   r/   c                 >    U R                   U:*  XR                  :  -  $ rD   r   r)   s     r,   r-   _HalfOpenInterval.check  s!      E)e6F6F.FGGr/   c                 x    U R                   R                  SS  nUSU R                   SU R                   S3-  nU$ r   r   r   s     r,   r5   _HalfOpenInterval.__repr__  r   r/   r   r   r]   s   @r,   r   r     s    
H r/   r   c                   "    \ rS rSrSrSrS rSrg)_Simplexi  zt
Constrain to the unit simplex in the innermost (rightmost) dimension.
Specifically: `x >= 0` and `x.sum(-1) == 1`.
r1   c                 ~    [         R                  " US:  SS9UR                  S5      S-
  R                  5       S:  -  $ )Nr   rw   rx   r1   ư>)torchr{   r   absr)   s     r,   r-   _Simplex.check  s7    yy!,21B0G0G0ID0PQQr/   r7   Nr3   r8   r9   r:   r;   r=   r-   r>   r7   r/   r,   r   r     s    
 IRr/   r   c                   ,    \ rS rSrSrSrSrS rS rSr	g)	_Multinomiali  a  
Constrain to nonnegative integer values summing to at most an upper bound.

Note due to limitations of the Multinomial distribution, this currently
checks the weaker condition ``value.sum(-1) <= upper_bound``. In the future
this may be strengthened to ``value.sum(-1) == upper_bound``.
Tr1   c                     Xl         g rD   r   )r*   r   s     r,   rH   _Multinomial.__init__  s    &r/   c                 `    US:  R                  SS9UR                  SS9U R                  :*  -  $ )Nr   rw   r   )r{   r   r   rU   s     r,   r-   _Multinomial.check  s1    Q|||#quuu}8H8H'HIIr/   r   N)
r3   r8   r9   r:   r;   r<   r=   rH   r-   r>   r7   r/   r,   r   r     s     KI'Jr/   r   c                   "    \ rS rSrSrSrS rSrg)_LowerTriangulari  z0
Constrain to lower-triangular square matrices.
   c                     UR                  5       nX!:H  R                  UR                  S S S-   5      R                  S5      S   $ )Nrv   rw   r   )trilviewrz   min)r*   r+   
value_trils      r,   r-   _LowerTriangular.check  sA    ZZ\
#))%++cr*:U*BCGGKANNr/   r7   Nr   r7   r/   r,   r  r    s     IOr/   r  c                   "    \ rS rSrSrSrS rSrg)_LowerCholeskyi  zH
Constrain to lower-triangular square matrices with positive diagonals.
r  c                     UR                  5       nX!:H  R                  UR                  S S S-   5      R                  S5      S   nUR	                  SSS9S:  R                  S5      S   nX4-  $ )Nr  rv   rw   r   )dim1dim2)r  r  rz   r  diagonal)r*   r+   r	  r   positive_diagonals        r,   r-   _LowerCholesky.check  sv    ZZ\
 &&u{{3B'7%'?@DDRHK 	 #^^"^=AFFrJ1M33r/   r7   Nr   r7   r/   r,   r  r    s     I4r/   r  c                   "    \ rS rSrSrSrS rSrg)_CorrCholeskyi  zq
Constrain to lower-triangular square matrices with positive diagonals and each
row vector being of unit length.
r  c                 n   [         R                  " UR                  5      R                  UR	                  S5      -  S-  n[         R
                  R                  UR                  5       SS9nUS-
  R                  5       R                  U5      R                  SS9n[        5       R                  U5      U-  $ )Nrw   
   r         ?)r   finfodtypeepssizelinalgnormdetachr   ler{   r  r-   )r*   r+   tolrow_normunit_row_norms        r,   r-   _CorrCholesky.check  s    KK$((5::b>9B> 	 <<$$U\\^$<!C,,.11#6::r:B%%e,}<<r/   r7   Nr   r7   r/   r,   r  r    s    
 I=r/   r  c                   "    \ rS rSrSrSrS rSrg)_Squarei  z
Constrain to square matrices.
r  c                     [         R                  " UR                  S S UR                  S   UR                  S   :H  [         R                  UR                  S9$ )Nr  rw   )r  
fill_valuer  device)r   fullrz   rZ   r(  r)   s     r,   r-   _Square.check#  sG    zzSb!B5;;r?:**<<	
 	
r/   r7   Nr   r7   r/   r,   r%  r%    s     I
r/   r%  c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )
_Symmetrici,  z)
Constrain to Symmetric square matrices.
c                    > [         TU ]  U5      nUR                  5       (       d  U$ [        R                  " XR
                  SS9R                  S5      R                  S5      $ )Nr   )atolr  rw   )rG   r-   r{   r   isclosemT)r*   r+   square_checkr2   s      r,   r-   _Symmetric.check1  sQ    w}U+!!}}UHH48<<R@DDRHHr/   r7   r3   r8   r9   r:   r;   r-   r>   r\   r]   s   @r,   r,  r,  ,  s    I Ir/   r,  c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_PositiveSemidefinitei8  z.
Constrain to positive-semidefinite matrices.
c                    > [         TU ]  U5      nUR                  5       (       d  U$ [        R                  R                  U5      R                  S5      R                  S5      $ )Nr   rw   )rG   r-   r{   r   r  eigvalshger*   r+   	sym_checkr2   s      r,   r-   _PositiveSemidefinite.check=  sM    GM%(	}}||$$U+..q155b99r/   r7   r3  r]   s   @r,   r5  r5  8      : :r/   r5  c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_PositiveDefiniteiD  z*
Constrain to positive-definite matrices.
c                    > [         TU ]  U5      nUR                  5       (       d  U$ [        R                  R                  U5      R                  R                  S5      $ rm   )rG   r-   r{   r   r  cholesky_exinfor   r9  s      r,   r-   _PositiveDefinite.checkI  sH    GM%(	}}||''.3366q99r/   r7   r3  r]   s   @r,   r>  r>  D  r<  r/   r>  c                   f   ^  \ rS rSrSrS	U 4S jjr\S\4S j5       r\S\	4S j5       r
S rSrU =r$ )
_CatiP  z
Constraint functor that applies a sequence of constraints
`cseq` at the submatrices at dimension `dim`,
each of size `lengths[dim]`, in a way compatible with :func:`torch.cat`.
c                 4  > [        S U 5       5      (       d   e[        U5      U l        Uc  S/[        U R                  5      -  n[        U5      U l        [        U R                  5      [        U R                  5      :X  d   eX l        [        TU ]  5         g )Nc              3   B   #    U  H  n[        U[        5      v   M     g 7frD   r_   r   .0cs     r,   	<genexpr> _Cat.__init__.<locals>.<genexpr>X       ;d:a,,d   r1   )r{   listcseqlenlengthsrx   rG   rH   )r*   rP  rx   rR  r2   s       r,   rH   _Cat.__init__W  sx    ;d;;;;;J	?cC		N*GG}4<< C		N222r/   rJ   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frD   r<   rH  s     r,   rK  #_Cat.is_discrete.<locals>.<genexpr>c       4)Q==)   anyrP  r4   s    r,   r<   _Cat.is_discretea      4$))444r/   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frD   r=   rH  s     r,   rK  !_Cat.event_dim.<locals>.<genexpr>g  s     2	1;;	rY  )maxrP  r4   s    r,   r=   _Cat.event_dime  s    2		222r/   c                    UR                  5       * U R                   s=::  a  UR                  5       :  d   e   e/ nSn[        U R                  U R                  5       HE  u  pEUR	                  U R                   X55      nUR                  UR                  U5      5        X5-   nMG     [        R                  " X R                   5      $ rm   )	rx   ziprP  rR  narrowappendr-   r   r   )r*   r+   checksstartconstrlengthvs          r,   r-   
_Cat.checki  s    		|txx5%))+55555!$))T\\:NFTXXu5AMM&,,q/*NE ; yy**r/   )rP  rx   rR  )r   Nr3   r8   r9   r:   r;   rH   rY   rZ   r<   r[   r=   r-   r>   r\   r]   s   @r,   rD  rD  P  sM     5T 5 5 33 3 3+ +r/   rD  c                   f   ^  \ rS rSrSrS	U 4S jjr\S\4S j5       r\S\	4S j5       r
S rSrU =r$ )
_Stackit  z
Constraint functor that applies a sequence of constraints
`cseq` at the submatrices at dimension `dim`,
in a way compatible with :func:`torch.stack`.
c                    > [        S U 5       5      (       d   e[        U5      U l        X l        [        TU ]  5         g )Nc              3   B   #    U  H  n[        U[        5      v   M     g 7frD   rG  rH  s     r,   rK  "_Stack.__init__.<locals>.<genexpr>|  rM  rN  )r{   rO  rP  rx   rG   rH   )r*   rP  rx   r2   s      r,   rH   _Stack.__init__{  s5    ;d;;;;;J	r/   rJ   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frD   rV  rH  s     r,   rK  %_Stack.is_discrete.<locals>.<genexpr>  rX  rY  rZ  r4   s    r,   r<   _Stack.is_discrete  r]  r/   c                 n    [        S U R                   5       5      nU R                  U-   S:  a  US-  nU$ )Nc              3   8   #    U  H  oR                   v   M     g 7frD   r`  rH  s     r,   rK  #_Stack.event_dim.<locals>.<genexpr>  s     1y!++yrY  r   r1   )rb  rP  rx   )r*   rx   s     r,   r=   _Stack.event_dim  s4    1tyy1188c>A1HC
r/   c           	         UR                  5       * U R                   s=::  a  UR                  5       :  d   e   e[        UR                  U R                   5      5       Vs/ s H  o!R                  U R                   U5      PM      nn[        R
                  " [        X0R                  5       VVs/ s H  u  pEUR                  U5      PM     snnU R                   5      $ s  snf s  snnf rD   )	rx   ranger  selectr   r"   re  rP  r-   )r*   r+   ivsrl  rj  s         r,   r-   _Stack.check  s    		|txx5%))+5555516uzz$((7K1LM1LAll488Q'1LM{{.1"ii.@A.@V\\!_.@A488
 	
 NAs    %C/C$
)rP  rx   )r   rn  r]   s   @r,   rp  rp  t  sM     5T 5 5 3  
 
r/   rp  r1   g        r  )?typingr   r   r   r   __all__r   r@   r   rY   rb   rj   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r%  r,  r5  r>  rD  rp  r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r   r   r    r   r   r	   r!   r#   r   r   r   r"   r7   r/   r,   <module>r     sG   + *B  F2 2:,N ,N^.4.
: .
b%pZ %pP+z +2j 2z 2z (* (J : $Z $
 $
 *
 *	Rz 	RJ: J&	Oz 	O4Z 4"=J ="
j 
 	I 	I	:J 	:	:
 	:!+: !+H
Z 
B L	' $
*
))!, &q) # w$"S! 	#s#& 
*#% !	L	-/ %' 
r/   