ó
    Eñie  ã                   ó€   • S SK r S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	J
r
  S SKJr  S SKJrJr  S/r " S	 S\5      rg)
é    N)ÚTensor)Úconstraints)ÚDistribution)Úbroadcast_allÚlazy_propertyÚlogits_to_probsÚprobs_to_logits)Ú binary_cross_entropy_with_logits)Ú_NumberÚNumberÚ	Geometricc            	       óp  ^ • \ rS rSrSr\R                  \R                  S.r\R                  r
   SS\\-  S-  S\\-  S-  S\S-  SS4U 4S	 jjjrSU 4S
 jj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\4S j5       r\R0                  " 5       4S jrS rS rSrU =r$ )r   é   a<  
Creates a Geometric distribution parameterized by :attr:`probs`,
where :attr:`probs` is the probability of success of Bernoulli trials.

.. math::

    P(X=k) = (1-p)^{k} p, k = 0, 1, ...

.. note::
    :func:`torch.distributions.geometric.Geometric` :math:`(k+1)`-th trial is the first success
    hence draws samples in :math:`\{0, 1, \ldots\}`, whereas
    :func:`torch.Tensor.geometric_` `k`-th trial is the first success hence draws samples in :math:`\{1, 2, \ldots\}`.

Example::

    >>> # xdoctest: +IGNORE_WANT("non-deterministic")
    >>> m = Geometric(torch.tensor([0.3]))
    >>> m.sample()  # underlying Bernoulli has 30% chance 1; 70% chance 0
    tensor([ 2.])

