a
    h!                     @   sv   d dl mZmZ d dlZd dlmZ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)nanTensor)constraints)Distribution)broadcast_all)_Number_sizeUniformc                       s   e Zd ZdZdZedd ZeedddZeeddd	Z	eedd
dZ
eedddZd$eeef eeef ee dd fddZd% fdd	Zejddddd Ze feedddZdd Zdd Zd d! Zd"d# Z  ZS )&r   a  
    Generates uniformly distributed random samples from the half-open interval
    ``[low, high)``.

    Example::

        >>> m = Uniform(torch.tensor([0.0]), torch.tensor([5.0]))
        >>> m.sample()  # uniformly distributed in the range [0.0, 5.0)
        >>> # xdoctest: +SKIP
        tensor([ 2.3418])

    Args:
        low (float or Tensor): lower range (inclusive).
        high (float or Tensor): upper range (exclusive).
    Tc                 C   s   t | jt | jdS )N)lowhigh)r   	less_thanr   greater_thanr   self r   I/var/www/auris/lib/python3.9/site-packages/torch/distributions/uniform.pyarg_constraints"   s    

zUniform.arg_constraints)returnc                 C   s   | j | j d S )N   r   r   r   r   r   r   mean*   s    zUniform.meanc                 C   s
   t | j S N)r   r   r   r   r   r   mode.   s    zUniform.modec                 C   s   | j | j d S )NgLXz@r   r   r   r   r   stddev2   s    zUniform.stddevc                 C   s   | j | j dd S )Nr      )r   r   powr   r   r   r   variance6   s    zUniform.varianceN)r   r   validate_argsr   c                    sN   t ||\| _| _t|tr0t|tr0t }n
| j }t j	||d d S )Nr   )
r   r   r   
isinstancer	   torchSizesizesuper__init__)r   r   r   r   batch_shape	__class__r   r   r&   :   s
    

zUniform.__init__c                    sR   |  t|}t|}| j||_| j||_tt|j|dd | j	|_	|S )NFr    )
Z_get_checked_instancer   r"   r#   r   expandr   r%   r&   _validate_args)r   r'   Z	_instancenewr(   r   r   r*   H   s    
zUniform.expandFr   )Zis_discreteZ	event_dimc                 C   s   t | j| jS r   )r   intervalr   r   r   r   r   r   supportQ   s    zUniform.support)sample_shaper   c                 C   s8   |  |}tj|| jj| jjd}| j|| j| j   S )N)dtypedevice)Z_extended_shaper"   randr   r0   r1   r   )r   r/   shaper2   r   r   r   rsampleU   s    
zUniform.rsamplec                 C   sZ   | j r| | | j|| j}| j|| j}t|	|t| j| j  S r   )
r+   _validate_sampler   leZtype_asr   gtr"   logmul)r   valueZlbZubr   r   r   log_probZ   s
    
zUniform.log_probc                 C   s4   | j r| | || j | j| j  }|jdddS )Nr      )minmax)r+   r5   r   r   clampr   r:   resultr   r   r   cdfa   s    
zUniform.cdfc                 C   s   || j | j  | j }|S r   r   r@   r   r   r   icdfg   s    zUniform.icdfc                 C   s   t | j| j S r   )r"   r8   r   r   r   r   r   r   entropyk   s    zUniform.entropy)N)N)__name__
__module____qualname____doc__Zhas_rsamplepropertyr   r   r   r   r   r   r   floatr   boolr&   r*   r   Zdependent_propertyr.   r"   r#   r
   r4   r;   rB   rC   rD   __classcell__r   r   r(   r   r      s6   
 

	
)typingr   r   r"   r   r   Ztorch.distributionsr   Z torch.distributions.distributionr   Ztorch.distributions.utilsr   Ztorch.typesr	   r
   __all__r   r   r   r   r   <module>   s   