
    IЦiK                        S 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,\r-\r.\" S:S;5      r/\r0\r1\" 5       r2\" 5       r3\" 5       r4\" 5       r5\" 5       r6\" 5       r7\" 5       r8\" 5       r9\r:\r;g)<a  
The following constraints are implemented:

- ``constraints.boolean``
- ``constraints.cat``
- ``constraints.corr_cholesky``
- ``constraints.dependent``
- ``constraints.greater_than(lower_bound)``
- ``constraints.greater_than_eq(lower_bound)``
- ``constraints.independent(constraint, reinterpreted_batch_ndims)``
- ``constraints.integer_interval(lower_bound, upper_bound)``
- ``constraints.interval(lower_bound, upper_bound)``
- ``constraints.less_than(upper_bound)``
- ``constraints.lower_cholesky``
- ``constraints.lower_triangular``
- ``constraints.multinomial``
- ``constraints.nonnegative``
- ``constraints.nonnegative_integer``
- ``constraints.one_hot``
- ``constraints.positive_integer``
- ``constraints.positive``
- ``constraints.positive_semidefinite``
- ``constraints.positive_definite``
- ``constraints.real_vector``
- ``constraints.real``
- ``constraints.simplex``
- ``constraints.symmetric``
- ``constraints.stack``
- ``constraints.square``
- ``constraints.symmetric``
- ``constraints.unit_interval``
    N)
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   I   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     ^/var/www/html/ai-image-ml/venv/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__b   s    ~~&&qr*T11r,    N)
r0   
__module____qualname____firstlineno____doc__is_discrete	event_dimr*   r2   __static_attributes__r4   r,   r)   r   r   I   s     KI"2r,   r   c                   l   ^  \ rS rSrSr\\S.U 4S jjr\S 5       r\S 5       r	\\S.S jr
S rS	rU =r$ )

_Dependentf   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.
r9   r:   c                :   > Xl         X l        [        TU ]  5         g N)_is_discrete
_event_dimsuper__init__)r'   r9   r:   r/   s      r)   rE   _Dependent.__init__t   s    '#r,   c                 V    U R                   [        L a  [        S5      eU R                   $ )Nz,.is_discrete cannot be determined statically)rB   NotImplementedr%   r1   s    r)   r9   _Dependent.is_discretey   s(    .%&TUU   r,   c                 V    U R                   [        L a  [        S5      eU R                   $ )Nz*.event_dim cannot be determined statically)rC   rH   r%   r1   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)
r?   )rH   rB   rC   r=   )r'   r9   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,   rC   rB   )r0   r5   r6   r7   r8   rH   rE   propertyr9   r:   rM   r*   r;   __classcell__r/   s   @r)   r=   r=   f   sZ     '5  
 ! !
  
 '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                   B   ^  \ rS rSrSr S\\S.U 4S jjjrS 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.
r?   c                <   > [         TU ]  U5        X l        X0l        g rA   )rD   rE   rB   rC   )r'   fnr9   r:   r/   s       r)   rE   _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):
        ...
r?   )r\   rB   rC   )r'   r_   s     r)   rM   _DependentProperty.__call__   s      "--
 	
r,   rT   rA   )
r0   r5   r6   r7   r8   rH   rE   rM   r;   rV   rW   s   @r)   r\   r\      s+    2 $&4$ $

 

r,   r\   c                   X   ^  \ rS rSrSrU 4S jr\S 5       r\S 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   )rY   r   intbase_constraintreinterpreted_batch_ndimsrD   rE   )r'   ri   rj   r/   s      r)   rE   _IndependentConstraint.__init__   sO    /:66663S9999(A---.)B&r,   c                 .    U R                   R                  $ rA   )ri   r9   r1   s    r)   r9   "_IndependentConstraint.is_discrete   s    ##///r,   c                 H    U R                   R                  U R                  -   $ rA   )ri   r:   rj   r1   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 rr   )	ri   r*   dimrj   r:   rP   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$ )Nr.   (z, ))r/   r0   reprri   rj   r1   s    r)   r2   _IndependentConstraint.__repr__   sA    ..))!"-.aT5I5I0J/K2dNlNlMmmnoor,   )ri   rj   )r0   r5   r6   r7   r8   rE   rU   r9   r:   r*   r2   r;   rV   rW   s   @r)   rd   rd      sH     0 0 O Op pr,   rd   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   r.   r4   r&   s     r)   r*   _Boolean.check  s    
uz**r,   r4   N)r0   r5   r6   r7   r8   r9   r*   r;   r4   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.
Tr.   c                     US:H  US:H  -  nUR                  S5      R                  S5      nUR                  S5      U-  $ )Nr   r.   rr   )sumeqrv   )r'   r(   
is_booleanis_normalizeds       r)   r*   _OneHot.check  s@    qjUaZ0
		"((+~~b!M11r,   r4   N)	r0   r5   r6   r7   r8   r9   r:   r*   r;   r4   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 rA   lower_boundupper_boundrD   rE   r'   r   r   r/   s      r)   rE   _IntegerInterval.__init__$      &&r,   c                 P    US-  S:H  U R                   U:*  -  XR                  :*  -  $ Nr.   r   r   r   r&   s     r)   r*   _IntegerInterval.check)  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$ Nr.   (lower_bound=z, upper_bound=r|   r/   r0   r   r   r'   
