+
    &jX                     <   ^ RI Ht ^ RIHt  ^ RIt. RNRNRNRNRNR	NR
NRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#Nt ! R$ R4      t ! R% R&]4      tR' t ! R( R)]	]4      t
 ! R* R+]4      t ! R, R]4      t ! R- R.]4      t ! R/ R0]4      t ! R1 R2]4      t ! R3 R4]4      t ! R5 R6]4      t ! R7 R8]4      t ! R9 R:]4      t ! R; R<]4      t ! R= R>]4      t ! R? R@]4      t ! RA RB]4      t ! RC RD]4      t ! RE RF]4      t ! RG RH]4      t ! RI RJ]4      t ! RK RL]4      t ! RM RN]4      t ! RO RP]4      t ! RQ RR]4      t ! RS RT]4      t  ! RU RV]4      t! ! RW RX]4      t"]! 4       t#]
t$]t%]! 4       t&]! 4       t']! ^ 4      t(]! ^4      t)]t*]! 4       t+]%! ]+^4      t,]! RY4      t-]! RY4      t.]t/]t0]t1]t2]! RYRZ4      t3]t4]t5]! 4       t6]! 4       t7]! 4       t8]! 4       t9]! 4       t:]! 4       t;]! 4       t<] ! 4       t=]!t>]"t?R# )[    )Callable)AnyN
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MixtureSameFamilyConstraintmultinomialnonnegativenonnegative_integerone_hotpositivepositive_semidefinitepositive_definitepositive_integerrealreal_vectorsimplexsquarestack	symmetricunit_intervalc                   8   a  ] tR t^Pt o RtRt^ tR tR tRt	V t
R# )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.
Fc                    \         h)z{
Returns a byte tensor of ``sample_shape + batch_shape`` indicating
whether each event in value satisfies this constraint.
)NotImplementedErrorselfvalues   &&w/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/distributions/constraints.pycheckConstraint.checkb   s
    
 "!    c                J    V P                   P                  R ,          R,           # )   NNz())	__class____name__r)   s   &r+   __repr__Constraint.__repr__i   s    ~~&&r*T11r.    N)r3   
__module____qualname____firstlineno____doc__is_discrete	event_dimr,   r5   __static_attributes____classdictcell____classdict__s   @r+   r   r   P   s%      KI"2 2r.   c                      a a ] tR t^mt oRtR]R]/V 3R llt]V3R lR l4       t]V3R lR l4       t	R]R]/R	 lt
R
 tRtVtV ;t# )
_Dependenta!  
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               <   < Wn         W n        \        SV `  4        R # N)_is_discrete
_event_dimsuper__init__)r)   r<   r=   r2   s   &$$r+   rI   _Dependent.__init__{   s    '#r.   c                    < V ^8  d   QhRS[ /#    returnbool)formatrA   s   "r+   __annotate___Dependent.__annotate__   s     ! !T !r.   c                X    V P                   \        J d   \        R 4      hV P                   # )z,.is_discrete cannot be determined statically)rF   NotImplementedr'   r4   s   &r+   r<   _Dependent.is_discrete   s(    .%&TUU   r.   c                    < V ^8  d   QhRS[ /# rL   int)rQ   rA   s   "r+   rR   rS      s      3 r.   c                X    V P                   \        J d   \        R 4      hV P                   # )z*.event_dim cannot be determined statically)rG   rU   r'   r4   s   &r+   r=   _Dependent.event_dim   s$    ??n,%&RSSr.   c               r    V\         J d   V P                  pV\         J d   V P                  p\        WR7      # )zo
Support for syntax to customize static attributes::

    constraints.dependent(is_discrete=True, event_dim=1)
r<   r=   )rU   rF   rG   rC   )r)   r<   r=   s   &$$r+   __call___Dependent.__call__   s3     .(++K&IkGGr.   c                    \        R 4      h)z1Cannot determine validity of dependent constraint)
ValueErrorr)   xs   &&r+   r,   _Dependent.check   s    LMMr.   rG   rF   )r3   r8   r9   r:   r;   rU   rI   propertyr<   r=   r^   r,   r>   r?   __classcell__r2   rA   s   @@r+   rC   rC   m   sg     n  
 ! !
  

Hn 
H 
HN Nr.   rC   c                "    \        V \        4      # )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
)
isinstancerC   )
constraints   &r+   r   r      s    . j*--r.   c                   d   a a ] tR t^t oRtR	R]R]/V3R lV 3R lllltV3R lR ltRtVt	V ;t
# )
_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.
r<   r=   c                n   < V ^8  d   QhRS[ RS[3,          R,          RS[R,          RS[R,          RR/# )rM   fn.Nr<   r=   rN   )r   r   rP   rY   )rQ   rA   s   "r+   rR   _DependentProperty.__annotate__   sI     	$ 	$S#X%	$ D[		$
 :	$ 
	$r.   c               >   < \         SV `  V4       W n        W0n        R # rE   )rH   rI   rF   rG   )r)   ro   r<   r=   r2   s   &&$$r+   rI   _DependentProperty.__init__   s     	'#r.   c                8   < V ^8  d   QhRS[ RS[3,          RR/# )rM   ro   .rN   rm   )r   r   )rQ   rA   s   "r+   rR   rp      s%     	
 	
