+
    –°³j…  ã                   óf   € ^ RI t ^ RI HtHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
 R.t ! R R]4      tR# )é    N)ÚnanÚTensor)Úconstraints)ÚDistribution)Úlazy_propertyÚlogits_to_probsÚprobs_to_logitsÚCategoricalc                   ó°  a a€ ] tR t^t oRtR]P                  R]P                  /tRt	RV3R lV 3R lllt
RV 3R lltR t]P                  ! R^ R	7      R
 4       t]V3R lR l4       t]V3R lR l4       t]V3R lR l4       t]V3R lR l4       t]V3R lR l4       t]V3R lR l4       t]P0                  ! 4       3R ltR tR tRR ltRtVtV ;t# )r
   ax  
Creates a categorical distribution parameterized by either :attr:`probs` or
:attr:`logits` (but not both).

.. note::
    It is equivalent to the distribution that :func:`torch.multinomial`
    samples from.

Samples are integers from :math:`\{0, \ldots, K-1\}` where `K` is ``probs.size(-1)``.

If `probs` is 1-dimensional with length-`K`, each element is the relative probability
of sampling the class at that index.

If `probs` is N-dimensional, the first N-1 dimensions are treated as a batch of
relative probability vectors.

.. note:: The `probs` argument must be non-negative, finite and have a non-zero sum,
          and it will be normalized to sum to 1 along the last dimension. :attr:`probs`
          will return this normalized value.
          The `logits` argument will be interpreted as unnormalized log probabilities
          and can therefore be any real number. It will likewise be normalized so that
          the resulting probabilities sum to 1 along the last dimension. :attr:`logits`
          will return this normalized value.

See also: :func:`torch.multinomial`

Example::

    >>> # xdoctest: +IGNORE_WANT("non-deterministic")
    >>> m = Categorical(torch.tensor([ 0.25, 0.25, 0.25, 0.25 ]))
    >>> m.sample()  # equal probability of 0, 1, 2, 3
    tensor(3)

Args:
    probs (Tensor): event probabilities
    logits (Tensor): event log probabilities (unnormalized)
