Ë
    f^(h20  ã                   óv   — d dl Z d dlmZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ dgZ G d	„ d«      Zy)
é    N)ÚOptional)Ú
deprecated)ÚTensor)Úconstraints)Úlazy_property)Ú_sizeÚDistributionc                   ó8  ‡ — e Zd ZdZdZdZdZededdfd„«       Z	 e
j                  «        e
j                  «       dfde
j                  d	e
j                  d
ee   fˆ fd„Zd'defd„Zede
j                  fd„«       Zede
j                  fd„«       Zedeeej,                  f   fd„«       Zedeej,                     fd„«       Zedefd„«       Zedefd„«       Zedefd„«       Zedefd„«       Z e
j                  «       fdedefd„Z e
j                  «       fdedefd„Z e de!¬«      de"defd„«       Z#dedefd„Z$dedefd„Z%dedefd„Z&d(dedefd „Z'defd!„Z(defd"„Z) e
j                  «       fdede
j                  fd#„Z*deddfd$„Z+d'd%„Z,defd&„Z-ˆ xZ.S ))r	   zP
    Distribution is the abstract base class for probability distributions.
    FTÚvalueÚreturnNc                 ó.   — | dvrt         ‚| t        _        y)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    ú^/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/distributions/distribution.pyÚset_default_validate_argsz&Distribution.set_default_validate_args   s   € ð ˜Ñ%ÜÐØ&+ŒÕ#ó    Úbatch_shapeÚevent_shapeÚvalidate_argsc                 óÄ  •— || _         || _        |�|| _        | j                  rô	 | j                  }|j                  «       D ]Ô  \  }}t        j                  |«      rŒ|| j                  vr$t        t        t        | «      |«      t        «      rŒNt        | |«      }|j!                  |«      }t#        j$                  |«      rŒ�t'        d|› dt        |«      j(                  › dt+        |j,                  «      › dt/        | «      › dt/        |«      › d	|› �«      ‚ t0        ‰	| �e  «        y # t        $ r. i }t        j                  | j                  › d�dz   dz   «       Y �Œ,w xY w)
