+
    &j_J                       ^ RI Ht ^ RIHtHt ^ RIHtHt ^ RIt^RI	H
t
Ht ^RIHt ]'       d   ^RIHt R R	 lt] ! R
 R4      4       tR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR# )    )annotations)	dataclassfield)AnyTYPE_CHECKINGN)_match_levelsDimEntry)
TensorInfoDimc               $    V ^8  d   QhRRRRRR/# )   lstlistitemr   returnz
int | None )formats   "q/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/functorch/dim/_getsetitem.py__annotate__r      s!      T       c                    \        V 4       FF  w  r#\        V\        4      '       d#   \        V\        4      '       d   W18X  d   Vu # K=  W1J g   KD  Vu # 	  R# )z
Helper function to find index of item in list.

For DimEntry objects, uses __eq__ comparison which properly handles
both positional and Dim entries.

Returns the index if found, None if not found.
N)	enumerate
isinstancer	   )r   r   i	list_items   &&  r   _safe_indexr      sM     "#dH%%*Y*I*I  !H ' r   c                      ] tR t^#t$ RtR]R&   RtR]R&   RtR]R&   ]! ]	R7      t
R	]R
&   ]! ]	R7      tR]R&   RtR]R&   RtR# )IndexingInfoFboolcan_call_originaladvanced_indexingNztorch.Tensor | Noneself_tensor)default_factoryz	list[Any]flat_inputslist[DimEntry]result_levels
has_devicer   )__name__
__module____qualname____firstlineno__r!   __annotations__r"   r#   r   r   r%   r'   r(   __static_attributes__r   r   r   r   r   #   sK    #t##t#'+K$+"48K8$)$$?M>?Jr   r   c                    V ^8  d   QhRRRR/# )r   objr   r   r    r   )r   s   "r   r   r   -   s     	; 	;# 	;$ 	;r   c                h    ^RI HpHp VP                  ! V 4      ;'       g    VP                  V 4      # )z
Check if an object has first-class dimensions.

This function checks if the object is either a Dim or a functorch Tensor
that has first-class dimensions, using the proper check_exact methods.
)r   Tensor) r   r2   check_exact)r0   r   r2   s   &  r   has_dimsr5   -   s)     ??3::6#5#5c#::r   c               0    V ^8  d   QhRRRRRRRRRRRR	/# )
r   szintsddimsr   nsznsdr   Noner   )r   s   "r   r   r   9   s6     1# 1#3 1#C 1#t 1#$ 1#T 1#d 1#r   c           	        ^RI Hp ^p\        V4       F  w  rxVP                  '       g   \	        V^,           \        V4      4       FJ  p	W),          P                  '       g   V! RV: RW),          : 24      hWbV	,          P                  ,          pKL  	  W,          ^ 8w  d;   \        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p
V! RV  RV
 24      hW,          pWn        T p MWhP                  ,          pK  	  W`8w  d   \        V4      p
V! RV  RV R	V
 24      h^ .\        V4      ,          pTp\        \	        \        V4      4      4       F   pWV&   WV,          P                  ,          pK"  	  \	        \        V4      4       F;  pVP                  W',          P                  4       VP                  W,          4       K=  	  R
# )zE
Bind dimensions to size and calculate proper strides for dim packs.
DimensionBindErrorz1cannot infer the sizes of two dimensions at once  and c              3  `   "   T F$  qP                   '       d   VP                  MR x  K&  	  R# 5i)?N)is_boundsize).0dims   & r   	<genexpr>%_bind_dims_to_size.<locals>.<genexpr>L   s     N#CHH#=s   ,.z>inferred dimension does not evenly fit into larger dimension: z vs z!Dimension sizes to do not match (z != z) when matching dimension pack N)
r3   r@   r   rD   rangelenrE   tuplereversedappend)r7   r9   r:   r;   r<   r@   rhs_prodr   rG   jtupinferred_sizenew_stridescurrent_strides   &&&&&         r   _bind_dims_to_sizerU   9   s    %HD/|||1q5#d),w''',KC7RWX\X_Wbc  GLL( - }!eNNeeNNN(TUWTXX\]`\ab  NM$HH H- "2 ~Dk /t4zA`ad`ef
 	
 #D	/KNeCI&''Aq',,& (
 3t9

