ó
    [T–h…	  ã                   ó@   • S SK r S SK Jr  S SKJr  S/r " S S\5      rg)é    N)ÚTensor)ÚDistributionÚExponentialFamilyc                   ó^   • \ rS rSrSr\S\\S4   4S j5       rS r	\S\
4S j5       rS rS	rg
)r   é
   aš  
ExponentialFamily is the abstract base class for probability distributions belonging to an
exponential family, whose probability mass/density function has the form is defined below

.. math::

    p_{F}(x; \theta) = \exp(\langle t(x), \theta\rangle - F(\theta) + k(x))

where :math:`\theta` denotes the natural parameters, :math:`t(x)` denotes the sufficient statistic,
:math:`F(\theta)` is the log normalizer function for a given family and :math:`k(x)` is the carrier
measure.

Note:
    This class is an intermediary between the `Distribution` class and distributions which belong
    to an exponential family mainly to check the correctness of the `.entropy()` and analytic KL
    divergence methods. We use this class to compute the entropy and KL divergence using the AD
    framework and Bregman divergences (courtesy of: Frank Nielsen and Richard Nock, Entropies and
    Cross-entropies of Exponential Families).
Úreturn.c                 ó   • [         e)z^
Abstract method for natural parameters. Returns a tuple of Tensors based
on the distribution
©ÚNotImplementedError©Úselfs    ÚV/var/www/auris/envauris/lib/python3.13/site-packages/torch/distributions/exp_family.pyÚ_natural_paramsÚ!ExponentialFamily._natural_params   ó
   € ô "Ð!ó    c                 ó   • [         e)zk
Abstract method for log normalizer function. Returns a log normalizer based on
the distribution and input
r
   )r   Únatural_paramss     r   Ú_log_normalizerÚ!ExponentialFamily._log_normalizer'   s
   € ô
 "Ð!r   c                 ó   • [         e)zX
Abstract method for expected carrier measure, which is required for computing
entropy.
r
   r   s    r   Ú_mean_carrier_measureÚ'ExponentialFamily._mean_carrier_measure.   r   r   c                 ó¤  • U R                   * nU R                   Vs/ s H   o"R                  5       R                  5       PM"     nnU R                  " U6 n[
        R                  R                  UR                  5       USS9nX-  n[        X55       H7  u  pgXU-  R                  U R                  S-   5      R                  S5      -  nM9     U$ s  snf )zO
Method to compute the entropy using Bregman divergence of the log normalizer.
T)Úcreate_graph)éÿÿÿÿr   )r   r   ÚdetachÚrequires_grad_r   ÚtorchÚautogradÚgradÚsumÚzipÚreshapeÚ_batch_shape)r   ÚresultÚpÚnparamsÚ	lg_normalÚ	gradientsÚnpÚgs           r   ÚentropyÚExponentialFamily.entropy6   s½   € ð ×,Ñ,Ð,ˆØ8<×8LÒ8LÓMÒ8L°1—8‘8“:×,Ñ,Ö.Ñ8LˆÐMØ×(Ò(¨'Ð2ˆ	Ü—N‘N×'Ñ'¨	¯©«¸ÈtÐ'ÐTˆ	ØÑˆÜ˜Ö,‰EˆBØ˜A‘v×&Ñ& t×'8Ñ'8¸5Ñ'@ÓA×EÑEÀbÓIÑIŠFñ -àˆùò Ns   œ'C© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚpropertyÚtupler   r   r   Úfloatr   r-   Ú__static_attributes__r/   r   r   r   r   
   sP   † ñð( ð"  v¨s {Ñ!3ó "ó ð"ò"ð ð" uó "ó ð"õr   )r   r   Ú torch.distributions.distributionr   Ú__all__r   r/   r   r   Ú<module>r;      s$   ðã Ý Ý 9ð Ð
€ô7˜õ 7r   