+
    –°³j=#  ã                   ó‚   € ^ RI t ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	H
t
 ^ RIHt ^ RIHt R	.t ! R
 R	]4      tR# )é    N)ÚTensor)Úconstraints)ÚDistribution)ÚIndependent)ÚComposeTransformÚ	Transform)Ú_sum_rightmost)Ú_sizeÚTransformedDistributionc                   ó,  a a€ ] tR t^t oRt/ tRV3R lV 3R llltRV 3R llt]P                  ! RR7      R 4       t
]V3R lR	 l4       t]P                  ! 4       3R
 lt]P                  ! 4       3V3R lR lltR tR tR tR tV3R ltRtVtV ;t# )r   aI  
Extension of the Distribution class, which applies a sequence of Transforms
to a base distribution.  Let f be the composition of transforms applied::

    X ~ BaseDistribution
    Y = f(X) ~ TransformedDistribution(BaseDistribution, f)
    log p(Y) = log p(X) + log |det (dX/dY)|

Note that the ``.event_shape`` of a :class:`TransformedDistribution` is the
maximum shape of its base distribution and its transforms, since transforms
can introduce correlations among events.

An example for the usage of :class:`TransformedDistribution` would be::

    # Building a Logistic Distribution
    # X ~ Uniform(0, 1)
    # f = a + b * logit(X)
    # Y ~ f(X) ~ Logistic(a, b)
    base_distribution = Uniform(0, 1)
    transforms = [SigmoidTransform().inv, AffineTransform(loc=a, scale=b)]
    logistic = TransformedDistribution(base_distribution, transforms)

