ó
    Eñi—1  ã                   ój   • S SK r S SKJr  S SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S/r " S S5      rg)	é    N)Ú
deprecated)ÚTensor)Úconstraints)Úlazy_property)Ú_sizeÚDistributionc            	       ó|  ^ • \ rS rSrSrSrSrSr\S\	SS4S j5       r
\R                  " 5       \R                  " 5       S4S	\R                  S
\R                  S\	S-  SS4U 4S jjjrS)S	\4S jjr\S\R                  4S j5       r\S\R                  4S j5       r\S\\\R,                  4   4S j5       r\S\R,                  S-  4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\R                  " 5       4S\S\4S jjr\R                  " 5       4S\S\4S jjr\ " S\!S9S\"S\4S j5       r#S\S\4S jr$S\S\4S jr%S\S\4S jr&S*S \	S\4S! jjr'S\4S" jr(S\4S# jr)\R                  " 5       4S\S\R                  4S$ jjr*S\SS4S% jr+S)S& jr,S\4S' jr-S(r.U =r/$ )+r   é   a;  
Distribution is the abstract base class for probability distributions.

Args:
    batch_shape (torch.Size): The shape over which parameters are batched.
    event_shape (torch.Size): The shape of a single sample (without batching).
    validate_args (bool, optional): Whether to validate arguments. Default: None.
FTÚvalueÚreturnNc                 ó2   • U S;  a  [         eU [        l        g)a]  
Sets whether validation is enabled or disabled.

The default behavior mimics Python's ``assert`` statement: validation
is on by default, but is disabled if Python is run in optimized mode
(via ``python -O``). Validation may be expensive, so you may want to
disable it once a model is working.

Args:
    value (bool): Whether to enable validation.
)TFN)Ú
ValueErrorr   Ú_validate_args)r   s    Ú]/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributions/distribution.pyÚset_default_validate_argsÚ&Distribution.set_default_validate_args   s   € ð ˜Ó%ÜÐØ&+ŒÕ#ó    Úbatch_shapeÚevent_shapeÚvalidate_argsc                 óö  >• Xl         X l        Ub  X0l        U R                  (       Ga   U R                  nUR                  5        Hç  u  pV[        R                  " U5      (       a  M"  XPR                  ;  a*  [        [        [        U 5      U5      [        5      (       a  M[  [        X5      nUR!                  U5      n["        R$                  " U5      (       a  M”  ['        SU S[        U5      R(                   S[+        UR,                  5       S	[/        U 5       S
[/        U5       SU 35      e   [0        T	U ]e  5         g ! [         a.    0 n[
        R                  " U R                   S3S-   S-   SS9   GNAf = f)Nz$ does not define `arg_constraints`. zAPlease set `arg_constraints = {}` or initialize the distribution z2with `validate_args=False` to turn off validation.é   ©Ú
stacklevelzExpected parameter z (ú
 of shape z) of distribution z to satisfy the constraint ú, but found invalid values:
)Ú_batch_shapeÚ_event_shaper   Úarg_constraintsÚNotImplementedErrorÚwarningsÚwarnÚ	__class__Úitemsr   Úis_dependentÚ__dict__Ú
isinstanceÚgetattrÚtyper   ÚcheckÚtorchÚ_is_all_truer   Ú__name__ÚtupleÚshapeÚreprÚsuperÚ__init__)
Úselfr   r   r   r   ÚparamÚ
constraintr   Úvalidr#   s
            €r   r2   ÚDistribution.__init__.   sy  ø€ ð (ÔØ'ÔØÑ$Ø"/ÔØ××Ðð	Ø"&×"6Ñ"6�ð &5×%:Ñ%:Ö%<Ñ!�Ü×+Ò+¨J×7Ñ7ÙØ§¡Ó-´*ÜœD ›J¨Ó.´÷3ñ 3ñ Ü Ó,�Ø"×(Ñ(¨Ó/�Ü×)Ò)¨%×0Ó0Ü$Ø-¨e¨Wð 5Ü  ›K×0Ñ0Ð1°¼EÀ%Ç+Á+Ó<NÐ;Oð P+Ü+/°«:¨,ð 75Ü59¸*Ó5EÐ4Fð G6Ø6;°Wð	>óð ñ &=ô" 	‰ÑÕøô3 'ó Ø"$�Ü—’Ø—~‘~Ð&Ð&JÐKØYñZàJñKð  !õ	ðús   ªE  Å 4E8Å7E8c                 ó   • [         e)a·  
Returns a new distribution instance (or populates an existing instance
provided by a derived class) with batch dimensions expanded to
`batch_shape`. This method calls :class:`~torch.Tensor.expand` on
the distribution's parameters. As such, this does not allocate new
memory for the expanded distribution instance. Additionally,
this does not repeat any args checking or parameter broadcasting in
`__init__.py`, when an instance is first created.

Args:
    batch_shape (torch.Size): the desired expanded size.
    _instance: new instance provided by subclasses that
        need to override `.expand`.

Returns:
    New distribution instance with batch dimensions expanded to
    `batch_size`.
©r    )r3   r   Ú	_instances      r   ÚexpandÚDistribution.expandV   s
   € ô& "Ð!r   c                 ó   • U R                   $ )z6
Returns the shape over which parameters are batched.
)r   ©r3   s    r   r   ÚDistribution.batch_shapek   ó   € ð
 × Ñ Ð r   c                 ó   • U R                   $ )z:
