
    קgK                        d Z ddlZg dZ G d d          Z G d de          Zd Z G d	 d
ee          Z G d de          Z G d de          Z	 G d de          Z
 G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z G d! d"e          Z G d# d$e          Z G d% d&e          Z G d' d(e          Z G d) d*e          Z G d+ d,e          Z G d- d.e          Z G d/ d0e          Z G d1 d2e          Z G d3 d4e          Z G d5 d6e          Z G d7 d8e          Z e            ZeZ eZ! e	            Z" e
            Z# ed          Z$ ed9          Z%eZ& e            Z' e!e'd9          Z( ed:          Z) ed:          Z*eZ+eZ,eZ-eZ. ed:d;          Z/eZ0eZ1 e            Z2 e            Z3 e            Z4 e            Z5 e            Z6 e            Z7 e            Z8 e            Z9eZ:eZ;dS )<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                   &    e Zd ZdZdZdZd Zd ZdS )r   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                     t           )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-engine/env/lib/python3.11/site-packages/torch/distributions/constraints.pycheckzConstraint.check[   s
    
 "!    c                 0    | j         j        dd          dz   S )N   z())	__class____name__r&   s    r(   __repr__zConstraint.__repr__b   s    ~&qrr*T11r*   N)r.   
__module____qualname____doc__is_discrete	event_dimr)   r0    r*   r(   r   r   I   sH          KI" " "2 2 2 2 2r*   r   c                   j     e Zd ZdZeed fd
Zed             Zed             ZeeddZ	d Z
 xZS )
_DependentaI  
    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.
    r4   r5   c                d    || _         || _        t                                                       d S N)_is_discrete
_event_dimsuper__init__)r&   r4   r5   r-   s      r(   r?   z_Dependent.__init__t   s.    '#r*   c                 J    | j         t          u rt          d          | j         S )Nz,.is_discrete cannot be determined statically)r<   NotImplementedr$   r/   s    r(   r4   z_Dependent.is_discretey   s(    ..%&TUUU  r*   c                 J    | j         t          u rt          d          | j         S )Nz*.event_dim cannot be determined statically)r=   rA   r$   r/   s    r(   r5   z_Dependent.event_dim   s&    ?n,,%&RSSSr*   c                d    |t           u r| j        }|t           u r| j        }t          ||          S )z
        Support for syntax to customize static attributes::

            constraints.dependent(is_discrete=True, event_dim=1)
        r9   )rA   r<   r=   r8   )r&   r4   r5   s      r(   __call__z_Dependent.__call__   s<     .((+K&&IkYGGGGr*   c                      t          d          )Nz1Cannot determine validity of dependent constraint)
ValueErrorr&   xs     r(   r)   z_Dependent.check   s    LMMMr*   )r.   r1   r2   r3   rA   r?   propertyr4   r5   rD   r)   __classcell__r-   s   @r(   r8   r8   f   s          '5       
 ! ! X!
   X
 '5 
H 
H 
H 
H 
HN N N N N N Nr*   r8   c                 ,    t          | t                    S )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
    )
