ó
    Eñi¼  ã                   óŽ   • S SK JrJr  S SKrS SKJr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
9r " S S\	\\   5      rg)é    )ÚGenericÚTypeVarN)ÚSizeÚTensor)Úconstraints)ÚDistribution)Ú_sum_rightmost)Ú_sizeÚIndependentÚD)Úboundc            	       ó´  ^ • \ rS rSr% Sr0 r\\\R                  4   \
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\R&                  S 5       r\S	\4S j5       r\S	\4S j5       r\S	\4S j5       r\R4                  " 5       4S	\4S jjr\R4                  " 5       4S\S	\4S jjrS rS rSS jr S r!Sr"U =r#$ )r   é   aI  
Reinterprets some of the batch dims of a distribution as event dims.

This is mainly useful for changing the shape of the result of
:meth:`log_prob`. For example to create a diagonal Normal distribution with
the same shape as a Multivariate Normal distribution (so they are
interchangeable), you can::

    >>> from torch.distributions.multivariate_normal import MultivariateNormal
    >>> from torch.distributions.normal import Normal
    >>> loc = torch.zeros(3)
    >>> scale = torch.ones(3)
    >>> mvn = MultivariateNormal(loc, scale_tril=torch.diag(scale))
    >>> [mvn.batch_shape, mvn.event_shape]
    [torch.Size([]), torch.Size([3])]
    >>> normal = Normal(loc, scale)
    >>> [normal.batch_shape, normal.event_shape]
    [torch.Size([3]), torch.Size([])]
    >>> diagn = Independent(normal, 1)
    >>> [diagn.batch_shape, diagn.event_shape]
    [torch.Size([]), torch.Size([3])]

Args:
    base_distribution (torch.distributions.distribution.Distribution): a
        base distribution
    reinterpreted_batch_ndims (int): the number of batch dims to
        reinterpret as event dims
Úarg_constraintsÚ	base_distNÚbase_distributionÚreinterpreted_batch_ndimsÚvalidate_argsÚreturnc                 óZ  >• U[        UR                  5      :”  a$  [        SU S[        UR                  5       35      eUR                  UR                  -   nU[        UR                  5      -   nUS [        U5      U-
   nU[        U5      U-
  S  nXl        X l        [        TU ]  XgUS9  g )NzQExpected reinterpreted_batch_ndims <= len(base_distribution.batch_shape), actual z vs ©r   )ÚlenÚbatch_shapeÚ
ValueErrorÚevent_shaper   r   ÚsuperÚ__init__)	Úselfr   r   r   ÚshapeÚ	event_dimr   r   Ú	__class__s	           €Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributions/independent.pyr   ÚIndependent.__init__3   sÂ   ø€ ð %¤sÐ+<×+HÑ+HÓ'IÓIÜðØ3Ð4°D¼Ð=N×=ZÑ=ZÓ9[Ð8\ð^óð ð (×3Ñ3Ð6G×6SÑ6SÑSˆØ2´SÐ9J×9VÑ9VÓ5WÑWˆ	ØÐ4œc %›j¨9Ñ4Ð5ˆØœC ›J¨Ñ2Ð4Ð5ˆØ*ŒØ)BÔ&ä‰Ñ˜ÀÐÒOó    c                 óN  >• U R                  [        U5      n[        R                  " U5      nU R                  R                  XR                  S U R                   -   5      Ul        U R                  Ul        [        [        U]'  XR                  SS9  U R                  Ul
        U$ )NFr   )Ú_get_checked_instancer   Útorchr   r   Úexpandr   r   r   r   Ú_validate_args)r   r   Ú	_instanceÚnewr!   s       €r"   r(   ÚIndependent.expandG   s—   ø€ Ø×(Ñ(¬°iÓ@ˆÜ—j’j Ó-ˆØŸ™×-Ñ-Ø×*Ñ*Ð+K¨T×-KÑ-KÐLÑLó