8CH- 	
2F 	
r.   c                D    \        WP                  V P                  R7      # )z
Support for syntax to customize static attributes::

    @constraints.dependent_property(is_discrete=True, event_dim=1)
    def support(self): ...
r]   )rm   rF   rG   )r)   ro   s   &&r+   r^   _DependentProperty.__call__   s      "--
 	
r.   re   rE   )r3   r8   r9   r:   r;   rU   rI   r^   r>   r?   rg   rh   s   @@r+   rm   rm      s7     2	$ $2		$
 !/	$ 	$	
 	
 	
r.   rm   c                   z   a a ] tR t^t oRtV 3R lt]V3R lR l4       t]V3R lR l4       tR t	R t
R	tVtV ;t# )
_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                B  < \        V\        4      '       g"   \        R \        V4      P                   24      h\        V\
        4      '       g"   \        R\        V4      P                   24      hV^ 8  d   \        RV 24      hWn        W n        \        SV `%  4        R# )*base_constraint must be a Constraint, got z.reinterpreted_batch_ndims must be an int, got z,reinterpreted_batch_ndims must be >= 0, got N)
rj   r   AssertionErrortyper3   rY   base_constraintreinterpreted_batch_ndimsrH   rI   )r)   r|   r}   r2   s   &&&r+   rI   _IndependentConstraint.__init__   s    /:66 <T/=R=[=[<\]  3S99 @F_A`AiAi@jk  %q( >?X>YZ   /)B&r.   c                    < V ^8  d   QhRS[ /# rL   rO   )rQ   rA   s   "r+   rR   #_IndependentConstraint.__annotate__        0 0T 0r.   c                .    V P                   P                  # rE   r|   r<   r4   s   &r+   r<   "_IndependentConstraint.is_discrete       ##///r.   c                    < V ^8  d   QhRS[ /# rL   rX   )rQ   rA   s   "r+   rR   r     s     O O3 Or.   c                P    V P                   P                  V P                  ,           # rE   )r|   r=   r}   r4   s   &r+   r=    _IndependentConstraint.event_dim  s    ##--0N0NNNr.   c                   V P                   P                  V4      pVP                  4       V P                  8  dG   V P                   P                  V P                  ,           p\        R V RVP                  4        24      hVP                  VP                  RVP                  4       V P                  ,
           R,           4      pVP                  R4      pV# )Expected value.dim() >= 	 but got Nr   )	r|   r,   dimr}   r=   ra   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                    V P                   P                  R ,           R\        V P                  4       RV P                   R2# )r0   (z, ))r2   r3   reprr|   r}   r4   s   &r+   r5   _IndependentConstraint.__repr__  s?    ..))"-.aT5I5I0J/K2dNlNlMmmnoor.   )r|   r}   r3   r8   r9   r:   r;   rI   rf   r<   r=   r,   r5   r>   r?   rg   rh   s   @@r+   rw   rw      sJ     " 0 0 O Op pr.   rw   c                   z   a a ] tR tRt oRtV 3R lt]V3R lR l4       t]V3R lR l4       tR t	R	 t
R
tVtV ;t# )r   i  av  
Constraint for the :class:`~torch.distribution.MixtureSameFamily`
distribution that adds back the rightmost batch dimension before
performing the validity check with the component distribution
constraint.

Args:
    base_constraint: The ``Constraint`` object of
        the component distribution of
        the :class:`~torch.distribution.MixtureSameFamily` distribution.
c                   < \        V\        4      '       g"   \        R \        V4      P                   24      hWn        \        SV `  4        R# )ry   N)rj   r   rz   r{   r3   r|   rH   rI   )r)   r|   r2   s   &&r+   rI   $MixtureSameFamilyConstraint.__init__%  sF    /:66 <T/=R=[=[<\]   /r.   c                    < V ^8  d   QhRS[ /# rL   rO   )rQ   rA   s   "r+   rR   (MixtureSameFamilyConstraint.__annotate__.  r   r.   c                .    V P                   P                  # rE   r   r4   s   &r+   r<   'MixtureSameFamilyConstraint.is_discrete-  r   r.   c                    < V ^8  d   QhRS[ /# rL   rX   )rQ   rA   s   "r+   rR   r   2  s     . .3 .r.   c                .    V P                   P                  # rE   )r|   r=   r4   s   &r+   r=   %MixtureSameFamilyConstraint.event_dim1  s    ##---r.   c                   VP                  RV P                  ,
          4      pV P                  P                  V4      pVP	                  4       V P                  8  d*   \        RV P                   RVP	                  4        24      hVP	                  4       V P                  ,
          pVP                  VP                  RV R,           4      pVP                  R4      pV# )z
Check validity of ``value`` as a possible outcome of sampling
the :class:`~torch.distribution.MixtureSameFamily` distribution.
r   r   Nr   r   )		unsqueezer=   r|   r,   r   ra   r   r   r   )r)   r*   unsqueezed_valuer   num_dim_to_keeps   &&   r+   r,   !MixtureSameFamilyConstraint.check5  s    
 !??2+>?%%++,<=99;'*4>>*:)EIIK=Q   ))+6-=o > FGBr.   c                `    V P                   P                   R \        V P                  4       R2# )r   r   )r2   r3   r   r|   r4   s   &r+   r5   $MixtureSameFamilyConstraint.__repr__E  s,    ..))*!D1E1E,F+GqIIr.   )r|   r   rh   s   @@r+   r   r     sH     
 0 0 . . J Jr.   c                   .   a  ] tR tRt o RtRtR tRtV tR# )_BooleaniI  z'