Returns the shape of a single sample (without batching).
)r   r>   s    r   r   ÚDistribution.event_shaper   r@   r   c                 ó   • [         e)zâ
Returns a dictionary from argument names to
:class:`~torch.distributions.constraints.Constraint` objects that
should be satisfied by each argument of this distribution. Args that
are not tensors need not appear in this dict.
r9   r>   s    r   r   ÚDistribution.arg_constraintsy   ó
   € ô "Ð!r   c                 ó   • [         e)zq
Returns a :class:`~torch.distributions.constraints.Constraint` object
representing this distribution's support.
r9   r>   s    r   ÚsupportÚDistribution.supportƒ   ó
   € ô "Ð!r   c                 ó   • [         e)z'
Returns the mean of the distribution.
r9   r>   s    r   ÚmeanÚDistribution.mean‹   ó
   € ô
 "Ð!r   c                 ó2   • [        U R                   S35      e)z'
Returns the mode of the distribution.
z does not implement mode)r    r#   r>   s    r   ÚmodeÚDistribution.mode’   s   € ô
 " T§^¡^Ð$4Ð4LÐ"MÓNÐNr   c                 ó   • [         e)z+
Returns the variance of the distribution.
r9   r>   s    r   ÚvarianceÚDistribution.variance™   rM   r   c                 ó6   • U R                   R                  5       $ )z5
Returns the standard deviation of the distribution.
)rR   Úsqrtr>   s    r   ÚstddevÚDistribution.stddev    s   € ð
 �}‰}×!Ñ!Ó#Ð#r   Úsample_shapec                 ó„   • [         R                  " 5          U R                  U5      sSSS5        $ ! , (       d  f       g= f)z|
Generates a sample_shape shaped sample or sample_shape shaped batch of
samples if the distribution parameters are batched.
N)r+   Úno_gradÚrsample©r3   rX   s     r   ÚsampleÚDistribution.sample§   s#   € ô
 �]Š]�_Ø—<‘< Ó-÷ �_�_ús   –1±
?c                 ó   • [         e)zœ
Generates a sample_shape shaped reparameterized sample or sample_shape
shaped batch of reparameterized samples if the distribution parameters
are batched.
r9   r\   s     r   r[   ÚDistribution.rsample¯   rI   r   z=`sample_n(n)` will be deprecated. Use `sample((n,))` instead.)ÚcategoryÚnc                 óN   • U R                  [        R                  " U45      5      $ )zY
Generates n samples or n batches of samples if the distribution
parameters are batched.
)r]   r+   ÚSize)r3   rb   s     r   Úsample_nÚDistribution.sample_n·   s   € ð �{‰{œ5Ÿ:š: q dÓ+Ó,Ð,r   c                 ó   • [         e)zk
Returns the log of the probability density/mass function evaluated at
`value`.

Args:
    value (Tensor):
r9   ©r3   r   s     r   Úlog_probÚDistribution.log_probÂ   rE   r   c                 ó   • [         e)z_
Returns the cumulative density/mass function evaluated at
`value`.

Args:
    value (Tensor):
r9   rh   s     r   ÚcdfÚDistribution.cdfÌ   rE   r   c                 ó   • [         e)zg
Returns the inverse cumulative density/mass function evaluated at
`value`.

Args:
    value (Tensor):
r9   rh   s     r   ÚicdfÚDistribution.icdfÖ   rE   r   r;   c                 ó   • [         e)aò  
Returns tensor containing all values supported by a discrete
distribution. The result will enumerate over dimension 0, so the shape
of the result will be `(cardinality,) + batch_shape + event_shape`
(where `event_shape = ()` for univariate distributions).

Note that this enumerates over all batched tensors in lock-step
`[[0, 0], [1, 1], ...]`. With `expand=False`, enumeration happens
along dim 0, but with the remaining batch dimensions being
singleton dimensions, `[[0], [1], ..`.

To iterate over the full Cartesian product use
`itertools.product(m.enumerate_support())`.

Args:
    expand (bool): whether to expand the support over the
        batch dims to match the distribution's `batch_shape`.

Returns:
    Tensor iterating over dimension 0.
r9   )r3   r;   s     r   Úenumerate_supportÚDistribution.enumerate_supportà   s
   € ô, "Ð!r   c                 ó   • [         e)zg
Returns entropy of distribution, batched over batch_shape.

Returns:
    Tensor of shape batch_shape.
r9   r>   s    r   ÚentropyÚDistribution.entropyø   s
   € ô "Ð!r   c                 óJ   • [         R                  " U R                  5       5      $ )zj