ˆŒð )-×(FÑ(FˆÔ%ÜŒk˜3Ñ(Ø×)Ñ)¸ð 	)ñ 	
ð "×0Ñ0ˆÔØˆ
r$   c                 ó.   • U R                   R                  $ ©N)r   Úhas_rsample©r   s    r"   r/   ÚIndependent.has_rsampleT   s   € à�~‰~×)Ñ)Ð)r$   c                 óP   • U R                   S:”  a  gU R                  R                  $ )Nr   F)r   r   Úhas_enumerate_supportr0   s    r"   r3   Ú!Independent.has_enumerate_supportX   s#   € à×)Ñ)¨AÓ-ØØ�~‰~×3Ñ3Ð3r$   c                 ó”   • U R                   R                  nU R                  (       a   [        R                  " XR                  5      nU$ r.   )r   Úsupportr   r   Úindependent)r   Úresults     r"   r6   ÚIndependent.support^   s7   € ð —‘×'Ñ'ˆØ×)×)Ü ×,Ò,¨V×5SÑ5SÓTˆFØˆr$   c                 ó.   • U R                   R                  $ r.   )r   Úmeanr0   s    r"   r;   ÚIndependent.meanf   ó   € à�~‰~×"Ñ"Ð"r$   c                 ó.   • U R                   R                  $ r.   )r   Úmoder0   s    r"   r?   ÚIndependent.modej   r=   r$   c                 ó.   • U R                   R                  $ r.   )r   Úvariancer0   s    r"   rB   ÚIndependent.variancen   s   € à�~‰~×&Ñ&Ð&r$   c                 ó8   • U R                   R                  U5      $ r.   )r   Úsample©r   Úsample_shapes     r"   rE   ÚIndependent.sampler   s   € Ø�~‰~×$Ñ$ \Ó2Ð2r$   rG   c                 ó8   • U R                   R                  U5      $ r.   )r   ÚrsamplerF   s     r"   rJ   ÚIndependent.rsampleu   s   € Ø�~‰~×%Ñ% lÓ3Ð3r$   c                 ób   • U R                   R                  U5      n[        X R                  5      $ r.   )r   Úlog_probr	   r   )r   ÚvaluerM   s      r"   rM   ÚIndependent.log_probx   s'   € Ø—>‘>×*Ñ*¨5Ó1ˆÜ˜h×(FÑ(FÓGÐGr$   c                 ó`   • U R                   R                  5       n[        XR                  5      $ r.   )r   Úentropyr	   r   )r   rQ   s     r"   rQ   ÚIndependent.entropy|   s%   € Ø—.‘.×(Ñ(Ó*ˆÜ˜g×'EÑ'EÓFÐFr$   c                 ój   • U R                   S:”  a  [        S5      eU R                  R                  US9$ )Nr   z5Enumeration over cartesian product is not implemented)r(   )r   ÚNotImplementedErrorr   Úenumerate_support)r   r(   s     r"   rU   ÚIndependent.enumerate_support€   s:   € Ø×)Ñ)¨AÓ-Ü%ØGóð ð �~‰~×/Ñ/°vÐ/Ð>Ð>r$   c                 ój   • U R                   R                  SU R                   SU R                   S3-   $ )NÚ(z, Ú))r!   Ú__name__r   r   r0   s    r"   Ú__repr__ÚIndependent.__repr__‡   s8   € à�N‰N×#Ñ#Ø�$—.‘.Ð!  D×$BÑ$BÐ#CÀ1ÐEñFð	
r$   )r   r   r.   )T)$rZ   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚdictÚstrr   Ú
ConstraintÚ__annotations__r   ÚintÚboolr   r(   Úpropertyr/   r3   Údependent_propertyr6   r   r;   r?   rB   r'   r   rE   r
   rJ   rM   rQ   rU   r[   Ú__static_attributes__Ú__classcell__)r!   s   @r"   r   r      s^  ø‡ ñð: :<€O�T˜#˜{×5Ñ5Ð5Ñ6Ó;ØƒLð &*ñ	PàðPð $'ðPð ˜d‘{ð	Pð
 
÷Pð P÷(ð ð*˜Tó *ó ð*ð ð4 tó 4ó ð4ð
 ×#Ñ#ñó $ðð ð#�fó #ó ð#ð ð#�fó #ó ð#ð ð'˜&ó 'ó ð'ð #(§*¢*£,ñ 3°6õ 3ð -2¯JªJ«Lñ 4 Eð 4¸Võ 4òHòGô?÷
ð 
r$   )Útypingr   r   r'   r   r   Útorch.distributionsr   Ú torch.distributions.distributionr   Útorch.distributions.utilsr	   Útorch.typesr
   Ú__all__r   r   © r$   r"   Ú<module>rr      sE   ðç #ã ß Ý +Ý 9Ý 4Ý ð ˆ/€ñ ˆC�|Ñ$€ôy
�, ¨¡
õ y
r$   