Constrain to the two values `{0, 1}`.
Tc                     V^ 8H  V^8H  ,          # r   r7   r(   s   &&r+   r,   _Boolean.checkP  s    
uz**r.   r7   N)	r3   r8   r9   r:   r;   r<   r,   r>   r?   r@   s   @r+   r   r   I  s      K+ +r.   r   c                   2   a  ] tR tRt o RtRt^tR tRtV t	R# )_OneHotiT  z
Constrain to one-hot vectors.
Tc                    V^ 8H  V^8H  ,          pVP                  R4      P                  ^4      pVP                  R4      V,          # r   r   )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>   r?   r@   s   @r+   r   r   T  s       KI2 2r.   r   c                   F   a a ] tR tRt oRtRtV 3R ltR tR tRt	Vt
V ;t# )_IntegerIntervalib  z@
Constrain to an integer interval `[lower_bound, upper_bound]`.
Tc                <   < Wn         W n        \        SV `  4        R # rE   lower_boundupper_boundrH   rI   r)   r   r   r2   s   &&&r+   rI   _IntegerInterval.__init__i      &&r.   c                h    V^,          ^ 8H  V P                   V8*  ,          WP                  8*  ,          # r1   r   r   r(   s   &&r+   r,   _IntegerInterval.checkn  s0    QY!^ 0 0E 9:eGWGW>WX	
r.   c                    V P                   P                  R ,          pVRV P                   RV P                   R2,          pV# r0   (lower_bound=z, upper_bound=r   r2   r3   r   r   r)   
fmt_strings   & r+   r5   _IntegerInterval.__repr__s  H    ^^,,R0
D,,-^D<L<L;MQO	

 r.   r   r3   r8   r9   r:   r;   r<   rI   r,   r5   r>   r?   rg   rh   s   @@r+   r   r   b  s%      K


 r.   r   c                   F   a a ] tR tRt oRtRtV 3R ltR tR tRt	Vt
V ;t# )_IntegerLessThani{  z9
Constrain to an integer interval `(-inf, upper_bound]`.
Tc                0   < Wn         \        SV `	  4        R # rE   r   rH   rI   r)   r   r2   s   &&r+   rI   _IntegerLessThan.__init__      &r.   c                @    V^,          ^ 8H  WP                   8*  ,          # r   r   r(   s   &&r+   r,   _IntegerLessThan.check      	Q5,<,<#<==r.   c                n    V P                   P                  R ,          pVRV P                   R2,          pV# r0   z(upper_bound=r   r2   r3   r   r   s   & r+   r5   _IntegerLessThan.__repr__  6    ^^,,R0
d&6&6%7q99
r.   r   r   rh   s   @@r+   r   r   {  %      K> r.   r   c                   F   a a ] tR tRt oRtRtV 3R ltR tR tRt	Vt
V ;t# )_IntegerGreaterThani  z8
Constrain to an integer interval `[lower_bound, inf)`.
Tc                0   < Wn         \        SV `	  4        R # rE   r   rH   rI   r)   r   r2   s   &&r+   rI   _IntegerGreaterThan.__init__  r   r.   c                @    V^,          ^ 8H  WP                   8  ,          # r   r   r(   s   &&r+   r,   _IntegerGreaterThan.check  r   r.   c                n    V P                   P                  R ,          pVRV P                   R2,          pV# r0   r   r   r2   r3   r   r   s   & r+   r5   _IntegerGreaterThan.__repr__  r   r.   r   r   rh   s   @@r+   r   r     r   r.   r   c                   *   a  ] tR tRt o RtR tRtV tR# )_Reali  z>
Trivially constrain to the extended real line `[-inf, inf]`.
c                
    W8H  # rE   r7   r(   s   &&r+   r,   _Real.check  s
    ~r.   r7   N)r3   r8   r9   r:   r;   r,   r>   r?   r@   s   @r+   r   r     s      r.   r   c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )_GreaterThani  z5
Constrain to a real half line `(lower_bound, inf]`.
c                0   < Wn         \        SV `	  4        R # rE   r   r   s   &&r+   rI   _GreaterThan.__init__  r   r.   c                     V P                   V8  # rE   r   r(   s   &&r+   r,   _GreaterThan.check  s    %''r.   c                n    V P                   P                  R ,          pVRV P                   R2,          pV# r   r   r   s   & r+   r5   _GreaterThan.__repr__  r   r.   r   r3   r8   r9   r:   r;   rI   r,   r5   r>   r?   rg   rh   s   @@r+   r   r          ( r.   r   c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )_GreaterThanEqi  z5
Constrain to a real half line `[lower_bound, inf)`.
c                0   < Wn         \        SV `	  4        R # rE   r   r   s   &&r+   rI   _GreaterThanEq.__init__  r   r.   c                     V P                   V8*  # rE   r   r(   s   &&r+   r,   _GreaterThanEq.check  s    5((r.   c                n    V P                   P                  R ,          pVRV P                   R2,          pV# r   r   r   s   & r+   r5   _GreaterThanEq.__repr__  r   r.   r   r   rh   s   @@r+   r   r     s     ) r.   r   c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )	_LessThani  z6
Constrain to a real half line `[-inf, upper_bound)`.
c                0   < Wn         \        SV `	  4        R # rE   r   r   s   &&r+   rI   _LessThan.__init__  r   r.   c                    WP                   8  # rE   r   r(   s   &&r+   r,   _LessThan.check  s    ''''r.   c                n    V P                   P                  R ,          pVRV P                   R2,          pV# r   r   r   s   & r+   r5   _LessThan.__repr__  r   r.   r   r   rh   s   @@r+   r  r    r   r.   r  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )	_Intervali  z<
Constrain to a real interval `[lower_bound, upper_bound]`.
c                <   < Wn         W n        \        SV `  4        R # rE   r   r   s   &&&r+   rI   _Interval.__init__  r   r.   c                F    V P                   V8*  WP                  8*  ,          # rE   r   r(   s   &&r+   r,   _Interval.check  s!      E)e7G7G.GHHr.   c                    V P                   P                  R ,          pVRV P                   RV P                   R2,          pV# r   r   r   s   & r+   r5   _Interval.__repr__  r   r.   r   r   rh   s   @@r+   r  r    s     
I r.   r  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )_HalfOpenIntervali  z<
Constrain to a real interval `[lower_bound, upper_bound)`.
c                <   < Wn         W n        \        SV `  4        R # rE   r   r   s   &&&r+   rI   _HalfOpenInterval.__init__  r   r.   c                F    V P                   V8*  WP                  8  ,          # rE   r   r(   s   &&r+   r,   _HalfOpenInterval.check  s!      E)e6F6F.FGGr.   c                    V P                   P                  R ,          pVRV P                   RV P                   R2,          pV# r   r   r   s   & r+   r5   _HalfOpenInterval.__repr__  r   r.   r   r   rh   s   @@r+   r  r    s     
H r.   r  c                   .   a  ] tR tRt o Rt^tR tRtV tR# )_Simplexi  zt
Constrain to the unit simplex in the innermost (rightmost) dimension.
Specifically: `x >= 0` and `x.sum(-1) == 1`.
c                    \         P                  ! V^ 8  RR7      VP                  R4      ^,
          P                  4       R8  ,          # )r   r   ư>r   )torchr   r   absr(   s   &&r+   r,   _Simplex.check  s7    yy!,21B0G0G0ID0PQQr.   r7   N	r3   r8   r9   r:   r;   r=   r,   r>   r?   r@   s   @r+   r  r    s     
 IR Rr.   r  c                   8   a  ] tR tRt o RtRt^tR tR tRt	V t
