
    IЦi	                     X    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)constraints)Gamma)TransformedDistribution)PowerTransformInverseGammac                      ^  \ rS rSrSr\R                  \R                  S.r\R                  rSr	SU 4S jjr
SU 4S jjr\S 5       r\S 5       r\S	 5       r\S
 5       r\S 5       rS rSrU =r$ )r      aD  
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                    > [        XUS9nUR                  R                  S5      * n[        TU ]  U[        U5      US9  g )N)validate_args )r   r   new_onessuper__init__r   )selfr
   r   r   	base_distneg_one	__class__s         `/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/distributions/inverse_gamma.pyr   InverseGamma.__init__(   sD    -]K	>>**2..~g.m 	 	
    c                 J   > U R                  [        U5      n[        TU ]  XS9$ )N)	_instance)_get_checked_instancer   r   expand)r   batch_shaper   newr   s       r   r   InverseGamma.expand/   s&    ((yAw~k~99r   c                 .    U R                   R                  $ N)r   r
   r   s    r   r
   InverseGamma.concentration3   s    ~~+++r   c                 .    U R                   R                  $ r!   )r   r   r"   s    r   r   InverseGamma.rate7   s    ~~"""r   c                     U R                   U R                  S-
  -  n[        R                  " U R                  S:  U[        R                  5      $ N   )r   r
   torchwhereinfr   results     r   meanInverseGamma.mean;   s=    d00145{{4--16599EEr   c                 :    U R                   U R                  S-   -  $ r'   )r   r
   r"   s    r   modeInverseGamma.mode@   s    yyD..233r   c                     U R                   R                  5       U R                  S-
  R                  5       U R                  S-
  -  -  n[        R                  " U R                  S:  U[        R
                  5      $ )Nr(      )r   squarer
   r)   r*   r+   r,   s     r   varianceInverseGamma.varianceD   sd    !!#!#++-1C1Ca1GH
 {{4--16599EEr   c                     U R                   U R                  R                  5       -   U R                   R                  5       -   SU R                   -   U R                   R	                  5       -  -
  $ r'   )r
   r   loglgammadigammar"   s    r   entropyInverseGamma.entropyK   sc    iimmo  '')* 4%%%););)C)C)EEF	
r   r   r!   )__name__
__module____qualname____firstlineno____doc__r   positivearg_constraintssupporthas_rsampler   r   propertyr
   r   r.   r1   r6   r<   __static_attributes____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>rO      s-     + + P 9 
E
* E
r   