ÚprobsÚlogitsTc                óZ   <€ V ^8„  d   QhRS[ R,          RS[ R,          RS[R,          RR/# )é   r   Nr   Úvalidate_argsÚreturn)r   Úbool)ÚformatÚ__classdict__s   "€Ú`/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributions/categorical.pyÚ__annotate__ÚCategorical.__annotate__8   sE   ø€ ÷ Cñ Cá˜�}ðCñ ˜•ðCñ ˜d•{ð	Cð
 
ñCó    c                ó¤  <€ VR J VR J 8X  d   \        R4      hVe@   VP                  4       ^8  d   \        R4      hWP                  R	RR7      ,          V n        MMVf   \	        R4      hVP                  4       ^8  d   \        R4      hW"P                  R	RR7      ,
          V n        Ve   V P                  MV P                  V n        V P                  P                  4       R	,          V n	        V P                  P                  4       ^8”  d   V P                  P                  4       R R	 M\        P                  ! 4       p\        SV `9  WCR7       R # )
Nz;Either `probs` or `logits` must be specified, but not both.z3`probs` parameter must be at least one-dimensional.T)Úkeepdimzlogits is unexpectedly Nonez4`logits` parameter must be at least one-dimensional.)Údimr   ©r   éÿÿÿÿ)Ú
ValueErrorr   Úsumr   ÚAssertionErrorÚ	logsumexpr   Ú_paramÚsizeÚ_num_eventsÚ
ndimensionÚtorchÚSizeÚsuperÚ__init__)Úselfr   r   r   Úbatch_shapeÚ	__class__s   &&&& €r   r)   ÚCategorical.__init__8   s  ø€ ð �TˆM˜v¨˜~Ô.ÜØMóð ð ÒØ�y‰y‹{˜QŒÜ Ð!VÓWÐWà§¡¨2°t Ó!<Õ<ˆD�JàŠ~Ü$Ð%BÓCÐCØ�z‰z‹|˜aÔÜ Ð!WÓXÐXð !×#3Ñ#3¸ÀDÐ#3Ó#IÕIˆDŒKØ$)Ò$5�d—j’j¸4¿;¹;ˆŒØŸ;™;×+Ñ+Ó-¨bÕ1ˆÔà'+§{¡{×'=Ñ'=Ó'?À!Ô'CˆD�K‰K×ÑÓ˜s Ñ#ÌÏÊËð 	ô 	‰Ñ˜ÐÖBr   c                ó&  <€ V P                  \        V4      p\        P                  ! V4      pV\        P                  ! V P                  34      ,           pR V P
                  9   d2   V P                  P                  V4      Vn        VP                  Vn        RV P
                  9   d2   V P                  P                  V4      Vn	        VP                  Vn        V P                  Vn        \        \        V`/  VRR7       V P                  Vn        V# )r   r   Fr   )Ú_get_checked_instancer
   r&   r'   r$   Ú__dict__r   Úexpandr"   r   r(   r)   Ú_validate_args)r*   r+   Ú	_instanceÚnewÚparam_shaper,   s   &&&  €r   r1   ÚCategorical.expandW   sÍ   ø€ Ø×(Ñ(¬°iÓ@ˆÜ—j’j Ó-ˆØ!¤E§J¢J°×0@Ñ0@Ð/BÓ$CÕCˆØ�d—m‘mÔ#ØŸ
™
×)Ñ)¨+Ó6ˆCŒIØŸ™ˆCŒJØ�t—}‘}Ô$ØŸ™×+Ñ+¨KÓ8ˆCŒJØŸ™ˆCŒJØ×*Ñ*ˆŒÜŒk˜3Ñ(¨ÀEÐ(ÔJØ!×0Ñ0ˆÔØˆ
r   c                ó:   € V P                   P                  ! V/ VB # ©N)r"   r4   )r*   ÚargsÚkwargss   &*,r   Ú_newÚCategorical._newf   s   € Ø�{‰{�Š Ð/¨Ñ/Ð/r   )Úis_discreteÚ	event_dimc                óR   € \         P                  ! ^ V P                  ^,
          4      # )r   )r   Úinteger_intervalr$   ©r*   s   &r   ÚsupportÚCategorical.supporti   s"   € ô ×+Ò+¨A¨t×/?Ñ/?À!Õ/CÓDÐDr   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©r   )r   r   s   "€r   r   r   o   s   ø€ ÷ +ñ +™ñ +r   c                ó,   € \        V P                  4      # r8   )r	   r   rA   s   &r   r   ÚCategorical.logitsn   s   € ä˜tŸz™zÓ*Ð*r   c                ó    <€ V ^8„  d   QhRS[ /# rE   rF   )r   r   s   "€r   r   r   s   s   ø€ ÷ ,ñ ,‘vñ ,r   c                ó,   € \        V P                  4      # r8   )r   r   rA   s   &r   r   ÚCategorical.probsr   s   € ä˜tŸ{™{Ó+Ð+r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# rE   )r&   r'   )r   r   s   "€r   r   r   w   s   ø€ ÷ "ñ "™UŸZ™Zñ "r   c                ó6   € V P                   P                  4       # r8   )r"   r#   rA   s   &r   r5   ÚCategorical.param_shapev   s   € à�{‰{×ÑÓ!Ð!r   c                ó    <€ V ^8„  d   QhRS[ /# rE   rF   )r   r   s   "€r   r   r   {   s   ø€ ÷ 
ñ 
‘fñ 
r   c                óª   € \         P                  ! V P                  4       \        V P                  P
                  V P                  P                  R 7      # ©©ÚdtypeÚdevice©r&   ÚfullÚ_extended_shaper   r   rS   rT   rA   s   &r   ÚmeanÚCategorical.meanz   ó<   € ä�zŠzØ× Ñ Ó"ÜØ—*‘*×"Ñ"Ø—:‘:×$Ñ$ô	
ð 	
r   c                ó    <€ V ^8„  d   QhRS[ /# rE   rF   )r   r   s   "€r   r   r   „   s   ø€ ÷ )ñ )‘fñ )r   c                ó:   € V P                   P                  RR7      # )é   )r   r   )r   ÚargmaxrA   s   &r   ÚmodeÚCategorical.modeƒ   s   € à�z‰z× Ñ  RÐ Ó(Ð(r   c                ó    <€ V ^8„  d   QhRS[ /# rE   rF   )r   r   s   "€r   r   r   ˆ   s   ø€ ÷ 
ñ 
™&ñ 
r   c                óª   € \         P                  ! V P                  4       \        V P                  P
                  V P                  P                  R 7      # rQ   rU   rA   s   &r   ÚvarianceÚCategorical.variance‡   rZ   r   c                óX  € \        V\        P                  4      '       g   \        P                  ! V4      pV P                  P	                  RV P
                  4      p\        P                  ! W!P                  4       R4      P                  pVP	                  V P                  V4      4      # )r]   Tr   )
Ú
isinstancer&   r'   r   Úreshaper$   ÚmultinomialÚnumelÚTrW   )r*   Úsample_shapeÚprobs_2dÚ
samples_2ds   &&  r   ÚsampleÚCategorical.sample�   sz   € Ü˜,¬¯
©
×3Ò3Ü Ÿ:š: lÓ3ˆLØ—:‘:×%Ñ% b¨$×*:Ñ*:Ó;ˆÜ×&Ò& x×1CÑ1CÓ1EÀtÓL×NÑNˆ
Ø×!Ñ! $×"6Ñ"6°|Ó"DÓEÐEr   c                ó  € V P                   '       d   V P                  V4       VP                  4       P                  R4      p\        P
                  ! WP                  4      w  rVR,          pVP                  RV4      P                  R4      # )r]   r   ).:Nr]   N)	r2   Ú_validate_sampleÚlongÚ	unsqueezer&   Úbroadcast_tensorsr   ÚgatherÚsqueeze)r*   ÚvalueÚlog_pmfs   && r   Úlog_probÚCategorical.log_prob—   sm   € Ø××ÐØ×!Ñ! %Ô(Ø—
‘
“×&Ñ& rÓ*ˆÜ×0Ò0°¿¹ÓD‰ˆØ�g•ˆØ�~‰~˜b %Ó(×0Ñ0°Ó4Ð4r   c                óö   € \         P                  ! V P                  P                  4      P                  p\         P
                  ! V P                  VR 7      pW P                  ,          pVP                  R4      ) # ))Úminr   )r&   Úfinfor   rS   r|   Úclampr   r   )r*   Úmin_realr   Úp_log_ps   &   r   ÚentropyÚCategorical.entropyŸ   sQ   € Ü—;’;˜tŸ{™{×0Ñ0Ó1×5Ñ5ˆÜ—’˜TŸ[™[¨hÔ7ˆØŸ:™:Õ%ˆØ—‘˜B“ÐÐr   c                óL  € V P                   p\        P                  ! V\        P                  V P                  P
                  R 7      pVP                  RR\        V P                  4      ,          ,           4      pV'       d#   VP                  RV P                  ,           4      pV# )rR   )r   )r]   )
r$   r&   Úarangerr   r"   rT   ÚviewÚlenÚ_batch_shaper1   )r*   r1   Ú
num_eventsÚvaluess   &&  r   Úenumerate_supportÚCategorical.enumerate_support¥   sq   € Ø×%Ñ%ˆ
Ü—’˜j´·
±
À4Ç;Á;×CUÑCUÔVˆØ—‘˜U T¬C°×0AÑ0AÓ,BÕ%BÕBÓCˆßØ—]‘] 5¨4×+<Ñ+<Õ#<Ó=ˆFØˆr   )r$   r"   r   r   )NNNr8   )T) Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚsimplexÚreal_vectorÚarg_constraintsÚhas_enumerate_supportr)   r1   r;   Údependent_propertyrB   r   r   r   Úpropertyr5   rX   r_   rc   r&   r'   rn   ry   r�   rŠ   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r,   r   s   @@r   r
   r
      s  ù‡ € ñ$ðN  × 3Ñ 3°X¸{×?VÑ?VÐW€OØ Ð÷Cõ C÷>ò0ð ×#Ò#°ÀÔBñEó CðEð ÷+ó ð+ð ÷,ó ð,ð ÷"ó ð"ð ÷
ó ð
ð ÷)ó ð)ð ÷
ó ð
ð #(§*¢*£,ô Fò5ò ÷ô r   )r&   r   r   Útorch.distributionsr   Ú torch.distributions.distributionr   Útorch.distributions.utilsr   r   r	   Ú__all__r
   © r   r   Ú<module>rŸ      s0   ðó ß Ý +Ý 9ß UÑ Uð ˆ/€ô^�,ö ^r   