Nz$ does not define `arg_constraints`. zAPlease set `arg_constraints = {}` or initialize the distribution z2with `validate_args=False` to turn off validation.z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   r.   zDistribution.__init__*   sw  ø€ ð (ˆÔØ'ˆÔØÐ$Ø"/ˆDÔØ×ÒðØ"&×"6Ñ"6�ð &5×%:Ñ%:Ó%<ò Ñ!��zÜ×+Ñ+¨JÔ7ØØ §¡Ñ-´*ÜœD ›J¨Ó.´ô3ð Ü  eÓ,�Ø"×(Ñ(¨Ó/�Ü×)Ñ)¨%Õ0Ü$Ø-¨e¨Wð 5Ü  ›K×0Ñ0Ð1°¼EÀ%Ç+Á+Ó<NÐ;Oð P+Ü+/°«:¨,ð 75Ü59¸*Ó5EÐ4Fð G6Ø6;°Wð	>óð ðô" 	‰ÑÕøô1 'ò Ø"$�Ü—‘Ø—~‘~Ð&Ð&JÐKØYñZàJñK÷ðús   ¦D( Ä(3EÅEc                 ó   — t         ‚)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   )r/   r   Ú	_instances      r   ÚexpandzDistribution.expandQ   s
   € ô& "Ð!r   c                 ó   — | j                   S )zF
        Returns the shape over which parameters are batched.
        )r   ©r/   s    r   r   zDistribution.batch_shapef   ó   € ð
 × Ñ Ð r   c                 ó   — | j                   S )zJ
        Returns the shape of a single sample (without batching).
        )r   r8   s    r   r   zDistribution.event_shapem   r9   r   c                 ó   — t         ‚)a
  
        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.
        r4   r8   s    r   r   zDistribution.arg_constraintst   ó
   € ô "Ð!r   c                 ó   — t         ‚)z‰
        Returns a :class:`~torch.distributions.constraints.Constraint` object
        representing this distribution's support.
        r4   r8   s    r   ÚsupportzDistribution.support~   ó
   € ô "Ð!r   c                 ó   — t         ‚)z7
        Returns the mean of the distribution.
        r4   r8   s    r   ÚmeanzDistribution.mean†   ó
   € ô
 "Ð!r   c                 ó2   — t        | j                  › d�«      ‚)z7
        Returns the mode of the distribution.
        z does not implement mode)r   r   r8   s    r   ÚmodezDistribution.mode�   s   € ô
 " T§^¡^Ð$4Ð4LÐ"MÓNÐNr   c                 ó   — t         ‚)z;
        Returns the variance of the distribution.
        r4   r8   s    r   ÚvariancezDistribution.variance”   rB   r   c                 ó6   — | j                   j                  «       S )zE
        Returns the standard deviation of the distribution.
        )rF   Úsqrtr8   s    r   ÚstddevzDistribution.stddev›   s   € ð
 �}‰}×!Ñ!Ó#Ð#r   Úsample_shapec                 óx   — t        j                  «       5  | j                  |«      cddd«       S # 1 sw Y   yxY w)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©r/   rJ   s     r   ÚsamplezDistribution.sample¢   s.   € ô
 �]‰]‹_ñ 	.Ø—<‘< Ó-÷	.÷ 	.ò 	.ús   •0°9c                 ó   — t         ‚)z¼
        Generates a sample_shape shaped reparameterized sample or sample_shape
        shaped batch of reparameterized samples if the distribution parameters
        are batched.
        r4   rN   s     r   rM   zDistribution.rsampleª   r?   r   z=`sample_n(n)` will be deprecated. Use `sample((n,))` instead.)ÚcategoryÚnc                 óL   — | j                  t        j                  |f«      «      S )zq
        Generates n samples or n batches of samples if the distribution
        parameters are batched.
        )rO   r'   ÚSize)r/   rR   s     r   Úsample_nzDistribution.sample_n²   s   € ð �{‰{œ5Ÿ:™: q dÓ+Ó,Ð,r   c                 ó   — t         ‚)z“
        Returns the log of the probability density/mass function evaluated at
        `value`.

        Args:
            value (Tensor):
        r4   ©r/   r   s     r   Úlog_probzDistribution.log_prob½   r<   r   c                 ó   — t         ‚)z‡
        Returns the cumulative density/mass function evaluated at
        `value`.

        Args:
            value (Tensor):
        r4   rW   s     r   ÚcdfzDistribution.cdfÇ   r<   r   c                 ó   — t         ‚)z�
        Returns the inverse cumulative density/mass function evaluated at
        `value`.

        Args:
            value (Tensor):
        r4   rW   s     r   ÚicdfzDistribution.icdfÑ   r<   r   r6   c                 ó   — t         ‚)ar  
        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.
        r4   )r/   r6   s     r   Úenumerate_supportzDistribution.enumerate_supportÛ   s
   € ô, "Ð!r   c                 ó   — t         ‚)z‡
        Returns entropy of distribution, batched over batch_shape.

        Returns:
            Tensor of shape batch_shape.
        r4   r8   s    r   ÚentropyzDistribution.entropyó   s
   € ô "Ð!r   c                 óH   — t        j                  | j                  «       «      S )zŠ
        Returns perplexity of distribution, batched over batch_shape.

        Returns:
            Tensor of shape batch_shape.
        )r'   Úexpr`   r8   s    r   Ú
perplexityzDistribution.perplexityü   s   € ô �y‰y˜Ÿ™›Ó(Ð(r   c                 ó¾   — t        |t        j                  «      st        j                  |«      }t        j                  || j                  z   | j                  z   «      S )ax  
        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'   rT   r   r   rN   s     r   Ú_extended_shapezDistribution._extended_shape  sE   € ô ˜,¬¯
©
Ô3Ü Ÿ:™: lÓ3ˆLÜ�z‰z˜,¨×):Ñ):Ñ:¸T×=NÑ=NÑNÓOÐOr   c                 ó¤  — t        |t        j                  «      st        d«      ‚t	        |j                  «       «      t	        | j                  «      z
  }|j                  «       |d | j                  k7  r*t        d|j                  «       › d| j                  › d�«      ‚|j                  «       }| j                  | j                  z   }t        t        |«      t        |«      «      D ](  \  }}|dk7  sŒ|dk7  sŒ||k7  sŒt        d|› d|› d�«      ‚ 	 | j                  }|€J ‚|j                  |«      }t        j                   |«      sRt        dt#        |«      j$                  › dt'        |j(                  «      › dt+        |«      › dt+        | «      › d|› �
«      ‚y# t        $ r+ t        j                  | j                  › d�d	z   d
z   «       Y yw xY w)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.zExpected value argument (r   z) to be within the support (z) of the distribution r   )r#   r'   r   r   ÚlenÚsizer   r   ÚzipÚreversedr>   r   r   r   r   r&   r(   r%   r)   r*   r+   r,   )	r/   r   Úevent_dim_startÚactual_shapeÚexpected_shapeÚiÚjr>   r2   s	            r   Ú_validate_samplez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ˆqØ�A‹v˜!˜q›& Q¨!£VÜ ØOÐP\È~Ð]aÐbpÐaqÐqrÐsóð ð	ð
	Ø—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   ÄF Æ1GÇGc                 óæ   — |€Rt        | «      j                  |j                  k7  r0t        d| j                  j                  › d|j                  › d�«      ‚|€| j                  t        | «      «      S |S )Nz	Subclass z of zR that defines a custom __init__ method must also define a custom .expand() method.)r%   r.   r   r   r)   Ú__new__)r/   Úclsr5   s      r   Ú_get_checked_instancez"Distribution._get_checked_instanceE  sp   € ØÐ¤ d£×!4Ñ!4¸¿¹Ò!DÜ%Ø˜DŸN™N×3Ñ3Ð4°D¸¿¹¸ð G>ð >óð ð ,5Ð+<ˆt�|‰|œD ›JÓ'ÐKÀ)ÐKr   c           	      ó¨  — | j                   j                  «       D ��cg c]  \  }}|| j                  v sŒ|‘Œ }}}dj                  |D �cg c]S  }|› d| j                  |   j	                  «       dk(  r| j                  |   n| j                  |   j                  «       › �‘ŒU c}«      }| j                  j                  dz   |z   dz   S c c}}w c c}w )Nz, z: rh   ú(ú))r   r    r"   ÚjoinÚnumelrj   r   r)   )r/   ÚkÚ_Úparam_namesÚpÚargs_strings         r   Ú__repr__zDistribution.__repr__M  sÈ   € Ø%)×%9Ñ%9×%?Ñ%?Ó%A×X™T˜Q ÀQÈ$Ï-É-ÒEW’qÐXˆÑXØ—i‘ið %öàð �#�R¨D¯M©M¸!Ñ,<×,BÑ,BÓ,DÈÒ,I˜Ÿ™ aÒ(ÈtÏ}É}Ð]^ÑO_×OdÑOdÓOfÐgÒhòó
ˆð �~‰~×&Ñ&¨Ñ,¨{Ñ:¸SÑ@Ð@ùó Yùòs   žC	µC	ÁAC)N)T)/r)   Ú
__module__Ú__qualname__Ú__doc__Úhas_rsampleÚhas_enumerate_supportr   ÚstaticmethodÚboolr   r'   rT   r   r.   r   r6   Úpropertyr   r   ÚdictÚstrr   Ú
Constraintr   r>   r   rA   rD   rF   rI   rO   rM   r   ÚFutureWarningÚintrU   rX   rZ   r\   r^   r`   rc   re   rr   rv   r�   Ú__classcell__)r   s   @r   r	   r	      s­  ø„ ñð €KØ!ÐØ€Nàð,¨ð ,°$ò ,ó ð,ð$ #- %§*¡*£,Ø", %§*¡*£,Ø(,ñ	%à—Z‘Zð%ð —Z‘Zð%ð   ‘~õ	%ñN" %ó "ð* ð!˜UŸZ™Zò !ó ð!ð ð!˜UŸZ™Zò !ó ð!ð ð"  c¨;×+AÑ+AÐ&AÑ!Bò "ó ð"ð ð"˜ +×"8Ñ"8Ñ9ò "ó ð"ð ð"�fò "ó ð"ð ðO�fò Oó ðOð ð"˜&ò "ó ð"ð ð$˜ò $ó ð$ð ,6¨5¯:©:«<ñ . 5ð .¸Fó .ð -7¨E¯J©J«Lñ " Eð "¸Vó "ñ ØGØôð-˜#ð - &ò -ó	ð-ð"˜fð "¨ó "ð"˜ð " Fó "ð"˜&ð " Vó "ñ"¨ð "¸ó "ð0"˜ó "ð)˜Fó )ð 5?°E·J±J³Lñ P¨Eð PÀUÇZÁZó Pð0 fð 0°ó 0ódLðA˜#÷ Ar   )r   Útypingr   Útyping_extensionsr   r'   r   Útorch.distributionsr   Útorch.distributions.utilsr   Útorch.typesr   Ú__all__r	   © r   r   ú<module>r—      s5   ðã Ý Ý (ã Ý Ý +Ý 3Ý ð Ð
€÷EAò EAr   