
    j
                     p    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	m
Z
 dgZ G d de          ZdS )	    N)Tensor)constraints)ExponentialFamily)broadcast_all)_Number_sizeExponentialc                   X    e Zd ZdZdej        iZej        ZdZ	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deez  ded
z  dd
f fdZd fd	Z ej                    fdedefdZd Zd Zd Zd Zedee         fd            Zd Z xZ S )r	   an  
    Creates a Exponential distribution parameterized by :attr:`rate`.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = Exponential(torch.tensor([1.0]))
        >>> m.sample()  # Exponential distributed with rate=1
        tensor([ 0.1046])

    Args:
        rate (float or Tensor): rate = 1 / scale of the distribution
    rateTr   returnc                 4    | j                                         S Nr   
reciprocalselfs    i/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/torch/distributions/exponential.pymeanzExponential.mean#       y##%%%    c                 4    t          j        | j                  S r   )torch
zeros_liker   r   s    r   modezExponential.mode'   s    	***r   c                 4    | j                                         S r   r   r   s    r   stddevzExponential.stddev+   r   r   c                 6    | j                             d          S )N)r   powr   s    r   variancezExponential.variance/   s    y}}R   r   Nvalidate_argsc                     t          |          \  | _        t          |t                    rt	          j                    n| j                                        }t                                          ||           d S )Nr!   )	r   r   
isinstancer   r   Sizesizesuper__init__)r   r   r!   batch_shape	__class__s       r   r(   zExponential.__init__3   sc    
 %T**&0w&?&?UejlllTY^^EUEUMBBBBBr   c                    |                      t          |          }t          j        |          }| j                            |          |_        t          t          |                              |d           | j        |_        |S )NFr#   )	_get_checked_instancer	   r   r%   r   expandr'   r(   _validate_args)r   r)   	_instancenewr*   s       r   r-   zExponential.expand<   sq    ((i@@j--9##K00k3((E(JJJ!0
r   sample_shapec                     |                      |          }| j                            |                                          | j        z  S r   )_extended_shaper   r0   exponential_)r   r1   shapes      r   rsamplezExponential.rsampleD   s<    $$\22y}}U##0022TY>>r   c                     | j         r|                     |           | j                                        | j        |z  z
  S r   )r.   _validate_sampler   logr   values     r   log_probzExponential.log_probH   s=     	)!!%(((y}}U!222r   c                 z    | j         r|                     |           dt          j        | j         |z            z
  S )N   )r.   r8   r   expr   r:   s     r   cdfzExponential.cdfM   s?     	)!!%(((59diZ%/0000r   c                 >    t          j        |            | j        z  S r   )r   log1pr   r:   s     r   icdfzExponential.icdfR   s    UF###di//r   c                 :    dt          j        | j                  z
  S )Ng      ?)r   r9   r   r   s    r   entropyzExponential.entropyU   s    UYty))))r   c                     | j          fS r   )r   r   s    r   _natural_paramszExponential._natural_paramsX   s    
}r   c                 .    t          j        |            S r   )r   r9   )r   xs     r   _log_normalizerzExponential._log_normalizer]   s    	1"~r   r   )!__name__
__module____qualname____doc__r   positivearg_constraintsnonnegativesupporthas_rsample_mean_carrier_measurepropertyr   r   r   r   r    floatboolr(   r-   r   r%   r   r6   r<   r@   rC   rE   tuplerG   rJ   __classcell__)r*   s   @r   r	   r	      s         {34O%GK&f & & & X& +f + + + X+ & & & & X& !& ! ! ! X! &*C CunC d{C 
	C C C C C C      -7EJLL ? ?E ?V ? ? ? ?3 3 3
1 1 1
0 0 0* * * v    X      r   )r   r   torch.distributionsr   torch.distributions.exp_familyr   torch.distributions.utilsr   torch.typesr   r   __all__r	    r   r   <module>r`      s           + + + + + + < < < < < < 3 3 3 3 3 3 & & & & & & & & /P P P P P# P P P P Pr   