+
    ˜°³jÌ  ã                  óæ   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHt ]'       d   ^ RIHtHtHt  ! R R	]4      t] ! R
 R4      4       t ! R R4      t ! R R4      tR# )aŽ  
IndentedBuffer: a line-oriented buffer that tracks indentation as source is
appended and renders it (optionally with a line map for traceback remapping).

This is the shared primitive underneath inductor's codegen buffers
(torch._inductor.utils re-exports these names and subclasses IndentedBuffer for
its JIT/AOTI variants), dynamo's guard codegen (IndentedBufferWithPrefix), and
AOTAutograd's runtime-wrapper codegen (PySourceBuilder). It lives in torch.utils
so those layers can share it without importing across the _functorch -> _inductor
edge or pulling in the heavy torch._inductor.utils module. The cluster depends
only on the standard library.
)ÚannotationsN)Ú	dataclass)ÚStringIO)ÚAnyÚ
NamedTupleÚTYPE_CHECKING)ÚSelf)ÚCallableÚIteratorÚSequencec                  ó"   € ] tR t^t$ R]R&   RtR# )ÚLineContextr   Úcontext© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__Ú__static_attributes__r   ó    Ú]/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/utils/_indented_buffer.pyr   r      s   ‡ Ø‡Lr   r   c                  ó,   € ] tR t^!t$ R]R&   R]R&   RtR# )ÚValueWithLineMapÚstrÚvaluezlist[tuple[int, LineContext]]Úline_mapr   Nr   r   r   r   r   r   !   s   ‡ àƒJØ+×+r   r   c                  ón  € ] tR t^'t^tR2R R llt]P                  R R l4       tR R lt	R R lt
R	 R
 ltR 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R3R R lltR3R R lltR R ltR4R  R! lltR4R" R# lltR4R$ R% lltR3R& R' lltR( R) ltR* R+ ltR, R- ltR. R/ ltR0tR1# )5ÚIndentedBufferc               ó    € V ^8„  d   QhRRRR/# )é   Úinitial_indentÚintÚreturnÚNoner   )Úformats   "r   Ú__annotate__ÚIndentedBuffer.__annotate__*   s   € ÷ &ñ & sð &°4ñ &r   c                	ó    € . V n         Wn        R # ©N)Ú_linesÚ_indent)Úselfr"   s   &&r   Ú__init__ÚIndentedBuffer.__init__*   s   € ØBDˆŒØ%Žr   c               ó    € V ^8„  d   QhRRRR/# )r!   Útabwidthr#   r$   úIterator[None]r   )r&   s   "r   r'   r(   /   s   € ÷ !ñ ! Sð !¨^ñ !r   c              #  	ó^   "  € V P                   p Wn         R x € W n         R #   Y n         i ; i5ir*   )r1   )r-   r1   Úprevs   && r   Úset_tabwidthÚIndentedBuffer.set_tabwidth.   s%   é € à�}‰}ˆð	!Ø$ŒMÛà ŽMø˜D�Müs   ‚-�
