o
    h
                     @   sb   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 )	    N)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" 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   s/var/www/html/construction_image-detection-poc/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.varianceNc                    s<   t |\| _t|trt n| j }t j||d d S )Nvalidate_args)	r   r	   
isinstancer   r   Sizesizesuper__init__)r   r	   r   batch_shape	__class__r   r   r#   1   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(   6   s   
zExponential.expandsample_shapec                 C   s    |  |}| j| | j S r   )_extended_shaper	   r+   exponential_)r   r,   shaper   r   r   rsample>   s   
zExponential.rsamplec                 C   s$   | j r| | | j | j|  S r   )r)   _validate_sampler	   logr   valuer   r   r   log_probB   s   
zExponential.log_probc                 C   s&   | j r| | dt| j |  S )N   )r)   r1   r   expr	   r3   r   r   r   cdfG   s   
zExponential.cdfc                 C   s   t |  | j S r   )r   log1pr	   r3   r   r   r   icdfL   s   zExponential.icdfc                 C   s   dt | j S )Ng      ?)r   r2   r	   r   r   r   r   entropyO   s   zExponential.entropyc                 C   s
   | j  fS r   )r	   r   r   r   r   _natural_paramsR   r   zExponential._natural_paramsc                 C   s   t |  S r   )r   r2   )r   xr   r   r   _log_normalizerV   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#   r(   r   r    r   r0   r5   r8   r:   r;   tupler<   r>   __classcell__r   r   r%   r   r      s0    
)r   r   torch.distributionsr   torch.distributions.exp_familyr   torch.distributions.utilsr   torch.typesr   r   __all__r   r   r   r   r   <module>   s   