fmt_strings     r)   r2   _IntegerInterval.__repr__.  J    ^^,,QR0
D,,-^D<L<L;MQO	

 r,   r   r0   r5   r6   r7   r8   r9   rE   r*   r2   r;   rV   rW   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
$ )_IntegerLessThani6  z9
Constrain to an integer interval `(-inf, upper_bound]`.
Tc                 .   > Xl         [        TU ]	  5         g rA   r   rD   rE   r'   r   r/   s     r)   rE   _IntegerLessThan.__init__=      &r,   c                 0    US-  S:H  XR                   :*  -  $ r   r   r&   s     r)   r*   _IntegerLessThan.checkA      	Q5,<,<#<==r,   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ Nr.   z(upper_bound=r|   r/   r0   r   r   s     r)   r2   _IntegerLessThan.__repr__D  8    ^^,,QR0
d&6&6%7q99
r,   r   r   rW   s   @r)   r   r   6  #     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
$ )_IntegerGreaterThaniJ  z8
Constrain to an integer interval `[lower_bound, inf)`.
Tc                 .   > Xl         [        TU ]	  5         g rA   r   rD   rE   r'   r   r/   s     r)   rE   _IntegerGreaterThan.__init__Q  r   r,   c                 0    US-  S:H  XR                   :  -  $ r   r   r&   s     r)   r*   _IntegerGreaterThan.checkU  r   r,   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ Nr.   r   r|   r/   r0   r   r   s     r)   r2   _IntegerGreaterThan.__repr__X  r   r,   r   r   rW   s   @r)   r   r   J  r   r,   r   c                       \ rS rSrSrS rSrg)_Reali^  z>
Trivially constrain to the extended real line `[-inf, inf]`.
c                 
    X:H  $ rA   r4   r&   s     r)   r*   _Real.checkc  s
    ~r,   r4   N)r0   r5   r6   r7   r8   r*   r;   r4   r,   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	$ )_GreaterThanig  z5
Constrain to a real half line `(lower_bound, inf]`.
c                 .   > Xl         [        TU ]	  5         g rA   r   r   s     r)   rE   _GreaterThan.__init__l  r   r,   c                      U R                   U:  $ rA   r   r&   s     r)   r*   _GreaterThan.checkp  s    %''r,   c                 ^    U R                   R                  SS  nUSU R                   S3-  nU$ r   r   r   s     r)   r2   _GreaterThan.__repr__s  r   r,   r   
r0   r5   r6   r7   r8   rE   r*   r2   r;   rV   rW   s   @r)   r   r   g      ( r,   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )_GreaterThanEqiy  z5
Constrain to a real half line `[lower_bound, inf)`.
c                 .   > Xl         [        TU ]	  5         g rA   r   r   s     r)   rE   _GreaterThanEq.__init__~  r   r,   c                      U R                   U:*  $ rA   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)   r2   _GreaterThanEq.__repr__  r   r,   r   r   rW   s   @r)   r   r   y  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 rA   r   r   s     r)   rE   _LessThan.__init__  r   r,   c                     XR                   :  $ rA   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)   r2   _LessThan.__repr__  r   r,   r   r   rW   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 rA   r   r   s      r)   rE   _Interval.__init__  r   r,   c                 >    U R                   U:*  XR                  :*  -  $ rA   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)   r2   _Interval.__repr__  r   r,   r   r   rW   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 rA   r   r   s      r)   rE   _HalfOpenInterval.__init__  r   r,   c                 >    U R                   U:*  XR                  :  -  $ rA   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)   r2   _HalfOpenInterval.__repr__  r   r,   r   r   rW   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`.
r.   c                 ~    [         R                  " US:  SS9UR                  S5      S-
  R                  5       S:  -  $ )Nr   rr   rs   r.   ư>)torchrv   r   absr&   s     r)   r*   _Simplex.check  s7    yy!,21B0G0G0ID0PQQr,   r4   Nr0   r5   r6   r7   r8   r:   r*   r;   r4   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``.
Tr.   c                     Xl         g rA   r   )r'   r   s     r)   rE   _Multinomial.__init__  s    &r,   c                 `    US:  R                  SS9UR                  SS9U R                  :*  -  $ )Nr   rr   r   )rv   r   r   rQ   s     r)   r*   _Multinomial.check  s1    Q|||#quuu}8H8H'HIIr,   r   N)
r0   r5   r6   r7   r8   r9   r:   rE   r*   r;   r4   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   $ )Nrq   rr   r   )trilviewru   min)r'   r(   
value_trils      r)   r*   _LowerTriangular.check  sA    ZZ\
#))%++cr*:U*BCGGKANNr,   r4   Nr   r4   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   rq   rr   r   )dim1dim2)r  r  ru   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,   r4   Nr   r4   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-  $ )Nrr   
   r         ?)r   finfodtypeepssizelinalgnormdetachr   lerv   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,   r4   Nr   r4   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   rr   )r  
