§
    ®˜ºh0
  ã                   óˆ   — d dl Z d dlmZmZ d dlZd dlmZm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e¦  «        ZdS )
é    N)ÚOptionalÚUnion)ÚinfÚTensor)Úconstraints)ÚCauchy)ÚTransformedDistribution)ÚAbsTransformÚ
HalfCauchyc                   ó  ‡ — e Zd ZU dZdej        iZej        ZdZ	e
ed<   	 ddeeef         dee         ddfˆ fd„Zdˆ 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d„ Zd„ Zd„ Zd„ Zˆ xZS )r   a´  
    Creates a half-Cauchy distribution parameterized by `scale` where::

        X ~ Cauchy(0, scale)
        Y = |X| ~ HalfCauchy(scale)

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = HalfCauchy(torch.tensor([1.0]))
        >>> m.sample()  # half-cauchy distributed with scale=1
        tensor([ 2.3214])

    Args:
        scale (float or Tensor): scale of the full Cauchy distribution
    ÚscaleTÚ	base_distNÚvalidate_argsÚreturnc                 óŒ   •— t          d|d¬¦  «        }t          ¦   «                              |t          ¦   «         |¬¦  «         d S )Nr   F)r   )r   ÚsuperÚ__init__r
   )Úselfr   r   r   Ú	__class__s       €úg/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/torch/distributions/half_cauchy.pyr   zHalfCauchy.__init__'   sB   ø€ õ
 ˜1˜e°5Ð9Ñ9Ô9ˆ	Ý‰Œ×Ò˜¥L¡N¤NÀ-ÐÑPÔPÐPÐPÐPó    c                 ó€   •— |                       t          |¦  «        }t          ¦   «                              ||¬¦  «        S )N)Ú	_instance)Ú_get_checked_instancer   r   Úexpand)r   Úbatch_shaper   Únewr   s       €r   r   zHalfCauchy.expand/   s2   ø€ Ø×(Ò(­°YÑ?Ô?ˆÝ‰wŒw�~Š~˜k°Sˆ~Ñ9Ô9Ð9r   c                 ó   — | j         j        S ©N)r   r   ©r   s    r   r   zHalfCauchy.scale3   s   € àŒ~Ô#Ð#r   c                 ó’   — t          j        |                      ¦   «         t          j        | j        j        | j        j        ¬¦  «        S )N©ÚdtypeÚdevice)ÚtorchÚfullÚ_extended_shapeÚmathr   r   r#   r$   r    s    r   ÚmeanzHalfCauchy.mean7   s?   € åŒzØ× Ò Ñ"Ô"ÝŒHØ”*Ô"Ø”:Ô$ð	
ñ 
ô 
ð 	
r   c                 ó4   — t          j        | j        ¦  «        S r   )r%   Ú
zeros_liker   r    s    r   ÚmodezHalfCauchy.mode@   s   € åÔ ¤
Ñ+Ô+Ð+r   c                 ó   — | j         j        S r   )r   Úvariancer    s    r   r.   zHalfCauchy.varianceD   s   € àŒ~Ô&Ð&r   c                 óF  — | j         r|                      |¦  «         t          j        || j        j        j        | j        j        j        ¬¦  «        }| j                             |¦  «        t          j
        d¦  «        z   }t          j        |dk    |t           ¦  «        }|S )Nr"   é   r   )Ú_validate_argsÚ_validate_sampler%   Ú	as_tensorr   r   r#   r$   Úlog_probr(   ÚlogÚwherer   )r   Úvaluer4   s      r   r4   zHalfCauchy.log_probH   s�   € ØÔð 	)Ø×!Ò! %Ñ(Ô(Ð(Ý”Ø˜œÔ-Ô3¸D¼NÔ<PÔ<Wð
ñ 
ô 
ˆð ”>×*Ò*¨5Ñ1Ô1µD´H¸Q±K´KÑ?ˆÝ”;˜u¨šz¨8µc°TÑ:Ô:ˆØˆr   c                 óz   — | j         r|                      |¦  «         d| j                             |¦  «        z  dz
  S )Nr0   é   )r1   r2   r   Úcdf)r   r7   s     r   r:   zHalfCauchy.cdfR   sA   € ØÔð 	)Ø×!Ò! %Ñ(Ô(Ð(Ø�4”>×%Ò% eÑ,Ô,Ñ,¨qÑ0Ð0r   c                 óB   — | j                              |dz   dz  ¦  «        S )Nr9   r0   )r   Úicdf)r   Úprobs     r   r<   zHalfCauchy.icdfW   s    € ØŒ~×"Ò" D¨1¡H°¡>Ñ2Ô2Ð2r   c                 ó^   — | j                              ¦   «         t          j        d¦  «        z
  S )Nr0   )r   Úentropyr(   r5   r    s    r   r?   zHalfCauchy.entropyZ   s#   € ØŒ~×%Ò%Ñ'Ô'­$¬(°1©+¬+Ñ5Ð5r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚpositiveÚarg_constraintsÚnonnegativeÚsupportÚhas_rsampler   Ú__annotations__r   r   Úfloatr   Úboolr   r   Úpropertyr   r)   r,   r.   r4   r:   r<   r?   Ú__classcell__)r   s   @r   r   r      s¤  ø€ € € € € € ðð ð"  Ô 4Ð5€OØÔ%€GØ€KØÐÐÑð
 )-ðQð Qà�V˜U�]Ô#ðQð   ”~ðQð 
ð	Qð Qð Qð Qð Qð Qð:ð :ð :ð :ð :ð :ð ð$�vð $ð $ð $ñ „Xð$ð ð
�fð 
ð 
ð 
ñ „Xð
ð ð,�fð ,ð ,ð ,ñ „Xð,ð ð'˜&ð 'ð 'ð 'ñ „Xð'ðð ð ð1ð 1ð 1ð
3ð 3ð 3ð6ð 6ð 6ð 6ð 6ð 6ð 6r   )r(   Útypingr   r   r%   r   r   Útorch.distributionsr   Útorch.distributions.cauchyr   Ú,torch.distributions.transformed_distributionr	   Útorch.distributions.transformsr
   Ú__all__r   © r   r   ú<module>rU      s×   ðà €€€Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ø -Ð -Ð -Ð -Ð -Ð -Ø PÐ PÐ PÐ PÐ PÐ PØ 7Ð 7Ð 7Ð 7Ð 7Ð 7ð ˆ.€ðK6ð K6ð K6ð K6ð K6Ð(ñ K6ô K6ð K6ð K6ð K6r   