
    }Yh
                     |    d dl mZ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 dlmZ dgZ G d	 de
          ZdS )
    )OptionalUnionN)Tensor)constraints)Gamma)TransformedDistribution)PowerTransformInverseGammac            	       >    e Zd ZU dZej        ej        dZej        ZdZe	e
d<   	 ddeeef         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ed	ef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rateT	base_distNr   r   validate_argsreturnc                     t          |||          }|j                            d           }t                                          |t          |          |           d S )N)r    )r   r   new_onessuper__init__r	   )selfr   r   r   r   neg_one	__class__s         s/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torch/distributions/inverse_gamma.pyr   zInverseGamma.__init__-   sk     -]KKK	>**2...~g..m 	 	
 	
 	
 	
 	
    c                     |                      t          |          }t                                          ||          S )N)	_instance)_get_checked_instancer
   r   expand)r   batch_shaper   newr   s       r   r   zInverseGamma.expand9   s2    ((yAAww~~kS~999r   c                     | j         j        S N)r   r   r   s    r   r   zInverseGamma.concentration=   s    ~++r   c                     | j         j        S r"   )r   r   r#   s    r   r   zInverseGamma.rateA   s    ~""r   c                 x    | j         | j        dz
  z  }t          j        | j        dk    |t          j                  S N   )r   r   torchwhereinfr   results     r   meanzInverseGamma.meanE   s4    d0145{4-1659EEEr   c                 &    | j         | j        dz   z  S r&   )r   r   r#   s    r   modezInverseGamma.modeJ   s    yD.233r   c                     | j                                         | j        dz
                                  | j        dz
  z  z  }t          j        | j        dk    |t          j                  S )Nr'      )r   squarer   r(   r)   r*   r+   s     r   variancezInverseGamma.varianceN   s^    !!##!#++--1Ca1GH
 {4-1659EEEr   c                     | j         | j                                        z   | j                                         z   d| j         z   | j                                         z  z
  S r&   )r   r   loglgammadigammar#   s    r   entropyzInverseGamma.entropyU   s]    immoo ''))* 4%%);)C)C)E)EEF	
r   r"   )__name__
__module____qualname____doc__r   positivearg_constraintssupporthas_rsampler   __annotations__r   r   floatr   boolr   r   propertyr   r   r-   r/   r3   r8   __classcell__)r   s   @r   r
   r
      s         , %-$ O "GK )-	

 

VU]+

 FEM"

  ~	


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