+
    &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   "w/Users/jameslopez/projects/CWCArchive/cwc-podcast/.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    TMv~.M  yy{Q !VWW2t!<<DJ~$%BCCzz|a !WXX !#3#3D#3#IIDK$)$5djj4;;;;++-b1'+{{'='='?!'CDKK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@jj-!EJJ0@0@/B$CCdmm#

))+6CICJt}}$++K8CJCJ**k3(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"     ++At/?/?!/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    tzz**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     " "UZZ "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   <    zz  "**""::$$	
 	
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    zz  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3L::%%b$*:*:;&&x1C1C1Et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;;CUCUVUTC0A0A,B%BBC]]54+<+<#<=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 3X{?V?VWO 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   