Args:
    probs (Number, Tensor): the probability of sampling `1`. Must be in range (0, 1]
    logits (Number, Tensor): the log-odds of sampling `1`.
)ÚprobsÚlogitsNr   r   Úvalidate_argsÚreturnc           
      óz  >• US L US L :X  a  [        S5      eUb  [        U5      u  U l        O Uc  [        S5      e[        U5      u  U l        Ub  UOUn[        U[        5      (       a  [        R                  " 5       nOUc  [        S5      eUR                  5       n[        T	U ]-  XSS9  U R                  (       a�  Ub}  U R                  nUS:„  nUR                  5       (       dV  UR                  U)    n[        S[        U5      R                    S[#        UR$                  5       S['        U 5       S	U 35      eg g g )
Nz;Either `probs` or `logits` must be specified, but not both.zlogits is unexpectedly Nonez$probs_or_logits is unexpectedly None©r   r   zExpected parameter probs (z
 of shape z) of distribution z* to be positive but found invalid values:
)Ú
ValueErrorr   r   ÚAssertionErrorr   Ú
isinstancer   ÚtorchÚSizeÚsizeÚsuperÚ__init__Ú_validate_argsÚallÚdataÚtypeÚ__name__ÚtupleÚshapeÚrepr)
Úselfr   r   r   Úprobs_or_logitsÚbatch_shapeÚvalueÚvalidÚinvalid_valueÚ	__class__s
            €ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributions/geometric.pyr   ÚGeometric.__init__2   sH  ø€ ð �TˆM˜v¨˜~Ó.ÜØMóð ð Ñä)¨%Ó0‰MˆT�Zà‰~Ü$Ð%BÓCÐCä*¨6Ó2‰NˆTŒ[Ø#(Ñ#4™%¸&ˆÜ�o¤w×/Ñ/ÜŸ*š*›,‰KàÑ&Ü$Ð%KÓLÐLØ)×.Ñ.Ó0ˆKÜ‰Ñ˜ÐÑBØ×× 5Ñ#4à—J‘JˆEØ˜A‘IˆEØ—9‘9—;‘;Ø %§
¡
¨E¨6Ñ 2�Ü ðÜ˜U›×,Ñ,Ð-¨Z¼¸e¿k¹kÓ8JÐ7Kð L'Ü'+¨D£z lð 3AØANÀðQóð ð ð	 $5Ðó    c                 óf  >• U R                  [        U5      n[        R                  " U5      nSU R                  ;   a   U R
                  R                  U5      Ul        SU R                  ;   a   U R                  R                  U5      Ul        [        [        U]'  USS9  U R                  Ul
        U$ )Nr   r   Fr   )Ú_get_checked_instancer   r   r   Ú__dict__r   Úexpandr   r   r   r   )r&   r(   Ú	_instanceÚnewr,   s       €r-   r3   ÚGeometric.expandY   sŽ   ø€ Ø×(Ñ(¬°IÓ>ˆÜ—j’j Ó-ˆØ�d—m‘mÓ#ØŸ
™
×)Ñ)¨+Ó6ˆCŒIØ�t—}‘}Ó$ØŸ™×+Ñ+¨KÓ8ˆCŒJÜŒi˜Ñ& {À%Ð&ÑHØ!×0Ñ0ˆÔØˆ
r/   c                 ó&   • SU R                   -  S-
  $ ©Ng      ð?©r   ©r&   s    r-   ÚmeanÚGeometric.meand   s   € à�T—Z‘ZÑ #Ñ%Ð%r/   c                 óB   • [         R                  " U R                  5      $ ©N)r   Ú
zeros_liker   r:   s    r-   ÚmodeÚGeometric.modeh   s   € ä×Ò §
¡
Ó+Ð+r/   c                 ó@   • SU R                   -  S-
  U R                   -  $ r8   r9   r:   s    r-   ÚvarianceÚGeometric.variancel   s   € à�d—j‘jÑ  3Ñ&¨$¯*©*Ñ4Ð4r/   c                 ó*   • [        U R                  SS9$ ©NT)Ú	is_binary)r	   r   r:   s    r-   r   ÚGeometric.logitsp   s   € ä˜tŸz™z°TÑ:Ð:r/   c                 ó*   • [        U R                  SS9$ rF   )r   r   r:   s    r-   r   ÚGeometric.probst   s   € ä˜tŸ{™{°dÑ;Ð;r/   c                 ó–  • U R                  U5      n[        R                  " U R                  R                  5      R
                  n[        R                  " 5          [        R                  R                  5       (       aM  [        R                  " X R                  R                  U R                  R                  S9nUR                  US9nO+U R                  R                  U5      R                  US5      nUR                  5       U R                  * R                  5       -  R!                  5       sS S S 5        $ ! , (       d  f       g = f)N)ÚdtypeÚdevice)Úminé   )Ú_extended_shaper   Úfinfor   rL   ÚtinyÚno_gradÚ_CÚ_get_tracing_stateÚrandrM   Úclampr5   Úuniform_ÚlogÚlog1pÚfloor)r&   Úsample_shaper$   rR   Úus        r-   ÚsampleÚGeometric.samplex   sÏ   € Ø×$Ñ$ \Ó2ˆÜ�{Š{˜4Ÿ:™:×+Ñ+Ó,×1Ñ1ˆÜ�]Š]�_Ü�x‰x×*Ñ*×,Ñ,ä—J’J˜u¯J©J×,<Ñ,<ÀTÇZÁZ×EVÑEVÑW�Ø—G‘G �GÐ%‘à—J‘J—N‘N 5Ó)×2Ñ2°4¸Ó;�Ø—E‘E“G §
¡
˜{×1Ñ1Ó3Ñ3×:Ñ:Ó<÷ �_�_ús   ÁCD:Ä:
Ec                 ó$  • U R                   (       a  U R                  U5        [        XR                  5      u  pUR	                  [
        R                  S9nSX"S:H  US:H  -  '   X* R                  5       -  U R                  R                  5       -   $ )N)Úmemory_formatr   rO   )	r   Ú_validate_sampler   r   Úcloner   Úcontiguous_formatrZ   rY   )r&   r)   r   s      r-   Úlog_probÚGeometric.log_prob„   sv   € Ø××Ø×!Ñ! %Ô(Ü$ U¯J©JÓ7‰ˆØ—‘¬%×*AÑ*A�ÐBˆØ-.ˆ˜‰z˜e q™jÑ)Ñ*Ø˜—~‘~Ó'Ñ'¨$¯*©*¯.©.Ó*:Ñ:Ð:r/   c                 óZ   • [        U R                  U R                  SS9U R                  -  $ )NÚnone)Ú	reduction)r
   r   r   r:   s    r-   ÚentropyÚGeometric.entropyŒ   s(   € ä,¨T¯[©[¸$¿*¹*ÐPVÑWØ�j‰jñð	
r/   )r   r   )NNNr>   )r"   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úunit_intervalÚrealÚarg_constraintsÚnonnegative_integerÚsupportr   r   Úboolr   r3   Úpropertyr;   r@   rC   r   r   r   r   r   r^   re   rj   Ú__static_attributes__Ú__classcell__)r,   s   @r-   r   r      s(  ø† ñð4 !,× 9Ñ 9À[×EUÑEUÑV€OØ×-Ñ-€Gð )-Ø)-Ø%)ñ	%à˜‰ Ñ%ð%ð ˜‘ $Ñ&ð%ð ˜d‘{ð	%ð
 
÷%ð %÷N	ð ð&�fó &ó ð&ð ð,�fó ,ó ð,ð ð5˜&ó 5ó ð5ð ð;˜ó ;ó ð;ð ð<�vó <ó ð<ð #(§*¢*£,ô 
=ò;÷
ð 
r/   )r   r   Útorch.distributionsr   Ú torch.distributions.distributionr   Útorch.distributions.utilsr   r   r   r	   Útorch.nn.functionalr
   Útorch.typesr   r   Ú__all__r   © r/   r-   Ú<module>r€      s=   ðó Ý Ý +Ý 9÷ó õ Aß 'ð ˆ-€ô|
�õ |
r/   