47<< 

;>" r   c                    V ^8  d   QhRRRR/# )r   r%   r   r   rL   r   )r   s   "r   r   r   m   s        r   c                    \        V 4      # N)rL   )r%   s   &r   slice_to_tuplerY   m   s    r   c               $    V ^8  d   QhRRRRRR/# )r   indexr   indicesr   r   r    r   )r   s   "r   r   r   q   s!     % %# % % %r   c                   \        V \        4      '       d   VP                  V 4       R # \        V \        P                  4      '       d   VP                  V 4       R# \        V R4      '       d   \        V \        \        34      '       d   VP                  V 4       R# \        V \        4      '       d   \        V 4      ^ 8  d   VP                  V 4       R # V  Fj  p\        V\        P                  \        34      '       g0   \        VR4      '       g   VRJ g   Ve   \        V4      '       g   KX  VP                  V 4        R # 	  VP                  V 4       R# VP                  V 4       R# )TF__iter__.)r   rL   extendtorchr2   rN   hasattrstrbytesr   rK   slicer5   )r[   r\   r   s   && r   extractIndicesre   q   s   %u	E5<<	(	(uUJ'':U|, , 	u %u:NN5! D4%,,!6774,,3;<D>>u%  	u NN5r   c               0    V ^8  d   QhRRRRRRRRRRRR/# )r   clsr   functypesargskwargsr   r   )r   s   "r   r   r      s6     	! 	! 	!C 	! 	!3 	! 	! 	!r   c                    V^ ,          pV^,          p\        WV\        V4      4      pVP                  '       d    \        P                  P                  WV4      # \        V4      # )r   )
getsetitemr5   r!   r`   r2   __getitem__invoke_getitem)rg   rh   ri   rj   rk   selfr[   iinfos   &&&&&   r   getitemrr      sP    7DGEtHTN3E||''44%  r   c               (    V ^8  d   QhRRRRRRRR/# )r   rp   r   r[   rhsr   r=   r   )r   s   "r   r   r      s(     >- >-# >-c >- >- >-r   c           	     2   ^RI HpHp \        Y\	        V 4      ;'       g    \	        V4      4      pVP
                  '       d-   \        P                  P                  P                  WV4       R# VP                  ! VRR4      pV'       Ed`   VP                   EF	  pVP                  4       '       d   K  RpVP                   FA  p	V	P                  4       '       d   K  V	P                  4       VP                  4       J g   K?  Rp M	  V'       d   Ky  . p