isinstancer8   )
constraints    r(   r   r      s    . j*---r*   c                   4     e Zd ZdZ	 deed fdZd Z xZS )_DependentPropertya  
    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.
    Nr9   c                f    t                                          |           || _        || _        d S r;   )r>   r?   r<   r=   )r&   fnr4   r5   r-   s       r(   r?   z_DependentProperty.__init__   s0     	'#r*   c                 :    t          || j        | j                  S )z
        Support for syntax to customize static attributes::

            @constraints.dependent_property(is_discrete=True, event_dim=1)
            def support(self):
                ...
        r9   )rP   r<   r=   )r&   rR   s     r(   rD   z_DependentProperty.__call__   s'     "D-
 
 
 	
r*   r;   )r.   r1   r2   r3   rA   r?   rD   rJ   rK   s   @r(   rP   rP      sj         2 $&4$ $ $ $ $ $ $

 

 

 

 

 

 

r*   rP   c                   Z     e Zd ZdZ fdZed             Zed             Zd Zd Z	 xZ
S )_IndependentConstraintz
    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                     t          |t                    sJ t          |t                    sJ |dk    sJ || _        || _        t                                                       d S Nr   )rM   r   intbase_constraintreinterpreted_batch_ndimsr>   r?   )r&   rY   rZ   r-   s      r(   r?   z_IndependentConstraint.__init__   sm    /:666663S99999(A----.)B&r*   c                     | j         j        S r;   )rY   r4   r/   s    r(   r4   z"_IndependentConstraint.is_discrete   s    #//r*   c                 *    | j         j        | j        z   S r;   )rY   r5   rZ   r/   s    r(   r5   z _IndependentConstraint.event_dim   s    #-0NNNr*   c                    | j                             |          }|                                | j        k     r;| j         j        | j        z   }t          d| d|                                           |                    |j        d |                                | j        z
           dz             }|                    d          }|S )NzExpected value.dim() >= z	 but got r_   )	rY   r)   dimrZ   r5   rF   reshapeshapeall)r&   r'   resultexpecteds       r(   r)   z_IndependentConstraint.check   s    %++E22::<<$888+58VVHK8KKeiikkKK   LH6::<<$*HHHIEQ
 
 Br*   c                 j    | j         j        dd           dt          | j                   d| j         dS )Nr,   (z, ))r-   r.   reprrY   rZ   r/   s    r(   r0   z_IndependentConstraint.__repr__   s=    .)!""-ooT5I0J0JoodNloooor*   )r.   r1   r2   r3   r?   rI   r4   r5   r)   r0   rJ   rK   s   @r(   rU   rU      s              0 0 X0 O O XO  p p p p p p pr*   rU   c                       e Zd ZdZdZd ZdS )_Booleanz/
    Constrain to the two values `{0, 1}`.
    Tc                     |dk    |dk    z  S )Nr   r,   r6   r%   s     r(   r)   z_Boolean.check  s    
uz**r*   N)r.   r1   r2   r3   r4   r)   r6   r*   r(   rk   rk     s4          K+ + + + +r*   rk   c                        e Zd ZdZdZdZd ZdS )_OneHotz'
    Constrain to one-hot vectors.
    Tr,   c                     |dk    |dk    z  }|                     d                              d          }|                    d          |z  S )Nr   r,   r_   )sumeqrc   )r&   r'   
is_booleanis_normalizeds       r(   r)   z_OneHot.check  sH    qjUaZ0
		"((++~~b!!M11r*   N)r.   r1   r2   r3   r4   r5   r)   r6   r*   r(   rn   rn     s9          KI2 2 2 2 2r*   rn   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )_IntegerIntervalzH
    Constrain to an integer interval `[lower_bound, upper_bound]`.
    Tc                 d    || _         || _        t                                                       d S r;   lower_boundupper_boundr>   r?   r&   rx   ry   r-   s      r(   r?   z_IntegerInterval.__init__$  /    &&r*   c                 D    |dz  dk    | j         |k    z  || j        k    z  S Nr,   r   rx   ry   r%   s     r(   r)   z_IntegerInterval.check)  s,    QY!^ 0E 9:etGW>WX	