R# )_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``.
Tc                    Wn         R # rE   r   )r)   r   s   &&r+   rI   _Multinomial.__init__$  s    &r.   c                t    V^ 8  P                  RR7      VP                  RR7      V P                  8*  ,          # )r   r  r   )r   r   r   rb   s   &&r+   r,   _Multinomial.check'  s1    Q|||#quuu}8H8H'HIIr.   r   N)r3   r8   r9   r:   r;   r<   r=   rI   r,   r>   r?   r@   s   @r+   r&  r&    s'      KI'J Jr.   r&  c                   .   a  ] tR tRt o Rt^tR tRtV tR# )_LowerTriangulari+  z0
Constrain to lower-triangular square matrices.
c                    VP                  4       pW!8H  P                  VP                  R R R,           4      P                  R4      ^ ,          # )Nr   r   )trilviewr   min)r)   r*   
value_trils   && r+   r,   _LowerTriangular.check2  sA    ZZ\
#))%++cr*:U*BCGGKANNr.   r7   Nr$  r@   s   @r+   r,  r,  +  s      IO Or.   r,  c                   .   a  ] tR tRt o Rt^tR tRtV tR# )_LowerCholeskyi7  zH
Constrain to lower-triangular square matrices with positive diagonals.
c                   VP                  4       pW!8H  P                  VP                  R R R,           4      P                  R4      ^ ,          pVP	                  RRR7      ^ 8  P                  R4      ^ ,          pW4,          # )N)dim1dim2r.  r   r   )r/  r0  r   r1  diagonal)r)   r*   r2  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$  r@   s   @r+   r5  r5  7  s      I4 4r.   r5  c                   .   a  ] tR tRt o Rt^tR tRtV tR# )_CorrCholeskyiH  zq
Constrain to lower-triangular square matrices with positive diagonals and each
row vector being of unit length.
c                   \         P                  ! VP                  4      P                  VP	                  R4      ,          ^
,          p\         P
                  P                  VP                  4       RR7      pVR,
          P                  4       P                  V4      P                  RR7      p\        4       P                  V4      V,          # )r1   r        ?r   )r!  finfodtypeepssizelinalgnormdetachr"  ler   r5  r,   )r)   r*   tolrow_normunit_row_norms   &&   r+   r,   _CorrCholesky.checkP  s    KK$((5::b>9B> 	 <<$$U\\^$<!C,,.11#6::r:B%%e,}<<r.   r7   Nr$  r@   s   @r+   r=  r=  H  s     
 I= =r.   r=  c                   .   a  ] tR tRt o Rt^tR tRtV tR# )_SquareiY  z
