o
    Zh                     @   sV   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	 dgZ
G dd deZdS )	    )Tensor)constraints)Normal)TransformedDistribution)StickBreakingTransformLogisticNormalc                       sl   e Zd ZdZejejdZejZ	dZ
d fdd	Zd fdd	Zed	efd
dZed	efddZ  ZS )r   a9  
    Creates a logistic-normal distribution parameterized by :attr:`loc` and :attr:`scale`
    that define the base `Normal` distribution transformed with the
    `StickBreakingTransform` such that::

        X ~ LogisticNormal(loc, scale)
        Y = log(X / (1 - X.cumsum(-1)))[..., :-1] ~ Normal(loc, scale)

    Args:
        loc (float or Tensor): mean of the base distribution
        scale (float or Tensor): standard deviation of the base distribution

    Example::

        >>> # logistic-normal distributed with mean=(0, 0, 0) and stddev=(1, 1, 1)
        >>> # of the base Normal distribution
        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = LogisticNormal(torch.tensor([0.0] * 3), torch.tensor([1.0] * 3))
        >>> m.sample()
        tensor([ 0.7653,  0.0341,  0.0579,  0.1427])

    )locscaleTNc                    s8   t |||d}|js|dg}t j|t |d d S )N)validate_args   )r   batch_shapeexpandsuper__init__r   )selfr   r	   r
   	base_dist	__class__ R/var/www/auris/lib/python3.10/site-packages/torch/distributions/logistic_normal.pyr   (   s   
zLogisticNormal.__init__c                    s   |  t|}t j||dS )N)	_instance)Z_get_checked_instancer   r   r   )r   r   r   newr   r   r   r   0   s   zLogisticNormal.expandreturnc                 C   
   | j j jS N)r   r   r   r   r   r   r   4      
zLogisticNormal.locc                 C   r   r   )r   r	   r   r   r   r   r	   8   r   zLogisticNormal.scaler   )__name__
__module____qualname____doc__r   realZpositiveZarg_constraintsZsimplexZsupportZhas_rsampler   r   propertyr   r   r	   __classcell__r   r   r   r   r      s    N)Ztorchr   Ztorch.distributionsr   Ztorch.distributions.normalr   Z,torch.distributions.transformed_distributionr   Ztorch.distributions.transformsr   __all__r   r   r   r   r   <module>   s   