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   Z
reciprocal©Úself© r   úe/home/www/facesmatcher.com/frenv_anti/lib/python3.10/site-packages/torch/distributions/exponential.pyÚmean#   ó   
zExponential.meanc                 C   s   t  | j¡S r   )ÚtorchZ
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   )	Z_get_checked_instancer
   r   r    r   Úexpandr"   r#   Ú_validate_args)r   r$   Z	_instanceÚnewr%   r   r   r'   <   s   
zExponential.expandÚsample_shapec                 C   s    |   |¡}| j |¡ ¡ | j S r   )Z_extended_shaper   r)   Z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(   r-   r   Úexpr   r/   r   r   r   ÚcdfM   s   
zExponential.cdfc                 C   s   t  | ¡ | j S r   )r   Úlog1pr   r/   r   r   r   ÚicdfR   s   zExponential.icdfc                 C   s   dt  | j¡ S )Ng      ð?)r   r.   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   r.   )r   Úxr   r   r   Ú_log_normalizer\   s   zExponential._log_normalizerr   )#Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZpositiveZarg_constraintsZnonnegativeZsupportZhas_rsampleZ_mean_carrier_measureÚpropertyr   r   r   r   r   r   Úfloatr   Úboolr#   r'   r   r    r	   r,   r1   r4   r6   r7   Útupler8   r:   Ú__classcell__r   r   r%   r   r
      s>    
ý
þýü	)Útypingr   r   r   r   Ztorch.distributionsr   Ztorch.distributions.exp_familyr   Ztorch.distributions.utilsr   Ztorch.typesr   r	   Ú__all__r
   r   r   r   r   Ú<module>   s   