Constrain to square matrices.
c                    \         P                  ! VP                  R R VP                  R,          VP                  R,          8H  \         P                  VP                  R7      # )N)rC  
fill_valuerA  devicer.  r   )r!  fullr   rP   rP  r(   s   &&r+   r,   _Square.check`  sG    zzSb!B5;;r?:**<<	
 	
r.   r7   Nr$  r@   s   @r+   rM  rM  Y  s      I
 
r.   rM  c                   6   a a ] tR tRt oRtV 3R ltRtVtV ;t# )
_Symmetricii  z)
Constrain to Symmetric square matrices.
c                   < \         SV `  V4      pVP                  4       '       g   V# \        P                  ! WP
                  R R7      P                  R4      P                  R4      # )r   )atolr.  r   )rH   r,   r   r!  isclosemT)r)   r*   square_checkr2   s   && r+   r,   _Symmetric.checkn  sQ    w}U+!!}}UHH48<<R@DDRHHr.   r7   	r3   r8   r9   r:   r;   r,   r>   r?   rg   rh   s   @@r+   rT  rT  i  s     I Ir.   rT  c                   6   a a ] tR tRt oRtV 3R ltRtVtV ;t# )_PositiveSemidefiniteiu  z.
Constrain to positive-semidefinite matrices.
c                   < \         SV `  V4      pVP                  4       '       g   V# \        P                  P                  V4      P                  ^ 4      P                  R4      # r   )rH   r,   r   r!  rD  eigvalshger)   r*   	sym_checkr2   s   && r+   r,   _PositiveSemidefinite.checkz  sM    GM%(	}}||$$U+..q155b99r.   r7   r[  rh   s   @@r+   r]  r]  u       : :r.   r]  c                   6   a a ] tR tRt oRtV 3R ltRtVtV ;t# )_PositiveDefinitei  z*
Constrain to positive-definite matrices.
c                   < \         SV `  V4      pVP                  4       '       g   V# \        P                  P                  V4      P                  P                  ^ 4      # r   )rH   r,   r   r!  rD  cholesky_exinfor   ra  s   && r+   r,   _PositiveDefinite.check  sH    GM%(	}}||''.3366q99r.   r7   r[  rh   s   @@r+   rf  rf    rd  r.   rf  c                   x   a a ] tR tRt oRtR
V 3R llt]V3R lR l4       t]V3R lR l4       tR t	R	t
VtV ;t# )_Cati  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                  < \         ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       g   \        R4      h\        V4      V n        Vf   ^.\	        V P                  4      ,          p\        V4      V n        \	        V P
                  4      \	        V P                  4      8w  d9   \        R\	        V P
                  4       R\	        V P                  4       R24      hW n        \        SV `!  4        R# )c              3   B   "   T F  p\        V\        4      x  K  	  R # 5irE   rj   r   .0cs   & r+   	<genexpr> _Cat.__init__.<locals>.<genexpr>       ;d:a,,d   FT1All elements of cseq must be Constraint instancesNz	lengths (z) must match cseq (r   )	r   rz   listcseqlenlengthsr   rH   rI   )r)   ry  r   r{  r2   s   &&&&r+   rI   _Cat.__init__  s    s;d;sss;d;;; !TUUJ	?cC		N*GG}t||DII. C-..A#dii.AQQRS  r.   c                    < V ^8  d   QhRS[ /# rL   rO   )rQ   rA   s   "r+   rR   _Cat.__annotate__       5 5T 5r.   c                    \         ;QJ d&    R  V P                   4       F  '       g   K   R# 	  R# ! R  V P                   4       4      # )c              3   8   "   T F  qP                   x  K  	  R # 5irE   r<   rp  s   & r+   rs  #_Cat.is_discrete.<locals>.<genexpr>       4)Q==)   TFanyry  r4   s   &r+   r<   _Cat.is_discrete  3    s4$))4ss4s4s4$))444r.   c                    < V ^8  d   QhRS[ /# rL   rX   )rQ   rA   s   "r+   rR   r~    s     3 33 3r.   c                :    \        R  V P                   4       4      # )c              3   8   "   T F  qP                   x  K  	  R # 5irE   r=   rp  s   & r+   rs  !_Cat.event_dim.<locals>.<genexpr>  s     2	1;;	r  )maxry  r4   s   &r+   r=   _Cat.event_dim  s    2		222r.   c                   VP                  4       ) V P                   u;8:  d   VP                  4       8  g-   M \        R V P                    RVP                  4        R24      h. p^ p\        V P                  V P                  4       FI  w  rEVP                  V P                   W54      pVP                  VP                  V4      4       W5,           pKK  	  \        P                  ! W P                   4      # zdim z out of range for value with z dimensions)
r   rz   zipry  r{  narrowappendr,   r!  r   )r)   r*   checksstartconstrlengthvs   &&     r+   r,   
_Cat.check  s    6599;6 txxj =eiik]+V  !$))T\\:NFTXXu5AMM&,,q/*NE ; yy**r.   )ry  r   r{  )r   Nr3   r8   r9   r:   r;   rI   rf   r<   r=   r,   r>   r?   rg   rh   s   @@r+   rl  rl    sA      5 5 3 3+ +r.   rl  c                   x   a a ] tR tRt oRtR
V 3R llt]V3R lR l4       t]V3R lR l4       tR t	R	t
VtV ;t# )_Stacki  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                   < \         ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       g   \        R4      h\        V4      V n        W n        \
        SV `  4        R# )c              3   B   "   T F  p\        V\        4      x  K  	  R # 5irE   ro  rp  s   & r+   rs  "_Stack.__init__.<locals>.<genexpr>  ru  rv  FTrw  N)r   rz   rx  ry  r   rH   rI   )r)   ry  r   r2   s   &&&r+   rI   _Stack.__init__  sK    s;d;sss;d;;; !TUUJ	r.   c                    < V ^8  d   QhRS[ /# rL   rO   )rQ   rA   s   "r+   rR   _Stack.__annotate__  r  r.   c                    \         ;QJ d&    R  V P                   4       F  '       g   K   R# 	  R# ! R  V P                   4       4      # )c              3   8   "   T F  qP                   x  K  	  R # 5irE   r  rp  s   & r+   rs  %_Stack.is_discrete.<locals>.<genexpr>  r  r  TFr  r4   s   &r+   r<   _Stack.is_discrete  r  r.   c                    < V ^8  d   QhRS[ /# rL   rX   )rQ   rA   s   "r+   rR   r    s      3 r.   c                    \        R  V P                   4       4      pV P                  V,           ^ 8  d
   V^,          pV# )c              3   8   "   T F  qP                   x  K  	  R # 5irE   r  rp  s   & r+   rs  #_Stack.event_dim.<locals>.<genexpr>  s     1y!++yr  )r  ry  r   )r)   r   s   & r+   r=   _Stack.event_dim  s4    1tyy1188c>A1HC
