ó
    "Eñi´  ã            	       óx  • S SK r S SKrS SKJr  S SKJr  S SKrS SKJrJ	r	  S SK
JrJrJr  / SQrS\S\\   4S	 jrS\S
\\   S\\   4S jrS\S\4S jr\	R,                  4S\S\S\S\4S jjrS\S\4S jrSS\S\S-  S\4S jjr\" S\S9S\S\S\4S j5       rS\S\4S jrS\S\R:                  S\4S jrg)é    N)ÚAny)Ú
deprecated)Ú_ShardingIterDataPipeÚSHARDING_PRIORITIES)ÚDataPipeÚDataPipeGraphÚtraverse_dps)Úapply_random_seedÚapply_shardingÚapply_shuffle_seedÚapply_shuffle_settingsÚget_all_graph_pipesÚgraphÚreturnc                 ó*   • [        U [        5       5      $ ©N)Ú_get_all_graph_pipes_helperÚset)r   s    Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/utils/data/graph_settings.pyr   r      s   € Ü& u¬c«eÓ4Ð4ó    Úid_cachec                 óÈ   • / nU R                  5        HK  u  nu  pEX1;   a  M  UR                  U5        UR                  U5        UR                  [	        XQ5      5        MM     U$ r   )ÚitemsÚaddÚappendÚextendr   )r   r   ÚresultsÚdp_idÚdatapipeÚ	sub_graphs         r   r   r      s[   € ð !€GØ(-¯©®Ñ$ˆÑ$�ØÓÙØ�‰�UÔØ�‰�xÔ Ø�‰Ô2°9ÓGÖHñ )6ð €Nr   r   c                 ó–   • [        U [        5      =(       d3    [        U S5      =(       a     [        R                  " U R
                  5      $ )Nr   )Ú
isinstancer   ÚhasattrÚinspectÚismethodr   ©r   s    r   Ú_is_sharding_datapiper'   )   s;   € Ü�hÔ 5Ó6÷ Ü�Ð*Ó+÷ 	6Ü×Ò˜X×4Ñ4Ó5ðr   Únum_of_instancesÚinstance_idc                 óN   ^^^^• [        U 5      nSSUUUU4S jjjmT" U5        U $ )zÅ
Apply dynamic sharding over the ``sharding_filter`` DataPipe that has a method ``apply_sharding``.

RuntimeError will be raised when multiple ``sharding_filter`` are presented in the same branch.
c                 ó\  >• U R                  5        H—  u  p#S n[        U5      (       as  Ub  [        SU SU 35      e[        R                  " UR
                  5      n[        UR                  5      S:  a  UR                  TT5        OUR                  TTT	S9  UnUc  UnT" X45        M™     g )NzoSharding twice on a single pipeline is likely unintended and will cause data loss. Sharding already applied to z while trying to apply to é   )Úsharding_group)Úvaluesr'   ÚRuntimeErrorr$   Ú	signaturer   ÚlenÚ
parameters)
r   Úprev_appliedÚdpr    ÚappliedÚsigÚ_helperr)   r(   r-   s
         €€€€r   r7   Úapply_sharding.<locals>._helper=   s¾   ø€ Ø"Ÿ\™\ž^‰MˆBØˆGÜ$ R×(Ñ(ØÑ+Ü&ð7Ø7C°nÐD^Ð_aÐ^bðdóð ô
 ×'Ò'¨×(9Ñ(9Ó:�Ü�s—~‘~Ó&¨Ó*Ø×%Ñ%Ð&6¸ÕDà×%Ñ%Ø(¨+Ànð &ñ ð �Ø‰Ø&�Ù�IÖ'ò' ,r   r   )r   N)r	   )r   r(   r)   r-   r   r7   s    ``` @r   r   r   0   s'   û€ ô ˜Ó"€E÷(ô (ñ, ˆE„Nà€Or   c                 óÜ   • [        U S5      =(       aZ    [        U S5      =(       aG    [        R                  " U R                  5      =(       a     [        R                  " U R                  5      $ )NÚset_shuffleÚset_seed)r#   r$   r%   r:   r;   r&   s    r   Ú_is_shuffle_datapiper<   X   sT   € ä�˜-Ó(÷ 	0Ü�H˜jÓ)÷	0ä×Ò˜X×1Ñ1Ó2÷	0ô ×Ò˜X×.Ñ.Ó/ð	r   Úshufflec                 ó.  • Uc  U $ [        U 5      n[        U5      nU Vs/ s H  n[        U5      (       d  M  UPM     nnU(       d/  U(       a(  [        R                  " SSS9  U R                  5       n U /nU H  nUR                  U5        M     U $ s  snf )a)  
Traverse the graph of ``DataPipes`` to find and set shuffle attribute.

Apply the method to each `DataPipe` that has APIs of ``set_shuffle``
and ``set_seed``.

Args:
    datapipe: DataPipe that needs to set shuffle attribute
    shuffle: Shuffle option (default: ``None`` and no-op to the graph)
z«`shuffle=True` was set, but the datapipe does not contain a `Shuffler`. Adding one at the end. Be aware that the default buffer size might not be sufficient for your task.é   )Ú
stacklevel)r	   r   r<   ÚwarningsÚwarnr=   r:   )r   r=   r   Ú	all_pipesÚpipeÚ	shufflersÚshufflers          r   r   r   a   s™   € ð �Øˆä˜Ó"€EÜ# EÓ*€IÙ"+ÓJ¢)˜$Ô/CÀD×/I—¡)€IÐJÞžÜ�Šð[àò	
ð
 ×#Ñ#Ó%ˆàð
ˆ	ó ˆØ×Ñ˜WÖ%ñ ð €Oùò Ks
    B¸Bz�`apply_shuffle_seed` is deprecated since 1.12 and will be removed in the future releases. Please use `apply_random_seed` instead.)ÚcategoryÚrngc                 ó   • [        X5      $ r   )r
   )r   rH   s     r   r   r   ƒ   s   € ô ˜XÓ+Ð+r   c                 óh   • [        U S5      =(       a     [        R                  " U R                  5      $ )Nr;   )r#   r$   r%   r;   r&   s    r   Ú_is_random_datapiperK   Œ   s%   € Ü�8˜ZÓ(×P¬W×-=Ò-=¸h×>OÑ>OÓ-PÐPr   c                 óº  • [        U 5      n[        U5      n[        5       n/ nU HQ  n[        U5      U;   a  M  [	        U5      (       d  M&  UR                  U5        UR                  [        U5      5        MS     U H[  n[        [        R                  " S[        R                  S9R                  US9R                  5       5      nUR                  U5        M]     U $ )a  
Traverse the graph of ``DataPipes`` to find random ``DataPipe`` with an API of ``set_seed``.

Then set the random seed based on the provided RNG to those ``DataPipe``.

Args:
    datapipe: DataPipe that needs to set randomness
    rng: Random number generator to generate random seeds
© )Údtype)Ú	generator)r	   r   r   ÚidrK   r   r   ÚintÚtorchÚemptyÚint64Úrandom_Úitemr;   )r   rH   r   rC   ÚcacheÚrandom_datapipesrD   Úrandom_seeds           r   r
   r
   �   s½   € ô ˜Ó"€EÜ# EÓ*€Iô ‹E€EØÐÛˆÜˆd‹8�uÓÙÜ˜t×$Ó$Ø×#Ñ# DÔ)Ø�I‰I”b˜“hÖñ ó !ˆÜÜ�KŠK˜¤%§+¡+Ñ.×6Ñ6ÀÐ6ÐE×JÑJÓLó
ˆð 	�‰�kÖ"ñ	 !ð €Or   r   )r$   rA   Útypingr   Útyping_extensionsr   rR   Ú(torch.utils.data.datapipes.iter.shardingr   r   Útorch.utils.data.graphr   r   r	   Ú__all__Úlistr   r   rQ   r   Úboolr'   ÚDEFAULTr   r<   r   ÚFutureWarningr   rK   Ú	Generatorr
   rM   r   r   Ú<module>rd      sI  ðã Û Ý Ý (ã ÷÷ IÑ Hò€ð5˜}ð 5°°h±ô 5ð
Øð
Ø$'¨¡Hð
à	ˆ(�^ô
ð Hð °ô ð '×.Ñ.ñ	%Øð%àð%ð ð%ð
 õ%ðP 8ð °ô ñ Xð ¸¸t¹ð Èxõ ñD ð.àñð
, ð ,°ð ,¸ó ,óð
,ðQ (ð Q¨tô Qð ð ¨u¯©ð À8õ r   