
    9i
                     t    S SK JrJr  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 SKJr  S/r " S	 S\
5      rg)
    )OptionalUnionN)Tensor)constraints)Gamma)TransformedDistribution)PowerTransformInverseGammac            	       H  ^  \ rS rSr% Sr\R                  \R                  S.r\R                  rSr	\
\S'    SS\\\4   S\\\4   S	\\   S
S4U 4S jjjrSU 4S jjr\S
\4S j5       r\S
\4S j5       r\S
\4S j5       r\S
\4S j5       r\S
\4S j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rateT	base_distNr   r   validate_argsreturnc                    > [        XUS9nUR                  R                  S5      * n[        TU ]  U[        U5      US9  g )N)r    )r   r   new_onessuper__init__r	   )selfr   r   r   r   neg_one	__class__s         a/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/distributions/inverse_gamma.pyr   InverseGamma.__init__-   sF     -]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.expand9   s&    ((yAw~k~99r   c                 .    U R                   R                  $ N)r   r   r   s    r   r   InverseGamma.concentration=   s    ~~+++r   c                 .    U R                   R                  $ r%   )r   r   r&   s    r   r   InverseGamma.rateA   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.meanE   s=    d00145{{4--16599EEr   c                 :    U R                   U R                  S-   -  $ r+   )r   r   r&   s    r   modeInverseGamma.modeJ   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/   r0   s     r   varianceInverseGamma.varianceN   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.entropyU   sc    iimmo  '')* 4%%%););)C)C)EEF	
r   r   r%   )__name__
__module____qualname____firstlineno____doc__r   positivearg_constraintssupporthas_rsampler   __annotations__r   r   floatr   boolr   r    propertyr   r   r2   r5   r:   r@   __static_attributes____classcell__)r   s   @r   r
   r
      s"   , %--$$O ""GK )-	

VU]+

 FEM"

  ~	


 


 

: ,v , , #f # # Ff F F 4f 4 4 F& F F
 
r   )typingr   r   r-   r   torch.distributionsr   torch.distributions.gammar   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr	   __all__r
   r   r   r   <module>rW      s3    "   + + P 9 
L
* L
r   