Ë
    P/æjÉ	  ã                   óX   — 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e«      Z
y)é    N)Úconstraints)ÚGamma)ÚTransformedDistribution)ÚPowerTransformÚInverseGammac                   óÔ   ‡ — e Zd ZdZej
                  ej
                  dœZej
                  ZdZdˆ fd„	Z	dˆ fd„	Z
ed„ «       Zed„ «       Zed„ «       Zed	„ «       Zed
„ «       Zd„ Zˆ xZS )r   a€  
    Creates an inverse gamma distribution parameterized by :attr:`concentration` and :attr:`rate`
    where::

        X ~ Gamma(concentration, rate)
        Y = 1 / X ~ InverseGamma(concentration, rate)

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterinistic")
        >>> m = InverseGamma(torch.tensor([2.0]), torch.tensor([3.0]))
        >>> m.sample()
        tensor([ 1.2953])

    Args:
        concentration (float or Tensor): shape parameter of the distribution
            (often referred to as alpha)
        rate (float or Tensor): rate = 1 / scale of the distribution
            (often referred to as beta)
    )ÚconcentrationÚrateTc                 ó�   •— t        |||¬«      }|j                  j                  d«       }t        ‰| �  |t        |«      |¬«       y )N)Úvalidate_args© )r   r
   Únew_onesÚsuperÚ__init__r   )Úselfr	   r
   r   Ú	base_distÚneg_oneÚ	__class__s         €úd/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torch/distributions/inverse_gamma.pyr   zInverseGamma.__init__(   sF   ø€ Ü˜-¨¸]ÔKˆ	Ø—>‘>×*Ñ*¨2Ó.Ð.ˆÜ‰ÑØ”~ gÓ.¸mð 	õ 	
ó    c                 óR   •— | j                  t        |«      }t        ‰| �  ||¬«      S )N)Ú	_instance)Ú_get_checked_instancer   r   Úexpand)r   Úbatch_shaper   Únewr   s       €r   r   zInverseGamma.expand/   s(   ø€ Ø×(Ñ(¬°yÓAˆÜ‰w‰~˜k°Sˆ~Ó9Ð9r   c                 ó.   — | j                   j                  S ©N)r   r	   ©r   s    r   r	   zInverseGamma.concentration3   s   € à�~‰~×+Ñ+Ð+r   c                 ó.   — | j                   j                  S r   )r   r
   r   s    r   r
   zInverseGamma.rate7   s   € à�~‰~×"Ñ"Ð"r   c                 óž   — | j                   | j                  dz
  z  }t        j                  | j                  dkD  |t        j                  «      S ©Né   )r
   r	   ÚtorchÚwhereÚinf©r   Úresults     r   ÚmeanzInverseGamma.mean;   s=   € à—‘˜d×0Ñ0°1Ñ4Ñ5ˆÜ�{‰{˜4×-Ñ-°Ñ1°6¼5¿9¹9ÓEÐEr   c                 ó:   — | j                   | j                  dz   z  S r"   )r
   r	   r   s    r   ÚmodezInverseGamma.mode@   s   € à�y‰y˜D×.Ñ.°Ñ2Ñ3Ð3r   c                 óö   — | j                   j                  «       | j                  dz
  j                  «       | j                  dz
  z  z  }t        j                  | j                  dkD  |t        j
                  «      S )Nr#   é   )r
   Úsquarer	   r$   r%   r&   r'   s     r   ÚvariancezInverseGamma.varianceD   sd   € à—‘×!Ñ!Ó#Ø×Ñ !Ñ#×+Ñ+Ó-°×1CÑ1CÀaÑ1GÑHñ
ˆô �{‰{˜4×-Ñ-°Ñ1°6¼5¿9¹9ÓEÐEr   c                 óÜ   — | j                   | j                  j                  «       z   | j                   j                  «       z   d| j                   z   | j                   j	                  «       z  z
  S r"   )r	   r
   ÚlogÚlgammaÚdigammar   s    r   ÚentropyzInverseGamma.entropyK   sc   € à×ÑØ�i‰i�m‰m‹oñà× Ñ ×'Ñ'Ó)ñ*ð �4×%Ñ%Ñ%¨×);Ñ);×)CÑ)CÓ)EÑEñFð	
r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚpositiveÚarg_constraintsÚsupportÚhas_rsampler   r   Úpropertyr	   r
   r)   r+   r/   r4   Ú__classcell__)r   s   @r   r   r      s¬   ø„ ñð* %×-Ñ-Ø×$Ñ$ñ€Oð ×"Ñ"€GØ€Kõ
õ:ð ñ,ó ð,ð ñ#ó ð#ð ñFó ðFð ñ4ó ð4ð ñFó ðFö
r   )r$   Útorch.distributionsr   Útorch.distributions.gammar   Ú,torch.distributions.transformed_distributionr   Útorch.distributions.transformsr   Ú__all__r   r   r   r   ú<module>rD      s-   ðã Ý +Ý +Ý PÝ 9ð Ð
€ôE
Ð*õ E
r   