For more examples, please look at the implementations of
:class:`~torch.distributions.gumbel.Gumbel`,
:class:`~torch.distributions.half_cauchy.HalfCauchy`,
:class:`~torch.distributions.half_normal.HalfNormal`,
:class:`~torch.distributions.log_normal.LogNormal`,
:class:`~torch.distributions.pareto.Pareto`,
:class:`~torch.distributions.weibull.Weibull`,
:class:`~torch.distributions.relaxed_bernoulli.RelaxedBernoulli` and
:class:`~torch.distributions.relaxed_categorical.RelaxedOneHotCategorical`
c                ó^   <€ V ^8„  d   QhRS[ RS[S[S[,          ,          RS[R,          RR/# )é   Úbase_distributionÚ
transformsÚvalidate_argsNÚreturn)r   r   ÚlistÚbool)ÚformatÚ__classdict__s   "€Úm/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributions/transformed_distribution.pyÚ__annotate__Ú$TransformedDistribution.__annotate__4   sF   ø€ ÷ :Pñ :Pá'ð:Pñ ¡¡Y¥Õ/ð:Pñ ˜d•{ð	:Pð
 
ñ:Pó    c                ó¨  <€ \        V\        4      '       d
   V.V n        Mp\        V\        4      '       dM   \        ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       g   \        R4      hW n        M\        RV 24      hVP                  VP                  ,           p\        VP                  4      p\        V P                  4      p\        V4      VP                  P                  8  d'   \        RVP                  P                   RV R24      hVP                  V4      pVP                  V4      pWH8w  d'   VR\        V4      V,
           p	VP                  V	4      pVP                  P                  V,
          p
V
^ 8”  d   \        W4      pWn        VP"                  P                  VP                  P                  ,
          p\%        VP"                  P                  W[,           4      p\        V4      V8  d   \'        R	\        V4       R
V 24      h\        V4      V,
          pVRV pW}R p\(        SV `U  WïVR7       R# )c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5i©N)Ú
isinstancer   )Ú.0Úts   & r   Ú	<genexpr>Ú3TransformedDistribution.__init__.<locals>.<genexpr>?   s   é € ÐD¹°A”z !¤Y×/Ð/»ùs   ‚FTz6transforms must be a Transform or a list of Transformsz0transforms must be a Transform or list, but was z9base_distribution needs to have shape with size at least z
, but got Ú.Nzforward_shape length z must be >= event_dim ©r   )r   r   r   r   ÚallÚ
ValueErrorÚbatch_shapeÚevent_shapeÚlenr   ÚdomainÚ	event_dimÚforward_shapeÚinverse_shapeÚexpandr   Ú	base_distÚcodomainÚmaxÚAssertionErrorÚsuperÚ__init__)Úselfr   r   r   Ú
base_shapeÚbase_event_dimÚ	transformr,   Úexpanded_base_shapeÚbase_batch_shapeÚreinterpreted_batch_ndimsÚtransform_change_in_event_dimr+   Úcutr'   r(   Ú	__class__s   &&&&            €r   r4   Ú TransformedDistribution.__init__4   s>  ø€ ô �j¤)×,Ò,àðˆD�Oô ˜
¤D×)Ò)ß“3ÑD¹ÓD—3—3’3ÑD¹ÓD×DÒDÜ ØLóð ð )�OäØBÀ:À,ÐOóð ð
 '×2Ñ2Ð5F×5RÑ5RÕRˆ
ÜÐ.×:Ñ:Ó;ˆÜ$ T§_¡_Ó5ˆ	Üˆz‹?˜Y×-Ñ-×7Ñ7Ô7ÜØKÈI×L\ÑL\×LfÑLfÐKgÐgqÐr|Ðq}Ð}~Ðóð ð "×/Ñ/°
Ó;ˆØ'×5Ñ5°mÓDÐØÔ,Ø2Ø;”#Ð)Ó*¨^Õ;ð Ðð !2× 8Ñ 8Ð9IÓ JÐØ$-×$4Ñ$4×$>Ñ$>ÀÕ$OÐ!Ø$ qÔ(Ü +Ø!ó!Ðð +Œð ×Ñ×(Ñ(¨9×+;Ñ+;×+EÑ+EÕEð 	&ô Ø×Ñ×(Ñ(ØÕ:ó
ˆ	ô ˆ}Ó 	Ô)Ü Ø'¬¨MÓ(:Ð';Ð;QÐR[ÐQ\Ð]óð ô �-Ó  9Õ,ˆØ# D SÐ)ˆØ# DÐ)ˆÜ‰Ñ˜ÀÐÖOr   c                ó  <€ V P                  \        V4      p\        P                  ! V4      pWP                  ,           p\        V P                  4       F  pVP                  V4      pK  	  VR \        V4      \        V P                  P                  4      ,
           pV P                  P                  V4      Vn	        V P                  Vn        \        \        V`3  WP                  RR7       V P                  Vn        V# )NFr$   )Ú_get_checked_instancer   ÚtorchÚSizer(   Úreversedr   r-   r)   r/   r.   r3   r4   Ú_validate_args)r5   r'   Ú	_instanceÚnewÚshaper    r:   r>   s   &&&    €r   r.   ÚTransformedDistribution.expandp   sÐ   ø€ Ø×(Ñ(Ô)@À)ÓLˆÜ—j’j Ó-ˆØ×.Ñ.Õ.ˆÜ˜$Ÿ/™/Ö*ˆAØ—O‘O EÓ*ŠEñ +à Ð!O¤3 u£:´°D·N±N×4NÑ4NÓ0OÕ#OÐPÐØŸ™×-Ñ-Ð.>Ó?ˆŒØŸ™ˆŒÜÔ% sÑ4Ø×)Ñ)¸ð 	5ô 	
ð "×0Ñ0ˆÔØˆ
r   F)Úis_discretec                óN  € V P                   '       g   V P                  P                  # V P                   R,          P                  p\	        V P
                  4      VP                  8”  d<   \        P                  ! V\	        V P
                  4      VP                  ,
          4      pV# )é   éÿÿÿÿ)	r   r/   Úsupportr0   r)   r(   r+   r   Úindependent)r5   rN   s   & r   rN   ÚTransformedDistribution.support   s|   € ð ��ˆØ—>‘>×)Ñ)Ð)Ø—/‘/ "Õ%×.Ñ.ˆÜˆt×ÑÓ  7×#4Ñ#4Ô4Ü!×-Ò-Øœ˜T×-Ñ-Ó.°×1BÑ1BÕBóˆGð ˆr   c                ó    <€ V ^8„  d   QhRS[ /# )r   r   )r   )r   r   s   "€r   r   r   Œ   s   ø€ ÷ *ñ *™Tñ *r   c                ó.   € V P                   P                  # r   )r/   Úhas_rsample)r5   s   &r   rS   Ú#TransformedDistribution.has_rsample‹   s   € à�~‰~×)Ñ)Ð)r   c                óê   € \         P                  ! 4       ;_uu_ 4        V P                  P                  V4      pV P                   F  pV! V4      pK  	  VuuRRR4       #   + '       g   i     R# ; i)zÜ
Generates a sample_shape shaped sample or sample_shape shaped batch of
samples if the distribution parameters are batched. Samples first from
base distribution and applies `transform()` for every transform in the
list.
N)rB   Úno_gradr/   Úsampler   ©r5   Úsample_shapeÚxr8   s   &&  r   rW   ÚTransformedDistribution.sample�   sI   € ô �]Š]�_�_Ø—‘×%Ñ% lÓ3ˆAØ!Ÿ_œ_�	Ù˜a“L’ñ -à÷	 �_�_‹_ús   ž8A!Á!A2	c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   rY   r   )r
   r   )r   r   s   "€r   r   r   œ   s   ø€ ÷ 