r.   c           	     "   VP                  4       ) V P                   u;8:  d   VP                  4       8  g-   M \        R V P                    RVP                  4        R24      h\        VP                  V P                   4      4       Uu. uF  q!P	                  V P                   V4      NK   	  pp\
        P                  ! \        W0P                  4       UUu. uF  w  rEVP                  V4      NK  	  uppV P                   4      # u upi u uppi r  )
r   rz   rangerC  selectr!  r"   r  ry  r,   )r)   r*   ivsr  r  s   &&    r+   r,   _Stack.check  s    6599;6 txxj =eiik]+V  27uzz$((7K1LM1LAll488Q'1LM{{.1"ii.@A.@V\\!_.@A488
 	
 NAs   	$DD
)ry  r   r   r  rh   s   @@r+   r  r    sA      5 5  
 
r.   r  g        r?  )@collections.abcr   typingr   r!  __all__r   rC   r   rf   rm   rw   r   r   r   r   r   r   r   r   r   r  r  r  r  r&  r,  r5  r=  rM  rT  r]  rf  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   r"   r7   r.   r+   <module>r     s   %  D !!! 
! 	!
 ! ! ! ! ! ! ! ! ! ! !  !!" "#!$ %!& '!( )!* +!, -!. /!0 1!2 3!4 5!6 7!8 9!: ;!< =!> ?!@ A!H2 2:,N ,N^.4.
: .
b.pZ .pb.J* .Jb+z +2j 2z 2z (* (J : $Z $
 $
 *
 *	Rz 	RJ: J&	Oz 	O4Z 4"=J ="
j 
 	I 	I	:J 	:	:
 	:(+: (+V!
Z !
J L	' $
*
))!, &q) # w$"S! 	#s#& 
*#% !	L	-/ %' 
r.   