fill_valuer  device)r   fullru   boolr#  r&   s     r)   r*   _Square.check  sG    zzSb!B5;;r?:**<<	
 	
r,   r4   Nr   r4   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   rr   )rD   r*   rv   r   isclosemT)r'   r(   square_checkr/   s      r)   r*   _Symmetric.check)  sQ    w}U+!!}}UHH48<<R@DDRHHr,   r4   r0   r5   r6   r7   r8   r*   r;   rV   rW   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$ )_PositiveSemidefinitei0  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   rr   )rD   r*   rv   r   r  eigvalshger'   r(   	sym_checkr/   s      r)   r*   _PositiveSemidefinite.check5  sM    GM%(	}}||$$U+..q155b99r,   r4   r/  rW   s   @r)   r1  r1  0      : :r,   r1  c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_PositiveDefinitei<  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      $ rg   )rD   r*   rv   r   r  cholesky_exinfor   r5  s      r)   r*   _PositiveDefinite.checkA  sH    GM%(	}}||''.3366q99r,   r4   r/  rW   s   @r)   r:  r:  <  r8  r,   r:  c                   V   ^  \ rS rSrSrSU 4S jjr\S 5       r\S 5       rS r	Sr
U =r$ )	_CatiH  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rA   rY   r   .0cs     r)   	<genexpr> _Cat.__init__.<locals>.<genexpr>P       ;d:a,,d   r.   )rv   listcseqlenlengthsrs   rD   rE   )r'   rL  rs   rN  r/   s       r)   rE   _Cat.__init__O  sx    ;d;;;;;J	?cC		N*GG}4<< C		N222r,   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frA   r9   rD  s     r)   rG  #_Cat.is_discrete.<locals>.<genexpr>[       4)Q==)   anyrL  r1   s    r)   r9   _Cat.is_discreteY      4$))444r,   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frA   r:   rD  s     r)   rG  !_Cat.event_dim.<locals>.<genexpr>_  s     2	1;;	rU  )maxrL  r1   s    r)   r:   _Cat.event_dim]  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      $ rg   )	rs   ziprL  rN  narrowappendr*   r   r   )r'   r(   checksstartconstrlengthvs          r)   r*   
_Cat.checka  s    		|txx5%))+55555!$))T\\:NFTXXu5AMM&,,q/*NE ; yy**r,   )rL  rs   rN  )r   Nr0   r5   r6   r7   r8   rE   rU   r9   r:   r*   r;   rV   rW   s   @r)   r@  r@  H  s?     5 5 3 3+ +r,   r@  c                   V   ^  \ rS rSrSrSU 4S jjr\S 5       r\S 5       rS r	Sr
U =r$ )	_Stackil  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rA   rC  rD  s     r)   rG  "_Stack.__init__.<locals>.<genexpr>t  rI  rJ  )rv   rK  rL  rs   rD   rE   )r'   rL  rs   r/   s      r)   rE   _Stack.__init__s  s5    ;d;;;;;J	r,   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7frA   rR  rD  s     r)   rG  %_Stack.is_discrete.<locals>.<genexpr>{  rT  rU  rV  r1   s    r)   r9   _Stack.is_discretey  rY  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rA   r\  rD  s     r)   rG  #_Stack.event_dim.<locals>.<genexpr>  s     1y!++yrU  r   r.   )r^  rL  rs   )r'   rs   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 rA   )	rs   ranger  selectr   r   ra  rL  r*   )r'   r(   ivsrh  rf  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$
)rL  rs   )r   rj  rW   s   @r)   rl  rl  l  s?     5 5  
 
r,   rl  r.   g        r  )<r8   r   __all__r   r=   r   rU   r\   rd   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r(  r1  r:  r@  rl  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   r4   r,   r)   <module>r     s?  B  F2 2:,N ,N^.4*
: *
Z%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,   