
    9i                     x    S SK JrJr  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Jr  S/r " S	 S\5      rg)
    )OptionalUnionN)Tensor)constraints)Distribution)broadcast_all)_Number_sizeLaplacec            	       l  ^  \ rS rSrSr\R                  \R                  S.r\R                  r	Sr
\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S	 j5       r SS\\\4   S\\\4   S\\   SS
4U 4S jjjrSU 4S jjr\R0                  " 5       4S\S\4S jjrS rS rS rS rSrU =r $ )r      a  
Creates a Laplace distribution parameterized by :attr:`loc` and :attr:`scale`.

Example::

    >>> # xdoctest: +IGNORE_WANT("non-deterministic")
    >>> m = Laplace(torch.tensor([0.0]), torch.tensor([1.0]))
    >>> m.sample()  # Laplace distributed with loc=0, scale=1
    tensor([ 0.1046])

Args:
    loc (float or Tensor): mean of the distribution
    scale (float or Tensor): scale of the distribution
)locscaleTreturnc                     U R                   $ Nr   selfs    [/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/distributions/laplace.pymeanLaplace.mean#       xx    c                     U R                   $ r   r   r   s    r   modeLaplace.mode'   r   r   c                 >    SU R                   R                  S5      -  $ N   )r   powr   s    r   varianceLaplace.variance+   s    4::>>!$$$r   c                      SU R                   -  $ )Ng;f?)r   r   s    r   stddevLaplace.stddev/   s    $**$$r   Nr   r   validate_argsc                   > [        X5      u  U l        U l        [        U[        5      (       a+  [        U[        5      (       a  [
        R                  " 5       nOU R                  R                  5       n[        TU ]%  XCS9  g )Nr'   )
r   r   r   
isinstancer	   torchSizesizesuper__init__)r   r   r   r'   batch_shape	__class__s        r   r/   Laplace.__init__3   s[      -S8$*c7##
5'(B(B**,K((--/KBr   c                 &  > U R                  [        U5      n[        R                  " U5      nU R                  R                  U5      Ul        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.   r/   _validate_args)r   r0   	_instancenewr1   s       r   r5   Laplace.expand@   st    (()<jj-((//+.JJ%%k2	gs$[$F!00
r   sample_shapec                 "   U R                  U5      n[        R                  " U R                  R                  5      n[        R
                  R                  5       (       a  [        R                  " X R                  R                  U R                  R                  S9S-  S-
  nU R                  U R                  UR                  5       -  [        R                  " UR                  5       R                  UR                  S9* 5      -  -
  $ U R                  R                  U5      R!                  UR"                  S-
  S5      nU R                  U R                  UR                  5       -  [        R                  " UR                  5       * 5      -  -
  $ )N)dtypedevicer       )min)_extended_shaper+   finfor   r<   _C_get_tracing_staterandr=   r   signlog1pabsclamptinyr8   uniform_eps)r   r:   shaperA   us        r   rsampleLaplace.rsampleI   s   $$\2DHHNN+88&&((

5txxORSSVWWA88djj16683ekk5::..7    HHLL((Q: xx$**qvvx/%++quuwh2GGGGr   c                     U R                   (       a  U R                  U5        [        R                  " SU R                  -  5      * [        R
                  " XR                  -
  5      U R                  -  -
  $ r   )r6   _validate_sampler+   logr   rG   r   r   values     r   log_probLaplace.log_probW   sQ    !!%(		!djj.))EIIehh6F,G$**,TTTr   c                    U R                   (       a  U R                  U5        SSXR                  -
  R                  5       -  [        R
                  " XR                  -
  R                  5       * U R                  -  5      -  -
  $ )N      ?)r6   rQ   r   rE   r+   expm1rG   r   rS   s     r   cdfLaplace.cdf\   sl    !!%(SEHH,2244u{{hh##%%

28
 
 
 	
r   c                     US-
  nU R                   U R                  UR                  5       -  [        R                  " SUR                  5       -  5      -  -
  $ )NrX   )r   r   rE   r+   rF   rG   )r   rT   terms      r   icdfLaplace.icdfc   sA    s{xx$**{{}4u{{2
?7SSSSr   c                 N    S[         R                  " SU R                  -  5      -   $ )Nr>   r    )r+   rR   r   r   s    r   entropyLaplace.entropyg   s    599Q^,,,r   r   )!__name__
__module____qualname____firstlineno____doc__r   realpositivearg_constraintssupporthas_rsamplepropertyr   r   r   r"   r%   r   floatr   boolr/   r5   r+   r,   r
   rN   rU   rZ   r_   rb   __static_attributes____classcell__)r1   s   @r   r   r      s,    *..9M9MNOGKf   f   %& % % % % % )-	C65=!C VU]#C  ~	C
 
C C -2JJL HE HV HU

T- -r   )typingr   r   r+   r   torch.distributionsr    torch.distributions.distributionr   torch.distributions.utilsr   torch.typesr	   r
   __all__r    r   r   <module>rz      s1    "   + 9 3 & +Y-l Y-r   