o
    ,h
                     @   sr   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mZ dgZG d	d deZdS )
    )OptionalUnionN)Tensor)constraints)ExponentialFamily)broadcast_all)_Number_sizeExponentialc                       s  e Zd ZdZdejiZejZdZ	dZ
edefddZedefdd	Zedefd
dZedefddZ	d#deeef dee ddf fddZd# fdd	Ze fdedefddZdd Zdd Zdd Zdd Zedee fdd Z d!d" Z!  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                 C   
   | j  S Nr   
reciprocalself r   Z/var/www/html/scripts/venv/lib/python3.10/site-packages/torch/distributions/exponential.pymean#      
zExponential.meanc                 C   s   t | jS r   )torch
zeros_liker   r   r   r   r   mode'      zExponential.modec                 C   r   r   r   r   r   r   r   stddev+   r   zExponential.stddevc                 C   s   | j dS )N)r   powr   r   r   r   variance/   r   zExponential.varianceNvalidate_argsc                    s<   t |\| _t|trt n| j }t j||d d S )Nr   )	r   r   
isinstancer   r   Sizesizesuper__init__)r   r   r   batch_shape	__class__r   r   r%   3   s   zExponential.__init__c                    sD   |  t|}t|}| j||_tt|j|dd | j|_|S )NFr    )	_get_checked_instancer
   r   r"   r   expandr$   r%   _validate_args)r   r&   	_instancenewr'   r   r   r*   <   s   
zExponential.expandsample_shapec                 C   s    |  |}| j| | j S r   )_extended_shaper   r-   exponential_)r   r.   shaper   r   r   rsampleD   s   
zExponential.rsamplec                 C   s$   | j r| | | j | j|  S r   )r+   _validate_sampler   logr   valuer   r   r   log_probH   s   
zExponential.log_probc                 C   s&   | j r| | dt| j |  S )N   )r+   r3   r   expr   r5   r   r   r   cdfM   s   
zExponential.cdfc                 C   s   t |  | j S r   )r   log1pr   r5   r   r   r   icdfR   s   zExponential.icdfc                 C   s   dt | j S )Ng      ?)r   r4   r   r   r   r   r   entropyU   s   zExponential.entropyc                 C   s
   | j  fS r   )r   r   r   r   r   _natural_paramsX   r   zExponential._natural_paramsc                 C   s   t |  S r   )r   r4   )r   xr   r   r   _log_normalizer\   s   zExponential._log_normalizerr   )#__name__
__module____qualname____doc__r   positivearg_constraintsnonnegativesupporthas_rsample_mean_carrier_measurepropertyr   r   r   r   r   r   floatr   boolr%   r*   r   r"   r	   r2   r7   r:   r<   r=   tupler>   r@   __classcell__r   r   r'   r   r
      s>    

	)typingr   r   r   r   torch.distributionsr   torch.distributions.exp_familyr   torch.distributions.utilsr   torch.typesr   r	   __all__r
   r   r   r   r   <module>   s   