" š-¢*ª-c               ó   € V ^8„  d   QhRR/# )r!   r$   r   r   )r&   s   "r   r'   r(   7   s   € ÷ 9ñ 9Ð%5ñ 9r   c                	ó  € \        4       p^p. pV P                   FË  p\        V\        4      '       d   V! 4       pVf   K&  M6\        V\        4      '       d   VP                  W$P                  34       K[  Tp\        V\        4      '       g   \        R\        V4       24      hVP                  V4       VP                  R4       V^VP                  R4      ,           ,          pKÍ  	  \        VP                  4       V4      # )é   úExpected str, got Ú
)r   r+   Ú
isinstanceÚDeferredLineBaser   Úappendr   r   ÚAssertionErrorÚtypeÚwriteÚcountr   Úgetvalue)r-   ÚbufÚpÚlinemapÚliÚlines   &     r   ÚgetvaluewithlinemapÚ"IndentedBuffer.getvaluewithlinemap7   sÑ   € Ü‹jˆØˆØ13ˆØ—+”+ˆBÜ˜"Ô.×/Ò/Ù“t�Ø’<Ùð  ä˜B¤×,Ò,Ø—‘ §:¡:˜Ô/Ùà�Ü˜d¤C×(Ò(Ü$Ð'9¼$¸t»*¸Ð%FÓGÐGØ�I‰I�dŒOØ�I‰I�dŒOØ��T—Z‘Z Ó%Õ%Õ%ŠAñ ô   §¡£°Ó8Ð8r   c               ó   € V ^8„  d   QhRR/# ©r!   r$   r   r   )r&   s   "r   r'   r(   L   s   € ÷ 0ñ 0˜#ñ 0r   c                	ó6   € V P                  4       P                  # r*   )rI   r   ©r-   s   &r   rC   ÚIndentedBuffer.getvalueL   s   € Ø×'Ñ'Ó)×/Ñ/Ð/r   c               ó   € V ^8„  d   QhRR/# rL   r   )r&   s   "r   r'   r(   O   s   € ÷ ñ ˜Sñ r   c                	óÐ  € \        4       pV P                   F½  p\        V\        4      '       d   V! 4       pVf   K&  M\        V\        4      '       d   K?  Tp\        V\
        4      '       g   \        R\        V4       24      hVP                  R4      '       d   VP                  VR R 4       K›  VP                  V4       VP                  R4       K¿  	  VP                  4       # )Nr:   Ú\r;   éÿÿÿÿ)r   r+   r<   r=   r   r   r?   r@   ÚendswithrA   rC   )r-   rD   rG   rH   s   &   r   ÚgetrawvalueÚIndentedBuffer.getrawvalueO   s·   € Ü‹jˆØ—+”+ˆBÜ˜"Ô.×/Ò/Ù“t�Ø’<Ùð  ä˜B¤×,Ò,Ùà�Ü˜d¤C×(Ò(Ü$Ð'9¼$¸t»*¸Ð%FÓGÐGà�}‰}˜T×"Ò"Ø—	‘	˜$˜s ˜)Ö$à—	‘	˜$”Ø—	‘	˜$–ñ! ð" �|‰|‹~Ðr   c                	ó   € V P                   # r*   ©r+   rN   s   &r   Úget_lines_refÚIndentedBuffer.get_lines_refd   s   € Ø�{‰{Ðr   c               ó   € V ^8„  d   QhRR/# ©r!   r$   r%   r   )r&   s   "r   r'   r(   g   s   € ÷ ñ �tñ r   c                	ó:   € V P                   P                  4        R # r*   )r+   ÚclearrN   s   &r   r^   ÚIndentedBuffer.clearg   s   € Ø�‰×ÑÖr   c               ó   € V ^8„  d   QhRR/# ©r!   r$   Úboolr   )r&   s   "r   r'   r(   j   s   € ÷ !ñ !˜$ñ !r   c                	ó,   € \        V P                  4      # r*   )rb   r+   rN   s   &r   Ú__bool__ÚIndentedBuffer.__bool__j   s   € Ü�D—K‘KÓ Ð r   c               ó   € V ^8„  d   QhRR/# rL   r   )r&   s   "r   r'   r(   m   s   € ÷ 4ñ 4˜ñ 4r   c                	óJ   € R V P                   V P                  ,          ,          # )Ú )r,   r1   rN   s   &r   ÚprefixÚIndentedBuffer.prefixm   s   € Ø�d—l‘l T§]¡]Õ2Õ3Ð3r   c               ó   € V ^8„  d   QhRR/# r\   r   )r&   s   "r   r'   r(   p   s   € ÷ ñ ˜ñ r   c                	ó(   € V P                  R 4       R# )r;   N©Ú	writelinerN   s   &r   ÚnewlineÚIndentedBuffer.newlinep   s   € Ø�‰�tÖr   c               ó    € V ^8„  d   QhRRRR/# ©r!   rH   z$LineContext | DeferredLineBase | strr$   r%   r   )r&   s   "r   r'   r(   s   s   € ÷ #ñ #ÐBð #Àtñ #r   c                	óÌ  € \        V\        4      '       d   V P                  P                  V4       R# \        V\        4      '       d;   V P                  P                  VP                  V P                  4       4      4       R# VP                  4       '       d0   V P                  P                  V P                  4        V 24       R# V P                  P                  R 4       R# ©Ú N)r<   r   r+   r>   r=   Úwith_prefixri   Ústrip©r-   rH   s   &&r   rn   ÚIndentedBuffer.writelines   s�   € Ü�dœK×(Ò(Ø�K‰K×Ñ˜tÖ$Ü˜Ô.×/Ò/Ø�K‰K×Ñ˜t×/Ñ/°·±³Ó>Ö?Ø�Z‰Z�\Š\Ø�K‰K×Ñ $§+¡+£- °°Ð7Ö8à�K‰K×Ñ˜rÖ"r   c               ó    € V ^8„  d   QhRRRR/# rr   r   )r&   s   "r   r'   r(   }   s   € ÷ ñ Ð"Fð È4ñ r   c                ó(   € V P                  V4       R# )zGWrite to JIT buffer only. On a plain IndentedBuffer, same as writeline.Nrm   rx   s   &&r   Úwriteline_jitÚIndentedBuffer.writeline_jit}   s   € à�‰�tÖr   c               ó    € V ^8„  d   QhRRRR/# rr   r   )r&   s   "r   r'   r(   �   s   € ÷ Jñ JÐ"Fð JÈ4ñ Jr   c                ó   € R# )z;Write to AOTI buffer only. No-op on a plain IndentedBuffer.Nr   rx   s   &&r   Úwriteline_aotÚIndentedBuffer.writeline_aot�   ó   ‚ r   c               ó$   € V ^8„  d   QhRRRRRR/# ©r!   Ú
other_codezIndentedBuffer | strrw   rb   r$   r%   r   )r&   s   "r   r'   r(   „   s#   € ÷ -ñ -Ð%9ð -À$ð -ÐSWñ -r   c                ó*   € V P                  WR7       R# )zESplice to JIT buffer only. On a plain IndentedBuffer, same as splice.)rw   N)Úsplice©r-   r…   rw   s   &&&r   Ú
splice_jitÚIndentedBuffer.splice_jit„   s   € à�‰�JˆÖ,r   c               ó$   € V ^8„  d   QhRRRRRR/# r„   r   )r&   s   "r   r'   r(   ˆ   s(   € ÷ Kñ KÐ%9ð KÀ$ð KÐSWñ Kr   c                ó   € R# )z<Splice to AOTI buffer only. No-op on a plain IndentedBuffer.Nr   rˆ   s   &&&r   Ú
splice_aotÚIndentedBuffer.splice_aotˆ   r‚   r   c               ó    € V ^8„  d   QhRRRR/# )r!   Úlinesz.Sequence[LineContext | DeferredLineBase | str]r$   r%   r   )r&   s   "r   r'   r(   ‹   s   € ÷ !ñ !Ð Nð !ÐSWñ !r   c                	ó:   € V F  pV P                  V4       K  	  R # r*   rm   )r-   r�   rH   s   && r   Ú
writelinesÚIndentedBuffer.writelines‹   s   € ÛˆDØ�N‰N˜4Ö ó r   c               ó    € V ^8„  d   QhRRRR/# )r!   Úoffsetr#   r$   z'contextlib.AbstractContextManager[None]r   )r&   s   "r   r'   r(   �   s   € ÷ 	ñ 	˜Sð 	Ð)Pñ 	r   c                	óN   a a€ \         P                  R  VV 3R ll4       pV! 4       # )c               ó   € V ^8„  d   QhRR/# )r!   r$   r2   r   )r&   s   "r   r'   Ú+IndentedBuffer.indent.<locals>.__annotate__‘   s   € ÷ 	'ñ 	'�^ñ 	'r   c               3  óº   <"  € S;P                   S ,          un          R x € S;P                   S ,          un         R #   S;P                   S ,          un         i ; i5ir*   ©r,   )r•   r-   s   €€r   ÚctxÚ"IndentedBuffer.indent.<locals>.ctx�   s8   øé € à�LŠL˜FÕ"�Lð'Ûà—’ Õ&—ø�—’ Õ&–üs   ƒAž= ¢A½AÁA)Ú
contextlibÚcontextmanager)r-   r•   r›   s   ff r   ÚindentÚIndentedBuffer.indent�   s)   ù€ Ü	×	"Ñ	"÷	'ð 	'ó 
#ð	'ñ ‹uˆr   c               ó    € V ^8„  d   QhRRRR/# ©r!   r•   r#   r$   r%   r   )r&   s   "r   r'   r(   š   s   € ÷ ñ  ð ¨Dñ r   c                	ó8   € V ;P                   V,          un         R # r*   rš   ©r-   r•   s   &&r   Ú	do_indentÚIndentedBuffer.do_indentš   ó   € Ø�Š˜Õ�r   c               ó    € V ^8„  d   QhRRRR/# r¢   r   )r&   s   "r   r'   r(   �   s   € ÷ ñ  #ð ¨dñ r   c                	ó8   € V ;P                   V,          un         R # r*   rš   r¤   s   &&r   Údo_unindentÚIndentedBuffer.do_unindent�   r§   r   c               ó$   € V ^8„  d   QhRRRRRR/# r„   r   )r&   s   "r   r'   r(       s"   € ÷ 2ñ 2Ð!5ð 2¸dð 2Ètñ 2r   c           	     	ó  € \        V\        4      '       dû   \        R 4      pVP                   FX  p\        V\        4      '       d   K  V'       g   K%  \        V\        V4      \        VP                  4       4      ,
          4      pKZ  	  \        P                  ! V4      '       d   ^ pVP                   FW  p\        V\        4      '       d   V P                  P                  V4       K6  \        P                  W\        V4      R 4       KY  	  R# \        P                  ! V4      pV'       d   VP                  4       pV'       g   R# VP                  4       pVP!                  R4       F  p\        P                  W4       K  	  R# )ÚinfNr;   )r<   r   Úfloatr+   r   ÚminÚlenÚlstripÚmathÚisinfr>   rn   r#   ÚtextwrapÚdedentÚrstripÚsplit)r-   r…   rw   r¶   rH   Úss   &&&   r   r‡   ÚIndentedBuffer.splice    s  € Ü�j¤.×1Ò1Ü˜5“\ˆFà"×)Ô)�Ü! $¬×4Ô4¿¹Ü  ¬¨T«´S¸¿¹»Ó5GÕ)GÓH’Fñ *ô �zŠz˜&×!Ò!Ø�Ø"×)Ô)�Ü˜d¤K×0Ò0Ø—K‘K×&Ñ& tÖ,ä"×,Ñ,¨T¼¸F»¸Ð3FÖGó	 *ô "Ÿš¨Ó4ˆJßØ'×.Ñ.Ó0�
ßÙØ#×*Ñ*Ó,ˆJØ×%Ñ% dÖ+�Ü×(Ñ(¨Ö1ó ,r   c               ó    € V ^8„  d   QhRRRR/# )r!   ÚfunczCallable[[Any], Any]r$   r   r   )r&   s   "r   r'   r(   ¸   s   € ÷ ñ Ð,ð °ñ r   c                	óˆ   € \        V P                  R 7      pV P                   Uu. uF
  q1! V4      NK  	  upVn        V# u upi )©r"   )r   r,   r+   )r-   r¼   ÚresrH   s   &&  r   ÚmapÚIndentedBuffer.map¸   s8   € Ü¨D¯L©LÔ9ˆØ-1¯[ª[Ó9©[ T�d˜4–j©[Ñ9ˆŒ
Øˆ
ùò :s   ¥?c               ó   € V ^8„  d   QhRR/# rL   r   )r&   s   "r   r'   r(   ½   s   € ÷ 2ñ 2˜#ñ 2r   c                	ó@   € \        V 4       R V P                  4        R2# )Ú(Ú))r@   rC   rN   s   &r   Ú__repr__ÚIndentedBuffer.__repr__½   s    € Ü�t“*�˜Q˜tŸ}™}›Ð/¨qÐ1Ð1r   c               ó    € V ^8„  d   QhRRRR/# )r!   Úotherr   r$   r   r   )r&   s   "r   r'   r(   À   s   € ÷ ñ ˜Tð  nñ r   c                	ó  € V P                   VP                   8w  d&   \        R V P                    RVP                    24      h\        V P                   R7      pVP                  V P                  4       VP                  VP                  4       V# )zIndent mismatch: z != r¾   )r,   r?   r   r’   r+   )r-   rÉ   r¿   s   && r   Ú__add__ÚIndentedBuffer.__add__À   sf   € Ø�<‰<˜5Ÿ=™=Ô(Ü Ð#4°T·\±\°NÀ$ÀuÇ}Á}ÀoÐ!VÓWÐWÜ¨D¯L©LÔ9ˆà�‰�t—{‘{Ô#Ø�‰�u—|‘|Ô$Øˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r!   Únew_linez$DeferredLineBase | LineContext | strr$   rb   r   )r&   s   "r   r'   r(   É   s   € ÷ 'ñ 'Ð!Eð 'È$ñ 'r   c                	ó   € WP                   9   # r*   rX   )r-   rÎ   s   &&r   ÚcontainsÚIndentedBuffer.containsÉ   s   € ØŸ;™;Ñ&Ð&r   )r,   r+   r1   N)é    )F)r9   ) r   r   r   r   r1   r.   r�   rž   r5   rI   rC   rU   rY   r^   rd   ri   ro   rn   r|   r€   r‰   r�   r’   rŸ   r¥   rª   r‡   rÀ   rÆ   rË   rÐ   r   r   r   r   r   r   '   s›   † Ø€H÷&ð ×Ñô!ó ð!õ9õ*0õò*õõ!õ4õõ#õõJ÷-÷Kõ!÷	÷÷÷2õ0õ
2õ÷'ñ 'r   r   c                  óz   € ] tR t^ÍtR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tR# )r=   z.A line that can be 'unwritten' at a later timec               ó   € V ^8„  d   QhRR/# )r!   rH   r   r   )r&   s   "r   r'   ÚDeferredLineBase.__annotate__Ð   s   € ÷ ñ ˜Sñ r   c                	óB   € VP                  4       '       g   R pWn        R# rt   )rw   rH   rx   s   &&r   r.   ÚDeferredLineBase.__init__Ð   s   € Ø�z‰z�|Š|ØˆDØŽ	r   c               ó   € V ^8„  d   QhRR/# )r!   r$   z
str | Noner   )r&   s   "r   r'   rÕ   Õ   s   € ÷ "ñ "˜*ñ "r   c                ó   € \         h)zJReturns either self.line or None to indicate the line has been 'unwritten'©ÚNotImplementedErrorrN   s   &r   Ú__call__ÚDeferredLineBase.__call__Õ   ó   € ä!Ð!r   c               ó    € V ^8„  d   QhRRRR/# )r!   rH   r   r$   r   r   )r&   s   "r   r'   rÕ   Ù   s   € ÷ "ñ "˜cð " dñ "r   c                ó   € \         h)z3Returns a new deferred line with the same conditionrÚ   rx   s   &&r   Ú	_new_lineÚDeferredLineBase._new_lineÙ   rÞ   r   c               ó    € V ^8„  d   QhRRRR/# )r!   ri   r   r$   r   r   )r&   s   "r   r'   rÕ   Ý   s   € ÷ 6ñ 6 #ð 6¨$ñ 6r   c                	ó@   € V P                  V V P                   24      # r*   ©rá   rH   )r-   ri   s   &&r   rv   ÚDeferredLineBase.with_prefixÝ   s   € Ø�~‰~  ¨¯©¨Ð4Ó5Ð5r   c               ó   € V ^8„  d   QhRR/# )r!   r$   r   r   )r&   s   "r   r'   rÕ   à   s   € ÷ 2ñ 2˜ñ 2r   c                	óT   € V P                  V P                  P                  4       4      # r*   )rá   rH   r²   rN   s   &r   r²   ÚDeferredLineBase.lstripà   s   € Ø�~‰~˜dŸi™i×.Ñ.Ó0Ó1Ð1r   c               ó    € V ^8„  d   QhRRRR/# )r!   Úindexzint | slicer$   r   r   )r&   s   "r   r'   rÕ   ã   s   € ÷ 0ñ 0 ð 0°ñ 0r   c                	óF   € V P                  V P                  V,          4      # r*   rå   )r-   rë   s   &&r   Ú__getitem__ÚDeferredLineBase.__getitem__ã   s   € Ø�~‰~˜dŸi™i¨Õ.Ó/Ð/r   c               ó   € V ^8„  d   QhRR/# ra   r   )r&   s   "r   r'   rÕ   æ   s   € ÷ ñ ˜$ñ r   c                	ó,   € \        V P                  4      # r*   )rb   rH   rN   s   &r   rd   ÚDeferredLineBase.__bool__æ   s   € Ü�D—I‘I‹Ðr   c               ó   € V ^8„  d   QhRR/# )r!   r$   r#   r   )r&   s   "r   r'   rÕ   é   s   € ÷ ñ ˜ñ r   c                	ó,   € \        V P                  4      # r*   )r±   rH   rN   s   &r   Ú__len__ÚDeferredLineBase.__len__é   s   € Ü�4—9‘9‹~Ðr   )rH   N)r   r   r   r   Ú__doc__r.   rÜ   rá   rv   r²   rí   rd   rô   r   r   r   r   r=   r=   Í   s2   † Ù8õõ
"õ"õ6õ2õ0õ÷ñ r   r=   )rö   Ú
__future__r   r�   r³   rµ   Údataclassesr   Úior   Útypingr   r   r   Útyping_extensionsr   Úcollections.abcr	   r
   r   r   r   r   r=   r   r   r   Ú<module>rý      sn   ðñõ #ã Û Û Ý !Ý ß 1Ñ 1Ý "÷ ß<Ñ<ô�*ô ð ÷,ð ,ó ð,÷
c'ñ c'÷Ló r   