Returns perplexity of distribution, batched over batch_shape.

Returns:
    Tensor of shape batch_shape.
)r+   Úexpru   r>   s    r   Ú
perplexityÚDistribution.perplexity  s   € ô �yŠy˜Ÿ™›Ó(Ð(r   c                 óÊ   • [        U[        R                  5      (       d  [        R                  " U5      n[        R                  " XR                  -   U R                  -   5      $ )a@  
Returns the size of the sample returned by the distribution, given
a `sample_shape`. Note, that the batch and event shapes of a distribution
instance are fixed at the time of construction. If this is empty, the
returned shape is upcast to (1,).

Args:
    sample_shape (torch.Size): the size of the sample to be drawn.
)r'   r+   rd   r   r   r\   s     r   Ú_extended_shapeÚDistribution._extended_shape
  sF   € ô ˜,¬¯
©
×3Ñ3Ü Ÿ:š: lÓ3ˆLÜ�zŠz˜,×):Ñ):Ñ:¸T×=NÑ=NÑNÓOÐOr   c                 óÜ  • [        U[        R                  5      (       d  [        S5      e[	        UR                  5       5      [	        U R                  5      -
  nUR                  5       US U R                  :w  a*  [        SUR                  5        SU R                   S35      eUR                  5       nU R                  U R                  -   n[        [        U5      [        U5      5       H,  u  pVUS:w  d  M  US:w  d  M  XV:w  d  M  [        SU SU S35      e    U R                  nUc  [        S5      eUR!                  U5      n[        R"                  " U5      (       dR  [        S[%        U5      R&                   S[)        UR*                  5       S[-        U5       S[-        U 5       SU 3
5      eg! [         a+    [        R                  " U R                   S3S	-   S
-   SS9   gf = f)aÂ  
Argument validation for distribution methods such as `log_prob`,
`cdf` and `icdf`. The rightmost dimensions of a value to be
scored via these methods must agree with the distribution's batch
and event shapes.

Args:
    value (Tensor): the tensor whose log probability is to be
        computed by the `log_prob` method.
Raises
    ValueError: when the rightmost dimensions of `value` do not match the
        distribution's batch and event shapes.
z/The value argument to log_prob must be a TensorNz5The right-most size of value must match event_shape: z vs Ú.é   z9Value is not broadcastable with batch_shape+event_shape: z% does not define `support` to enable z;sample validation. Please initialize the distribution with z-`validate_args=False` to turn off validation.r   r   zsupport is unexpectedly NonezExpected value argument (r   z) to be within the support (z) of the distribution r   )r'   r+   r   r   ÚlenÚsizer   r   ÚzipÚreversedrG   r    r!   r"   r#   ÚAssertionErrorr*   r,   r)   r-   r.   r/   r0   )	r3   r   Úevent_dim_startÚactual_shapeÚexpected_shapeÚiÚjrG   r6   s	            r   Ú_validate_sampleÚDistribution._validate_sample  sî  € ô ˜%¤§¡×.Ñ.ÜÐNÓOÐOä˜eŸj™j›lÓ+¬c°$×2CÑ2CÓ.DÑDˆØ�:‰:‹<˜Ð(Ð)¨T×->Ñ->Ó>ÜØGÈÏ
É
ËÀ~ÐUYÐZ^×ZkÑZkÐYlÐlmÐnóð ð —z‘z“|ˆØ×*Ñ*¨T×->Ñ->Ñ>ˆÜœ Ó.´¸Ó0HÖI‰DˆAØ�A�v˜!˜q�& Q¥VÜ ØOÐP\È~Ð]aÐbpÐaqÐqrÐsóð ñ Jð
		Ø—l‘lˆGð ‰?Ü Ð!?Ó@Ð@Ø—‘˜eÓ$ˆÜ×!Ò! %×(Ñ(ÜðÜ˜“K×(Ñ(Ð)¨´E¸%¿+¹+Ó4FÐ3Gð H-Ü-1°'«]¨Oð <'Ü'+¨D£z lð 3.Ø.3¨Wð	6óð ð )øô #ó 	Ü�MŠMØ—>‘>Ð"Ð"GÐHØOñPàAñBð ò	ñ ð	ús   ÄF6 Æ62G+Ç*G+c                 óì   • UcS  [        U 5      R                  UR                  :w  a0  [        SU R                  R                   SUR                   S35      eUc  U R                  [        U 5      5      $ U$ )Nz	Subclass z of zR that defines a custom __init__ method must also define a custom .expand() method.)r)   r2   r    r#   r-   Ú__new__)r3   Úclsr:   s      r   Ú_get_checked_instanceÚ"Distribution._get_checked_instanceL  sp   € ØÑ¤ d£×!4Ñ!4¸¿¹Ó!DÜ%Ø˜DŸN™N×3Ñ3Ð4°D¸¿¹¸ð G>ð >óð ð ,5Ñ+<ˆt�|‰|œD ›JÓ'ÐKÀ)ÐKr   c           	      ó¸  • U R                   R                  5        VVs/ s H  u  pXR                  ;   d  M  UPM     nnnSR                  U Vs/ s HU  nU SU R                  U   R	                  5       S:X  a  U R                  U   OU R                  U   R                  5        3PMW     sn5      nU R                  R                  S-   U-   S-   $ s  snnf s  snf )Nz, z: r€   Ú(Ú))r   r$   r&   ÚjoinÚnumelr‚   r#   r-   )r3   ÚkÚ_Úparam_namesÚpÚargs_strings         r   Ú__repr__ÚDistribution.__repr__T  sÌ   € Ø%)×%9Ñ%9×%?Ñ%?Ô%AÔXÒ%A™T˜QÀQÏ-É-ÑEW—qÑ%AˆÑXØ—i‘iñ %óâ$�Að �#�R¨D¯M©M¸!Ñ,<×,BÑ,BÓ,DÈÓ,I˜Ÿ™ aÒ(ÈtÏ}É}Ð]^ÑO_×OdÑOdÓOfÐgÓhÙ$ñó
ˆð �~‰~×&Ñ&¨Ñ,¨{Ñ:¸SÑ@Ð@ùó Yùòs   žC·CÁAC)r   r   r   )N)T)0r-   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úhas_rsampleÚhas_enumerate_supportr   ÚstaticmethodÚboolr   r+   rd   r2   r   r;   Úpropertyr   r   ÚdictÚstrr   Ú
Constraintr   rG   r   rK   rO   rR   rV   r]   r[   r   ÚFutureWarningÚintre   ri   rl   ro   rr   ru   ry   r|   r‹   r�   rœ   Ú__static_attributes__Ú__classcell__)r#   s   @r   r   r      s¸  ø† ñð €KØ!ÐØ€Nàð,¨ð ,°$ó ,ó ð,ð$ #(§*¢*£,Ø"'§*¢*£,Ø%)ñ	&à—Z‘Zð&ð —Z‘Zð&ð ˜d‘{ð	&ð
 
÷&ð &ñP" %õ "ð* ð!˜UŸZ™Zó !ó ð!ð ð!˜UŸZ™Zó !ó ð!ð ð"  c¨;×+AÑ+AÐ&AÑ!Bó "ó ð"ð ð"˜×/Ñ/°$Ñ6ó "ó ð"ð ð"�fó "ó ð"ð ðO�fó Oó ðOð ð"˜&ó "ó ð"ð ð$˜ó $ó ð$ð ,1¯:ª:«<ñ . 5ð .¸Fõ .ð -2¯JªJ«Lñ " Eð "¸Võ "ñ ØGØñð-˜#ð - &ó -ó	ð-ð"˜fð "¨ô "ð"˜ð " Fô "ð"˜&ð " Vô "ñ"¨ð "¸õ "ð0"˜ô "ð)˜Fô )ð 5:·J²J³Lñ P¨Eð PÀUÇZÁZõ Pð2 fð 2°ô 2ôhLðA˜#÷ Aò Ar   )r!   Útyping_extensionsr   r+   r   Útorch.distributionsr   Útorch.distributions.utilsr   Útorch.typesr   Ú__all__r   © r   r   Ú<module>r´      s2   ðã Ý (ã Ý Ý +Ý 3Ý ð Ð
€÷MAò MAr   