§
    ŠŠtj�1  ã                   ór   — d dl 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dS )	é    N)Ú
deprecated)ÚTensor)Úconstraints)Úlazy_property)Ú_sizeÚDistributionc            	       ó*  ‡ — 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dz  dd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j        dz  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   aS  
    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                 ó4   — | dvrt           ‚| t          _        dS )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/html/CA-Chatbot/venv/lib/python3.11/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        }n6# t          $ r) i }t          j        | j        › d�dz   dz   d¬¦  «         Y nw xY w|                     ¦   «         D ]ì\  }}t          j
        |¦  «        rŒ|| j        vr1t          t          t          | ¦  «        |¦  «        t          ¦  «        rŒTt          | |¦  «        }|                     |¦  «        }t#          j        |¦  «        s_t'          d|› dt          |¦  «        j        › dt+          |j        ¦  «        › d	t/          | ¦  «        › d
t/          |¦  «        › d|› �¦  «        ‚Œít1          ¦   «                              ¦   «          d S )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   r0   zDistribution.__init__.   sô  ø€ ð (ˆÔØ'ˆÔØÐ$Ø"/ˆDÔØÔñ 	ð	Ø"&Ô"6��øÝ&ð ð ð Ø"$�Ý”Ø”~ÐKÐKÐKØYñZàJñKð  !ð	ñ ô ð ð ð ðøøøð &5×%:Ò%:Ñ%<Ô%<ð ð Ñ!��zÝÔ+¨JÑ7Ô7ð ØØ ¤Ð-Ð-µ*Ý�D ™JœJ¨Ñ.Ô.µñ3ô 3Ð-ð Ý  eÑ,Ô,�Ø"×(Ò(¨Ñ/Ô/�ÝÔ)¨%Ñ0Ô0ð Ý$ð>¨eð >ð >Ý  ™KœKÔ0ð>ð >Ý<AÀ%Ä+Ñ<NÔ<Nð>ð >å+/°©:¬:ð>ð >õ 6:¸*Ñ5EÔ5Eð>ð >ð 7<ð	>ð >ñô ð ðõ 	‰Œ×ÒÑÔÐÐÐs   ¢* ª0AÁAc                 ó   — t           ‚)a0  
        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_shape`.
        ©r   )r1   r   Ú	_instances      r   ÚexpandzDistribution.expandV   s
   € õ& "Ð!r   c                 ó   — | j         S )zF
        Returns the shape over which parameters are batched.
        )r   ©r1   s    r   r   zDistribution.batch_shapek   ó   € ð
 Ô Ð r   c                 ó   — | j         S )zJ
        Returns the shape of a single sample (without batching).
        )r   r:   s    r   r   zDistribution.event_shaper   r;   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.
        r6   r:   s    r   r   zDistribution.arg_constraintsy   ó
   € õ "Ð!r   c                 ó   — t           ‚)z‰
        Returns a :class:`~torch.distributions.constraints.Constraint` object
        representing this distribution's support.
        r6   r:   s    r   ÚsupportzDistribution.supportƒ   ó
   € õ "Ð!r   c                 ó   — t           ‚)z7
        Returns the mean of the distribution.
        r6   r:   s    r   ÚmeanzDistribution.mean‹   ó
   € õ
 "Ð!r   c                 ó0   — t          | j        › d�¦  «        ‚)z7
        Returns the mode of the distribution.
        z does not implement mode)r   r!   r:   s    r   ÚmodezDistribution.mode’   s   € õ
 " T¤^Ð"MÐ"MÐ"MÑNÔNÐNr   c                 ó   — t           ‚)z;
        Returns the variance of the distribution.
        r6   r:   s    r   ÚvariancezDistribution.variance™   rD   r   c                 ó4   — | j                              ¦   «         S )zE
        Returns the standard deviation of the distribution.
        )rH   Úsqrtr:   s    r   ÚstddevzDistribution.stddev    s   € ð
 Œ}×!Ò!Ñ#Ô#Ð#r   Úsample_shapec                 ó†   — t          j        ¦   «         5  |                      |¦  «        cddd¦  «         S # 1 swxY w Y   dS )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©r1   rL   s     r   ÚsamplezDistribution.sample§   sƒ   € õ
 Œ]‰_Œ_ð 	.ð 	.Ø—<’< Ñ-Ô-ð	.ð 	.ð 	.ð 	.ñ 	.ô 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.øøøð 	.ð 	.ð 	.ð 	.ð 	.ð 	.s   ”6¶:½:c                 ó   — t           ‚)z¼
        Generates a sample_shape shaped reparameterized sample or sample_shape
        shaped batch of reparameterized samples if the distribution parameters
        are batched.
        r6   rP   s     r   rO   zDistribution.rsample¯   rA   r   z=`sample_n(n)` will be deprecated. Use `sample((n,))` instead.)ÚcategoryÚnc                 óR   — |                       t          j        |f¦  «        ¦  «        S )zq
        Generates n samples or n batches of samples if the distribution
        parameters are batched.
        )rQ   r)   ÚSize)r1   rT   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):
        r6   ©r1   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):
        r6   rY   s     r   ÚcdfzDistribution.cdfÌ   r>   r   c                 ó   — t           ‚)z�
        Returns the inverse cumulative density/mass function evaluated at
        `value`.

        Args:
            value (Tensor):
        r6   rY   s     r   ÚicdfzDistribution.icdfÖ   r>   r   r8   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.
        r6   )r1   r8   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.
        r6   r:   s    r   ÚentropyzDistribution.entropyø   s
   € õ "Ð!r   c                 óN   — t          j        |                      ¦   «         ¦  «        S )zŠ
        Returns perplexity of distribution, batched over batch_shape.

        Returns:
            Tensor of shape batch_shape.
        )r)   Úexprb   r:   s    r   Ú
perplexityzDistribution.perplexity  s   € õ Œ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)   rV   r   r   rP   s     r   Ú_extended_shapezDistribution._extended_shape
  sG   € õ ˜,­¬
Ñ3Ô3ð 	4Ý œ: lÑ3Ô3ˆLÝŒz˜,¨Ô):Ñ:¸TÔ=NÑNÑOÔOÐOr   c                 ó  — t          |t          j        ¦  «        st          d¦  «        ‚t	          |                     ¦   «         ¦  «        t	          | j        ¦  «        z
  }|                     ¦   «         |d…         | j        k    r-t          d|                     ¦   «         › d| j        › d�¦  «        ‚|                     ¦   «         }| j        | j        z   }t          t          |¦  «        t          |¦  «        ¦  «        D ]-\  }}|dk    r"|dk    r||k    rt          d|› d|› d�¦  «        ‚Œ.	 | j
        }n5# t          $ r( t          j        | j        › d�d	z   d
z   d¬¦  «         Y dS w xY w|€t          d¦  «        ‚|                     |¦  «        }t          j        |¦  «        s\t          dt%          |¦  «        j        › dt)          |j        ¦  «        › dt-          |¦  «        › dt-          | ¦  «        › d|› �
¦  «        ‚dS )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Úreversedr@   r   r   r    r!   ÚAssertionErrorr(   r*   r'   r+   r,   r-   r.   )	r1   r
   Úevent_dim_startÚactual_shapeÚexpected_shapeÚiÚjr@   r4   s	            r   Ú_validate_samplezDistribution._validate_sample  sa  € õ ˜%¥¤Ñ.Ô.ð 	PÝÐNÑOÔOÐOå˜eŸjšj™lœlÑ+Ô+­c°$Ô2CÑ.DÔ.DÑDˆØ�:Š:‰<Œ<˜Ð(Ð(Ô)¨TÔ->Ò>Ð>ÝØnÈÏ
Ê
ÉÌÐnÐnÐZ^ÔZkÐnÐnÐnñô ð ð —z’z‘|”|ˆØÔ*¨TÔ->Ñ>ˆÝ� Ñ.Ô.µ¸Ñ0HÔ0HÑIÔIð 	ð 	‰DˆAˆqØ�AŠvˆv˜!˜qš&˜& Q¨!¢V VÝ ØsÐP\ÐsÐsÐbpÐsÐsÐsñô ð øð		Ø”lˆGˆGøÝ"ð 	ð 	ð 	ÝŒMØ”>ÐHÐHÐHØOñPàAñBð ð	ñ ô ð ð ˆFˆFð	øøøð ˆ?Ý Ð!?Ñ@Ô@Ð@Ø—’˜eÑ$Ô$ˆÝÔ! %Ñ(Ô(ð 	Ýð6Ý˜‘K”KÔ(ð6ð 6Ý49¸%¼+Ñ4FÔ4Fð6ð 6å-1°'©]¬]ð6ð 6õ (,¨D¡z¤zð6ð 6ð /4ð	6ð 6ñô ð ð	ð 	s   Ä.D6 Ä6.E(Å'E(c                 óÖ   — |€Bt          | ¦  «        j        |j        k    r%t          d| j        j        › d|j        › d�¦  «        ‚|€"|                      t          | ¦  «        ¦  «        n|S )Nz	Subclass z of zR that defines a custom __init__ method must also define a custom .expand() method.)r'   r0   r   r!   r+   Ú__new__)r1   Úclsr7   s      r   Ú_get_checked_instancez"Distribution._get_checked_instanceL  s|   € ØÐ¥ d¡¤Ô!4¸¼Ò!DÐ!DÝ%ð>˜DœNÔ3ð >ð >¸¼ð >ð >ð >ñô ð ð ,5Ð+<ˆt�|Š|�D ™JœJÑ'Ô'Ð'À)ÐKr   c                 ó–   ‡ — ˆ fd„‰ j         D ¦   «         }d                     ˆ fd„|D ¦   «         ¦  «        }‰ j        j        dz   |z   dz   S )Nc                 ó&   •— g | ]}|‰j         v ¯|‘ŒS © )r$   )Ú.0Úkr1   s     €r   ú
<listcomp>z)Distribution.__repr__.<locals>.<listcomp>U  s%   ø€ ÐMÐMÐM˜Q¸!¸t¼}Ð:LÐ:L�qÐ:LÐ:LÐ:Lr   z, c                 ó¸   •— g | ]V}|› d ‰j         |                              ¦   «         dk    r‰j         |         n‰j         |                              ¦   «         › �‘ŒWS )z: rj   )r$   Únumelrl   )r}   Úpr1   s     €r   r   z)Distribution.__repr__.<locals>.<listcomp>W  st   ø€ ð ð ð àð ÐhÐh¨D¬M¸!Ô,<×,BÒ,BÑ,DÔ,DÈÒ,IÐ,I˜œ aÔ(Ð(ÈtÌ}Ð]^ÔO_×OdÒOdÑOfÔOfÐhÐhðð ð r   ú(ú))r   Újoinr!   r+   )r1   Úparam_namesÚargs_strings   `  r   Ú__repr__zDistribution.__repr__T  st   ø€ ØMÐMÐMÐM $Ô"6ÐMÑMÔMˆØ—i’iðð ð ð à$ðñ ô ñ
ô 
ˆð Œ~Ô&¨Ñ,¨{Ñ:¸SÑ@Ð@r   )N)T).r+   Ú
__module__Ú__qualname__Ú__doc__Úhas_rsampleÚhas_enumerate_supportr   ÚstaticmethodÚboolr   r)   rV   r0   r   r8   Úpropertyr   r   ÚdictÚstrr   Ú
Constraintr   r@   r   rC   rF   rH   rK   rQ   rO   r   ÚFutureWarningÚintrW   rZ   r\   r^   r`   rb   re   rg   ru   ry   rˆ   Ú__classcell__)r!   s   @r   r   r      sY  ø€ € € € € ðð ð €KØ!ÐØ€Nàð,¨ð ,°$ð ,ð ,ð ,ñ „\ð,ð$ #- %¤*¡,¤,Ø", %¤*¡,¤,Ø%)ð	&ð &à”Zð&ð ”Zð&ð ˜d‘{ð	&ð
 
ð&ð &ð &ð &ð &ð &ðP"ð " %ð "ð "ð "ð "ð* ð!˜UœZð !ð !ð !ñ „Xð!ð ð!˜UœZð !ð !ð !ñ „Xð!ð ð"  c¨;Ô+AÐ&AÔ!Bð "ð "ð "ñ „Xð"ð ð"˜Ô/°$Ñ6ð "ð "ð "ñ „Xð"ð ð"�fð "ð "ð "ñ „Xð"ð ðO�fð Oð Oð Oñ „XðOð ð"˜&ð "ð "ð "ñ „Xð"ð ð$˜ð $ð $ð $ñ „Xð$ð ,6¨5¬:©<¬<ð .ð . 5ð .¸Fð .ð .ð .ð .ð -7¨E¬J©L¬Lð "ð " Eð "¸Vð "ð "ð "ð "ð €ZØGØðñ ô ð-˜#ð - &ð -ð -ð -ñ	ô ð-ð"˜fð "¨ð "ð "ð "ð "ð"˜ð " Fð "ð "ð "ð "ð"˜&ð " Vð "ð "ð "ð "ð"ð "¨ð "¸ð "ð "ð "ð "ð0"˜ð "ð "ð "ð "ð)˜Fð )ð )ð )ð )ð 5?°E´J±L´Lð Pð P¨Eð PÀUÄZð Pð Pð Pð Pð2 fð 2°ð 2ð 2ð 2ð 2ðhLð Lð Lð LðA˜#ð Að Að Að Að Að Að Að Ar   )r   Útyping_extensionsr   r)   r   Útorch.distributionsr   Útorch.distributions.utilsr   Útorch.typesr   Ú__all__r   r|   r   r   ú<module>rœ      sÁ   ðà €€€Ø (Ð (Ð (Ð (Ð (Ð (à €€€Ø Ð Ð Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø Ð Ð Ð Ð Ð ð Ð
€ðMAð MAð MAð MAð MAñ MAô MAð MAð MAð MAr   