r*   c                 Z    | j         j        dd          }|d| j         d| j         dz  }|S Nr,   (lower_bound=z, upper_bound=rh   r-   r.   rx   ry   r&   
fmt_strings     r(   r0   z_IntegerInterval.__repr__.  C    ^,QRR0
OD,OOD<LOOO	

 r*   	r.   r1   r2   r3   r4   r?   r)   r0   rJ   rK   s   @r(   ru   ru     sg          K    

 
 

      r*   ru   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )_IntegerLessThanzA
    Constrain to an integer interval `(-inf, upper_bound]`.
    Tc                 V    || _         t                                                       d S r;   ry   r>   r?   r&   ry   r-   s     r(   r?   z_IntegerLessThan.__init__=  '    &r*   c                 ,    |dz  dk    || j         k    z  S r}   ry   r%   s     r(   r)   z_IntegerLessThan.checkA      	Q5D,<#<==r*   c                 J    | j         j        dd          }|d| j         dz  }|S Nr,   z(upper_bound=rh   r-   r.   ry   r   s     r(   r0   z_IntegerLessThan.__repr__D  4    ^,QRR0
9d&69999
r*   r   rK   s   @r(   r   r   6  g          K    > > >      r*   r   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )_IntegerGreaterThanz@
    Constrain to an integer interval `[lower_bound, inf)`.
    Tc                 V    || _         t                                                       d S r;   rx   r>   r?   r&   rx   r-   s     r(   r?   z_IntegerGreaterThan.__init__Q  r   r*   c                 ,    |dz  dk    || j         k    z  S r}   rx   r%   s     r(   r)   z_IntegerGreaterThan.checkU  r   r*   c                 J    | j         j        dd          }|d| j         dz  }|S Nr,   r   rh   r-   r.   rx   r   s     r(   r0   z_IntegerGreaterThan.__repr__X  r   r*   r   rK   s   @r(   r   r   J  r   r*   r   c                       e Zd ZdZd ZdS )_RealzF
    Trivially constrain to the extended real line `[-inf, inf]`.
    c                     ||k    S r;   r6   r%   s     r(   r)   z_Real.checkc  s    ~r*   N)r.   r1   r2   r3   r)   r6   r*   r(   r   r   ^  s-             r*   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )_GreaterThanz=
    Constrain to a real half line `(lower_bound, inf]`.
    c                 V    || _         t                                                       d S r;   r   r   s     r(   r?   z_GreaterThan.__init__l  r   r*   c                     | j         |k     S r;   r   r%   s     r(   r)   z_GreaterThan.checkp  s    %''r*   c                 J    | j         j        dd          }|d| j         dz  }|S r   r   r   s     r(   r0   z_GreaterThan.__repr__s  r   r*   r.   r1   r2   r3   r?   r)   r0   rJ   rK   s   @r(   r   r   g  `             ( ( (      r*   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )_GreaterThanEqz=
    Constrain to a real half line `[lower_bound, inf)`.
    c                 V    || _         t                                                       d S r;   r   r   s     r(   r?   z_GreaterThanEq.__init__~  r   r*   c                     | j         |k    S r;   r   r%   s     r(   r)   z_GreaterThanEq.check  s    5((r*   c                 J    | j         j        dd          }|d| j         dz  }|S r   r   r   s     r(   r0   z_GreaterThanEq.__repr__  r   r*   r   rK   s   @r(   r   r   y  s`             ) ) )      r*   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )	_LessThanz>
    Constrain to a real half line `[-inf, upper_bound)`.
    c                 V    || _         t                                                       d S r;   r   r   s     r(   r?   z_LessThan.__init__  r   r*   c                     || j         k     S r;   r   r%   s     r(   r)   z_LessThan.check  s    t'''r*   c                 J    | j         j        dd          }|d| j         dz  }|S r   r   r   s     r(   r0   z_LessThan.__repr__  r   r*   r   rK   s   @r(   r   r     r   r*   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )	_IntervalzD
    Constrain to a real interval `[lower_bound, upper_bound]`.
    c                 d    || _         || _        t                                                       d S r;   rw   rz   s      r(   r?   z_Interval.__init__  r{   r*   c                 0    | j         |k    || j        k    z  S r;   r~   r%   s     r(   r)   z_Interval.check  s     E)et7G.GHHr*   c                 Z    | j         j        dd          }|d| j         d| j         dz  }|S r   r   r   s     r(   r0   z_Interval.__repr__  r   r*   r   rK   s   @r(   r   r     sc             
I I I      r*   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )_HalfOpenIntervalzD
    Constrain to a real interval `[lower_bound, upper_bound)`.
    c                 d    || _         || _        t                                                       d S r;   rw   rz   s      r(   r?   z_HalfOpenInterval.__init__  r{   r*   c                 0    | j         |k    || j        k     z  S r;   r~   r%   s     r(   r)   z_HalfOpenInterval.check  s     E)ed6F.FGGr*   c                 Z    | j         j        dd          }|d| j         d| j         dz  }|S r   r   r   s     r(   r0   z_HalfOpenInterval.__repr__  r   r*   r   rK   s   @r(   r   r     sc             
H H H      r*   r   c                       e Zd ZdZdZd ZdS )_Simplexz
    Constrain to the unit simplex in the innermost (rightmost) dimension.
    Specifically: `x >= 0` and `x.sum(-1) == 1`.
    r,   c                     t          j        |dk    d          |                    d          dz
                                  dk     z  S )Nr   r_   r`   r,   ư>)torchrc   rp   absr%   s     r(   r)   z_Simplex.check  s@    y!,,,21B0G0G0I0ID0PQQr*   Nr.   r1   r2   r3   r5   r)   r6   r*   r(   r   r     s9         
 IR R R R Rr*   r   c                   &    e Zd ZdZdZdZd Zd ZdS )_Multinomiala3  
    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                     || _         d S r;   r   )r&   ry   s     r(   r?   z_Multinomial.__init__  s    &r*   c                 v    |dk                         d          |                    d          | j        k    z  S )Nr   r_   r   )rc   rp   ry   rG   s     r(   r)   z_Multinomial.check  s3    Q|||##quuu}}8H'HIIr*   N)r.   r1   r2   r3   r4   r5   r?   r)   r6   r*   r(   r   r     sM          KI' ' 'J J J J Jr*   r   c                       e Zd ZdZdZd ZdS )_LowerTriangularz8
    Constrain to lower-triangular square matrices.
       c                     |                                 }||k                        |j        d d         dz                                 d          d         S )Nr^   r_   r   )trilviewrb   min)r&   r'   
value_trils      r(   r)   z_LowerTriangular.check  sK    ZZ\\
e#))%+crc*:U*BCCGGKKANNr*   Nr   r6   r*   r(   r   r     s9          IO O O O Or*   r   c                       e Zd ZdZdZd ZdS )_LowerCholeskyzP
    Constrain to lower-triangular square matrices with positive diagonals.
    r   c                     |                                 }||k                        |j        d d         dz                                 d          d         }|                    dd          dk                        d          d         }||z  S )Nr   r^   r_   r   )dim1dim2)r   r   rb   r   diagonal)r&   r'   r   r   positive_diagonals        r(   r)   z_LowerCholesky.check  s    ZZ\\
5 &&u{3B3'7%'?@@DDRHHK 	 #^^"^==AFFrJJ1M"333r*   Nr   r6   r*   r(   r   r     s4          I4 4 4 4 4r*   r   c                       e Zd ZdZdZd ZdS )_CorrCholeskyz}
    Constrain to lower-triangular square matrices with positive diagonals and each
    row vector being of unit length.
    r   c                    t          j        |j                  j        |                    d          z  dz  }t           j                            |                                d          }|dz
                                  	                    |          
                    d          }t                                          |          |z  S )Nr_   
   r         ?)r   finfodtypeepssizelinalgnormdetachr   lerc   r   r)   )r&   r'   tolrow_normunit_row_norms        r(   r)   z_CorrCholesky.check  s    K$$(5::b>>9B> 	 <$$U\\^^$<<!C,,..11#66::r:BB%%e,,}<<r*   Nr   r6   r*   r(   r   r     s4         
 I= = = = =r*   r   c                       e Zd ZdZdZd ZdS )_Squarez'
    Constrain to square matrices.
    r   c                     t          j        |j        d d         |j        d         |j        d         k    t           j        |j                  S )Nr   r_   )r   
fill_valuer   device)r   fullrb   boolr   r%   s     r(   r)   z_Square.check  sG    zSbS!B5;r?:*<	
 
 
 	
r*   Nr   r6   r*   r(   r   r     s4          I
 
 
 
 
r*   r   c                   "     e Zd ZdZ fdZ xZS )
_Symmetricz1
    Constrain to Symmetric square matrices.
    c                     t                                          |          }|                                s|S t          j        ||j        d                              d                              d          S )Nr   )atolr   r_   )r>   r)   rc   r   isclosemT)r&   r'   square_checkr-   s      r(   r)   z_Symmetric.check)  sg    ww}}U++!! 	 }UEH4888<<R@@DDRHHHr*   r.   r1   r2   r3   r)   rJ   rK   s   @r(   r   r   $  sK         I I I I I I I I Ir*   r   c                   "     e Zd ZdZ fdZ xZS )_PositiveSemidefinitez6
    Constrain to positive-semidefinite matrices.
    c                     t                                          |          }|                                s|S t          j                            |                              d                              d          S )Nr   r_   )r>   r)   rc   r   r   eigvalshger&   r'   	sym_checkr-   s      r(   r)   z_PositiveSemidefinite.check5  s`    GGMM%((	}} 	|$$U++..q1155b999r*   r   rK   s   @r(   r   r   0  B         : : : : : : : : :r*   r   c                   "     e Zd ZdZ fdZ xZS )_PositiveDefinitez2
    Constrain to positive-definite matrices.
    c                     t                                          |          }|                                s|S t          j                            |          j                            d          S rW   )r>   r)   rc   r   r   cholesky_exinforq   r   s      r(   r)   z_PositiveDefinite.checkA  sU    GGMM%((	}} 	|''..366q999r*   r   rK   s   @r(   r  r  <  r   r*   r  c                   V     e Zd ZdZd fd	Zed             Zed             Zd Z xZ	S )	_Catz
    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`.
    r   Nc                 h   t          d |D                       sJ t          |          | _        |dgt          | j                  z  }t          |          | _        t          | j                  t          | j                  k    sJ || _        t                                                       d S )Nc              3   @   K   | ]}t          |t                    V  d S r;   rM   r   .0cs     r(   	<genexpr>z _Cat.__init__.<locals>.<genexpr>P  ,      ;;:a,,;;;;;;r*   r,   )rc   listcseqlenlengthsr`   r>   r?   )r&   r  r`   r  r-   s       r(   r?   z_Cat.__init__O  s    ;;d;;;;;;;;JJ	?cC	NN*GG}}4<  C	NN2222r*   c                 >    t          d | j        D                       S )Nc              3   $   K   | ]}|j         V  d S r;   r4   r
  s     r(   r  z#_Cat.is_discrete.<locals>.<genexpr>[  $      44Q1=444444r*   anyr  r/   s    r(   r4   z_Cat.is_discreteY  !    44$)444444r*   c                 >    t          d | j        D                       S )Nc              3   $   K   | ]}|j         V  d S r;   r5   r
  s     r(   r  z!_Cat.event_dim.<locals>.<genexpr>_  s$      2211;222222r*   )maxr  r/   s    r(   r5   z_Cat.event_dim]  s!    22	222222r*   c                    |                                  | j         cxk    r|                                 k     sn J g }d}t          | j        | j                  D ]N\  }}|                    | j         ||          }|                    |                    |                     ||z   }Ot          j        || j                   S rW   )	r`   zipr  r  narrowappendr)   r   r   )r&   r'   checksstartconstrlengthvs          r(   r)   z
_Cat.checka  s    		|tx5555%))++555555!$)T\:: 	# 	#NFFTXuf55AMM&,,q//***FNEEy***r*   )r   N
r.   r1   r2   r3   r?   rI   r4   r5   r)   rJ   rK   s   @r(   r  r  H  s               5 5 X5 3 3 X3+ + + + + + +r*   r  c                   V     e Zd ZdZd fd	Zed             Zed             Zd Z xZ	S )_Stackz
    Constraint functor that applies a sequence of constraints
    `cseq` at the submatrices at dimension `dim`,
    in a way compatible with :func:`torch.stack`.
    r   c                     t          d |D                       sJ t          |          | _        || _        t	                                                       d S )Nc              3   @   K   | ]}t          |t                    V  d S r;   r	  r
  s     r(   r  z"_Stack.__init__.<locals>.<genexpr>t  r  r*   )rc   r  r  r`   r>   r?   )r&   r  r`   r-   s      r(   r?   z_Stack.__init__s  sV    ;;d;;;;;;;;JJ	r*   c                 >    t          d | j        D                       S )Nc              3   $   K   | ]}|j         V  d S r;   r  r
  s     r(   r  z%_Stack.is_discrete.<locals>.<genexpr>{  r  r*   r  r/   s    r(   r4   z_Stack.is_discretey  r  r*   c                 h    t          d | j        D                       }| j        |z   dk     r|dz  }|S )Nc              3   $   K   | ]}|j         V  d S r;   r  r
  s     r(   r  z#_Stack.event_dim.<locals>.<genexpr>  s$      11!!+111111r*   r   r,   )r  r  r`   )r&   r`   s     r(   r5   z_Stack.event_dim}  s?    11ty111118c>A1HC
r*   c                 R                                       j         cxk    r                                 k     sn J  fdt                               j                             D             }t          j        d t          | j                  D              j                   S )Nc                 F    g | ]}                     j        |          S r6   )selectr`   )r  ir&   r'   s     r(   
<listcomp>z _Stack.check.<locals>.<listcomp>  s)    MMMAell48Q''MMMr*   c                 >    g | ]\  }}|                     |          S r6   )r)   )r  r&  r$  s      r(   r4  z _Stack.check.<locals>.<listcomp>  s&    AAAFV\\!__AAAr*   )r`   ranger   r   r   r  r  )r&   r'   vss   `` r(   r)   z_Stack.check  s    		|tx5555%))++555555MMMMMuzz$(7K7K1L1LMMM{AAc"di.@.@AAA48
 
 	
r*   )r   r'  rK   s   @r(   r)  r)  l  s               5 5 X5   X
 
 
 
 
 
 
r*   r)  r,   g        r   )<r3   r   __all__r   r8   r   rI   rP   rU   rk   rn   ru   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   r   r   r	   r
   r   r   r!   r   r   r   r   r   r   r   r    r   r   r   r   r6   r*   r(   <module>r9     s   B      F2 2 2 2 2 2 2 2:,N ,N ,N ,N ,N ,N ,N ,N^. . .4*
 *
 *
 *
 *
: *
 *
 *
Z%p %p %p %p %pZ %p %p %pP+ + + + +z + + +2 2 2 2 2j 2 2 2    z   2    z   (    *   (    J       :   $    Z   $    
   $    
   *    
   *	R 	R 	R 	R 	Rz 	R 	R 	RJ J J J J: J J J&	O 	O 	O 	O 	Oz 	O 	O 	O4 4 4 4 4Z 4 4 4"= = = = =J = = ="
 
 
 
 
j 
 
 
 	I 	I 	I 	I 	I 	I 	I 	I	: 	: 	: 	: 	:J 	: 	: 	:	: 	: 	: 	: 	:
 	: 	: 	:!+ !+ !+ !+ !+: !+ !+ !+H
 
 
 
 
Z 
 
 
B JLL	' $
(**
'))))!,, &&q)) # uwwk$""<nS!! 		#s##& 
(**##%% !!	JLL	--// %%'' 
r*   