ñ 
¡Eð 
¹Vñ 
r   c                ór   € V P                   P                  V4      pV P                   F  pV! V4      pK  	  V# )zü
Generates a sample_shape shaped reparameterized sample or sample_shape
shaped batch of reparameterized samples if the distribution parameters
are batched. Samples first from base distribution and applies
`transform()` for every transform in the list.
)r/   Úrsampler   rX   s   &&  r   r^   ÚTransformedDistribution.rsampleœ   s4   € ð �N‰N×"Ñ" <Ó0ˆØŸœˆIÙ˜!“ŠAñ )àˆr   c                ób  € V P                   '       d   V P                  V4       \        V P                  4      pRpTp\	        V P
                  4       F‰  pVP                  V4      pW%P                  P                  VP                  P                  ,
          ,          pV\        VP                  Wd4      W%P                  P                  ,
          4      ,
          pTpK‹  	  V\        V P                  P                  V4      V\        V P                  P                  4      ,
          4      ,           pV# )z�
Scores the sample by inverting the transform(s) and computing the score
using the score of the base distribution and the log abs det jacobian.
g        )rE   Ú_validate_sampler)   r(   rD   r   Úinvr*   r+   r0   r	   Úlog_abs_det_jacobianr/   Úlog_prob)r5   Úvaluer+   rd   Úyr8   rZ   s   &&     r   rd   Ú TransformedDistribution.log_prob¨   sø   € ð
 ××ÐØ×!Ñ! %Ô(Ü˜×(Ñ(Ó)ˆ	Ø#&ˆØˆÜ! $§/¡/Ö2ˆIØ—‘˜aÓ ˆAØ×)Ñ)×3Ñ3°i×6HÑ6H×6RÑ6RÕRÕRˆIØ¤.Ø×.Ñ.¨qÓ4Ø×,Ñ,×6Ñ6Õ6ó#õ ˆHð ŠAñ 3ð œnØ�N‰N×#Ñ# AÓ&¨	´C¸¿¹×8RÑ8RÓ4SÕ(Só
õ 
ˆð ˆr   c                óº   € ^pV P                    F  pW#P                  ,          pK  	  \        V\        4      '       d
   V^8X  d   V# W!R,
          ,          R,           # )z]
This conditionally flips ``value -> 1-value`` to ensure :meth:`cdf` is
monotone increasing.
g      à?)r   Úsignr   Úint)r5   re   ri   r8   s   &&  r   Ú_monotonize_cdfÚ'TransformedDistribution._monotonize_cdfÀ   sM   € ð
 ˆØŸœˆIØŸ.™.Õ(ŠDñ )ä�dœC× Ò  T¨Q¤YØˆLØ˜s•{Õ# cÕ)Ð)r   c                ó  € V P                   RRR1,           F  pVP                  V4      pK  	  V P                  '       d   V P                  P	                  V4       V P                  P                  V4      pV P                  V4      pV# )z
Computes the cumulative distribution function by inverting the
transform(s) and computing the score of the base distribution.
NrM   )r   rb   rE   r/   ra   Úcdfrk   ©r5   re   r8   s   && r   rn   ÚTransformedDistribution.cdfÌ   ss   € ð
 Ÿ™©¨2¨×.Ð.ˆIØ—M‘M %Ó(ŠEñ /à××ÐØ�N‰N×+Ñ+¨EÔ2Ø—‘×"Ñ" 5Ó)ˆØ×$Ñ$ UÓ+ˆØˆr   c                ó”   € V P                  V4      pV P                  P                  V4      pV P                   F  pV! V4      pK  	  V# )z|
Computes the inverse cumulative distribution function using
transform(s) and computing the score of the base distribution.
)rk   r/   Úicdfr   ro   s   && r   rr   ÚTransformedDistribution.icdfÙ   sE   € ð
 ×$Ñ$ UÓ+ˆØ—‘×#Ñ# EÓ*ˆØŸœˆIÙ˜eÓ$ŠEñ )àˆr   c                óP   <€ V ^8„  d   Qh/ S[ S[S[P                  3,          ;R&   # )r   Úarg_constraints)ÚdictÚstrr   Ú
Constraint)r   r   s   "€r   r   r      s$   ø‡ ‚ ñD ™#™{×5Ñ5Ð5Õ6Ñ;òE r   )r/   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ru   r4   r.   r   Údependent_propertyrN   ÚpropertyrS   rB   rC   rW   r^   rd   rk   rn   rr   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r>   r   s   @@r   r   r      s˜   ù‡ € ñðB :<€O÷:Põ :P÷xð ×#Ò#°Ô6ñó 7ðð ÷*ó ð*ð #(§*¢*£,ô ð -2¯JªJ«L÷ 
ò 
òò0
*òò	÷S … r   )rB   r   Útorch.distributionsr   Ú torch.distributions.distributionr   Útorch.distributions.independentr   Útorch.distributions.transformsr   r   Útorch.distributions.utilsr	   Útorch.typesr
   Ú__all__r   © r   r   Ú<module>rŒ      s7   ðó Ý Ý +Ý 9Ý 7ß FÝ 4Ý ð %Ð
%€ôR˜lö Rr   