VP                   FY  pVP                  4       '       d"   V
P                  VP!                  4       4       K:  V
P                  VP                  4       4       K[  	  V! RVP                  4       : R\#        V
4      : R24      h	  VP$                  f   \'        R4      h\)        VP$                  VP                  VP                  4      pMTpVP*                  '       de   \-        VP.                  4      pVP0                  f   \3        R	4      h\        P                  P                  P                  VP0                  W4       R# VP0                  f   \3        R
4      hVP0                  P5                  V4       R# )z2Set values in tensor using first-class dimensions.)r@   r
   NFTz"rhs of setitem contains dimension z, which is not in the dimension on the left ()z"Cannot match levels on None tensorzCannot setitem on None tensorzCannot copy to None tensor)r3   r@   r
   rm   r5   r!   r`   _C
TensorBase__setitem__createlevelsis_positionalr'   rG   rN   positionrL   tensorAssertionErrorr   r"   rY   r%   r#   RuntimeErrorcopy_)rp   r[   rt   r@   r
   rq   rhs_infolfoundresult_levelresult_dimsrlmatched_rhsrQ   s   &&&           r   setitemr      s   0tHTN$C$ChsmDE''S9   eU3HxA??$$$)$7$7L(6688(,,.!%%'9 $ %8 u35K#11++--'..r{{}='..rvvx8	 2 -<QUUWK H!+.14 + !6 ??" !EFF#OOX__e.A.A
  U../$>??''(9(93L $;<<,r   c                    V ^8  d   QhRRRR/# )r   rq   r   r   r   r   )r   s   "r   r   r      s     R R, R3 Rr   c                &   V P                   '       d:   V P                  p\        V P                  4      pVf   \	        R4      hW,          pMV P                  pVf   \	        R4      h^RIHp VP                  W0P                  V P                  4      # )NzCannot getitem on None tensor)r2   )
r"   r#   rY   r%   r   r3   r2   from_positionalr'   r(   )rq   r#   rQ   rtensorr2   s   &    r   ro   ro      s    ''U../>??"##?>?? !!'+>+>@P@PQQr   c               (    V ^8  d   QhRRRRRRRR/# )r   rp   r   r[   tensors_have_dimsr    r   r   r   )r   s   "r   r   r      s4     oP oPS oP oP oP, oPr   c                  a ^RI Hp V'       * p. p\        V4      '       d   VP                  V4       M'\	        W4      pV'       d   V'       g   \        RR7      # ^ pRoRp. p	R V3R llp
R R lpR	p\        V4       F  w  r\        V4      '       d   R	pV^,          pK#  VR
J d   V
! V4       K3  \        W4      '       dO   R	pVP                  '       g   V
! V4       TpMV\        VP                  4      ,          pV	P                  V4       K  Vf   RpK  V! V4      '       d   R	pRpV^,          pK  V^,          pK  	  V'       d   \        RR7      # \        P                  ! V R	R4      p\        VP                  4      pVV8  d   \        RV RV R24      hVV,
          pSR8w  dG   Ve   VP                  V4       M0\!        R4      .V,          pVRS V,           VS^,           R ,           p\#        \        V	4      ^,
          RR4       FV  pW,          pVf   SR8w  d   VS8  d
   VV,          pVV,          pVRV VP                  ,           VV^,           R ,           pKX  	  \%        W. . V4      # )   )DimListT)r!   Nc                    V ^8  d   QhRRRR/# r   r   r8   r   r=   r   )r   s   "r   r    getsetitem.<locals>.__annotate__  s     	 	3 	4 	r   c                B   < SR8w  d   ^RI Hp V! RS RV  24      hV oR# )r   r?   z\at most one ... or unbound dimension list can exist in indexing list but found 2 at offsets rA   N)r3   r@   )r   r@   expanding_objects   & r   check_expanding#getsetitem.<locals>.check_expanding  s7    r!,$n#$E!.  r   c                    V ^8  d   QhRRRR/# )r   sr   r   r    r   )r   s   "r   r   r     s     
 
c 
d 
r   c                   a ^RI Ho \        V \        \        34      ;'       dQ    \        V 4      ^ 8  ;'       d;    \        ;QJ d    V3R lV  4       F  '       d   K   R# 	  R# ! V3R lV  4       4      # )r   r   c              3  H   <"   T F  pSP                   ! V4      x  K  	  R # 5irX   r4   )rF   r   r   s   & r   rH   1getsetitem.<locals>.is_dimpack.<locals>.<genexpr>  s     8adCOOD))a   "FT)r3   r   r   rL   r   rK   all)r   r   s   &@r   
is_dimpackgetsetitem.<locals>.is_dimpack  sj     q5$-( 9 9A
9 98a8	
 	
 8a88	
r   F.z	at least z/ indices were supplied but the tensor only has z dimensionsr   )r3   r   r5   rN   re   r   r   r   rD   rK   _dimsr
   rz   r{   
ValueErrorbind_lenrd   rJ   getsetitem_flat)rp   r[   r   r   can_call_original_getitem
input_listis_sequencedims_indexedunbound_dim_listdimlistsr   r   has_dimpacks_or_noner   r   	self_info
total_dimsexpanding_dims	no_slicesidxdlr   s   &&&                  @r   rm   rm      s{   $5 5J% $U7$[$77 LH	 	
 !*%A;;(-%AL#XA##(-%:::"#$ AGG,OOAY#' ]](-%#' ALAL+ &0 !d33!!$t4IY%%&Jj ~%TU_T``kl
 	

  ,.N2'%%n5 t6I,,--1345  3x=1$b"-k $ B&&&>!C_  %0:cAgi3HH
! .$ 9"b:NOOr   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   r   r
   r   r   keysr&   valuesr   r    r   r   r   )r   s   "r   r   r   k  sL     I III I 	I
 I Ir   c                	  aaaaaaaaaaaaaa a!a"a#a$ ^RI Ho . o . o!R V V!3R llo. o. o#RoR VV#3R lloR VVV#3R llo. o. oV P                  f   \        R	4      hV P                  P	                  4       o"V P                  P                  4       oR
 VVVVV"3R lloVR,          oR VVVV3R llpR VVVVVVVVVV"3
R llp\        V P                  4       F  w  rx\        W(4      p	V	e   V! WsV	,          4       K%  VP                  4       '       dG   V! 4        S'       g   S! \        R4      4       S! V4       Ke  S^ ,          p
SR,          oV! Wz4       K  S! VP                  4       4       S! VP                  4       4       S! V4       K  	  V! 4        S'       dX   S'       dP   V P                  f   \        R4      hV P                  P                  SSV P                  P                  4       4      pMV P                  p. o. pRo$RpR VV$3R llp\        S4       EFi  w  rS#V,          e?   RpV! 4        S#V,          P                   F  pW9  g   K  VP                  V4       K  	  KO  SP                  ! V4      '       d   Tp\        S V4      pVf   \!        RV R24      hS!V,          ^8X  d+   \        R4      SV&   SP                  \#        V4      4       K  RpRSV&   \%        VP'                  4       \#        V4      .RR4      S#V&   \#        V4      V9  d   VP                  \#        V4      4       V! 4        EK$  V\        R4      8w  d   Rp\)        V\*        4      '       d   EKO  SP                  \#        R4      4       EKl  	  S$R8w  d%   \-        V4       F  pSP/                  S$V4       K  	  V'       d   \1        \3        S4      4       F  pS#V,          f   K  S#V,          P                  pVf   \!        R4      hS#V,          P4                  '       g    Se   VP7                  SP8                  4      p\;        VS#V,          P                  V4      SV&   K  	  ^ p\-        \1        \3        S4      4      4       F:  pSV,          P                  4       '       g   K"  V^,          p\#        V) 4      SV&   K<  	  \=        RVVSSV P4                  R7      # )r   r   c                    V ^8  d   QhRRRR/# )r   rG   r   r   r=   r   )r   s   "r   r   %getsetitem_flat.<locals>.__annotate__x  s     & &S &T &r   c                   < \        SV 4      pVe   SV;;,          ^,          uu&   R # SP                  V 4       SP                  ^4       R # rX   )r   rN   )rG   r   	seen_dimsseen_dims_nusess   & r   add_dim getsetitem_flat.<locals>.add_dimx  s@    )S)?C A% S!""1%r   Nc                    V ^8  d   QhRRRR/# )r   handler   r   r=   r   )r   s   "r   r   r     s     # #3 #4 #r   c                L   < SP                  V 4       SP                  R 4       R # rX   rN   )r   r%   tensor_inputss   &r   append_flat_handle+getsetitem_flat.<locals>.append_flat_handle  s    6"T"r   c                    V ^8  d   QhRRRR/# )r   tir
   r   r=   r   )r   s   "r   r   r     s     . .
 .t .r   c                   < SP                  R 4       SP                  V 4       V P                  '       d   Sf   V P                  oR # R # R # rX   )rN   r(   r~   )r   device_holding_tensorr%   r   s   &r   append_tensor_input,getsetitem_flat.<locals>.append_tensor_input  s?    4 R ===2:$&II! ;=r   z%Cannot get size/stride on None tensorc                    V ^8  d   QhRRRR/# r   r   )r   s   "r   r   r     s      s t r   c                |   < S'       d3   SP                  SV ,          4       SP                  SV ,          4       R # R # rX   r   )r   r   r<   r;   r9   r7   s   &r   append_size$getsetitem_flat.<locals>.append_size  s+    JJr!uJJr!u  r   :NNNc                   V ^8  d   QhRR/# r   r   r=   r   )r   s   "r   r   r     s     $ $ $r   c                    < S'       dL   S^ ,          f?   S ! \        R4      4       SP                  ^4       SP                  ^ 4       SR,          oKQ  R# R# )r   Nr   NN)rd   rN   )r   input_itr<   r;   s   r   parse_nones$getsetitem_flat.<locals>.parse_nones  sA    8A;.uT{+JJqMJJqM|H	 /hr   c               $    V ^8  d   QhRRRRRR/# )r   r   r8   argr   r   r=   r   )r   s   "r   r   r     s!        s      r   c                  <
 SP                   ! V4      '       d<   TpVP                  R8X  d   SV ,          Vn        S! V4       S	! V 4       S! V4       R# \        P                  ! VRR4      pV'       dT   S	! V 4       S
! V4       VP
                   F1  pVP                  4       '       d   K  S! VP                  4       4       K3  	  R# S'       d   \        V\        \        34      '       d   \        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       dD   \        V4      pV F  pS! V4       S! V4       K  	  \        SV ,          SV ,          VSS4       R# S	! V 4       S! V4       R# )r   NFc              3  H   <"   T F  pSP                   ! V4      x  K  	  R # 5irX   r   )rF   dr   s   & r   rH   7getsetitem_flat.<locals>.append_item.<locals>.<genexpr>  s     5VRUQcooa6H6HRUr   Tr   )r4   _sizerE   r
   rz   r{   r|   rG   r   rL   r   r   rU   )r   r   r   infoleveldim_packr   r   r   r   r   r   r<   r;   r9   r7   s   &&    r   append_item$getsetitem_flat.<locals>.append_item  s    ??3Aww"}AAJNs#  eU3N%**,,EIIK( % #t}--##5VRU5V###5VRU5V2V2V9!AAJ&q) " #2a5"Q%3DA3r   r   zCannot restride None tensorFc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     $ $t $r   c                 X   < SR8X  d   \        S 4      oR# S\        S 4      8w  d   ^ oR# R# )r   Nr   )rK   )r'   tensor_insert_points   r   mark_tensor_index*getsetitem_flat.<locals>.mark_tensor_index  s.    "$"%m"4 C$66"# 7r   TzDim z not found in seen_dimsz(TensorInfo should have valid tensor data)r!   r"   r#   r%   r'   r(   r   )r3   r   r~   r   rE   strider   r{   r   r|   rd   rG   
as_stridedstorage_offsetrN   r4   r   r	   r
   
_get_ranger   r8   rM   insertrJ   rK   r(   todevicer   r   )%r   r   r   r   r   r   r   r   r   r   r   r#   index_levelsrequires_getindexr   inpr   dim_idxtseen_positionalsr   r   r   r   r   r   r%   r   r<   r;   r'   r9   r   r   r7   r   r   s%   &&&&f               @@@@@@@@@@@@@@@@@r   r   r   k  sU     I!#O& & K!M # #. . C
CBCC						 B				 	 	"B 
 !}H$ $     B i../$&?#;'""$$&uT{3N"1+C'|H'		$"599;/A% 0( M #<==&&11i&&557
  &&  "ML$ $ K(' $&q)00, ''. 1 __S!!A!)Q/G$tA3.E%FGGw'1,!&tA$$Xa[1$(!!%A#-LLNXa[M5$$a  A;l2 ''4!#eDk!$(!c3''$$Xb\2; )@ b l+E  !4e< , s;'(AQ+!!$++9()STT%a(333-9299:A!.q-2B2I2I<!XA ) eC./0))++!')9(9:M! 1
 +#'' r   )
__future__r   dataclassesr   r   typingr   r   r`   
_dim_entryr   r	   _tensor_infor
   r3   r   r   r   r5   rU   rY   re   rr   r   ro   rm   r   r   r   r   <module>r      sr    " ( %  / $ &   	;1#h%P	!>-BR&oPdIr   