
    [Th	                     d    S SK r S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S/r
 " S S\5      rg)	    N)Tensor)constraints)ExponentialFamily)broadcast_all)_NumberPoissonc                     ^  \ rS rSrSrS\R                  0r\R                  r	\
S\4S j5       r\
S\4S j5       r\
S\4S j5       rSU 4S jjrSU 4S	 jjr\R$                  " 5       4S
 jrS r\
S\\   4S j5       rS rSrU =r$ )r      a  
Creates a Poisson distribution parameterized by :attr:`rate`, the rate parameter.

Samples are nonnegative integers, with a pmf given by

.. math::
  \mathrm{rate}^k \frac{e^{-\mathrm{rate}}}{k!}

Example::

    >>> # xdoctest: +SKIP("poisson_cpu not implemented for 'Long'")
    >>> m = Poisson(torch.tensor([4]))
    >>> m.sample()
    tensor([ 3.])

Args:
    rate (Number, Tensor): the rate parameter
ratereturnc                     U R                   $ Nr   selfs    S/var/www/auris/envauris/lib/python3.13/site-packages/torch/distributions/poisson.pymeanPoisson.mean$       yy    c                 6    U R                   R                  5       $ r   )r   floorr   s    r   modePoisson.mode(   s    yy  r   c                     U R                   $ r   r   r   s    r   variancePoisson.variance,   r   r   c                    > [        U5      u  U l        [        U[        5      (       a  [        R
                  " 5       nOU R                  R                  5       n[        TU ]!  X2S9  g )Nvalidate_args)	r   r   
isinstancer   torchSizesizesuper__init__)r   r   r    batch_shape	__class__s       r   r&   Poisson.__init__0   sI    $T*dG$$**,K))..*KBr   c                    > U R                  [        U5      n[        R                  " U5      nU R                  R                  U5      Ul        [        [        U]  USS9  U R                  Ul        U$ )NFr   )	_get_checked_instancer   r"   r#   r   expandr%   r&   _validate_args)r   r'   	_instancenewr(   s       r   r,   Poisson.expand8   s`    (()<jj-99##K0gs$[$F!00
r   c                     U R                  U5      n[        R                  " 5          [        R                  " U R                  R                  U5      5      sS S S 5        $ ! , (       d  f       g = fr   )_extended_shaper"   no_gradpoissonr   r,   )r   sample_shapeshapes      r   samplePoisson.sample@   s@    $$\2]]_==!1!1%!89 __s   /A  
A.c                     U R                   (       a  U R                  U5        [        U R                  U5      u  p!UR	                  U5      U-
  US-   R                  5       -
  $ )N   )r-   _validate_sampler   r   xlogylgamma)r   valuer   s      r   log_probPoisson.log_probE   sQ    !!%(#DIIu5{{4 4'519*<*<*>>>r   c                 D    [         R                  " U R                  5      4$ r   )r"   logr   r   s    r   _natural_paramsPoisson._natural_paramsK   s    		$))$&&r   c                 .    [         R                  " U5      $ r   )r"   exp)r   xs     r   _log_normalizerPoisson._log_normalizerO   s    yy|r   r   r   )__name__
__module____qualname____firstlineno____doc__r   nonnegativearg_constraintsnonnegative_integersupportpropertyr   r   r   r   r&   r,   r"   r#   r7   r?   tuplerC   rH   __static_attributes____classcell__)r(   s   @r   r   r      s    & {667O--Gf   !f ! ! &  C #(**, :
? 'v ' ' r   )r"   r   torch.distributionsr   torch.distributions.exp_familyr   torch.distributions.utilsr   torch.typesr   __all__r    r   r   <module>r]      s/      + < 3  +C Cr   