
    JTh              	           S SK r S SKrS SKrS SKJr  S SKJrJr  S SKJ	r	  S SK
JrJr  SS/r\\\4   r\\\\S4   4   rS	 rS
\S\S\\   S\\   4S jrS\S\4S jrSS\S\\   S\4S jjrS\S\S\\   S\4S jrg)    N)
Collection)OptionalUnion)dill_available)IterDataPipeMapDataPipetraversetraverse_dpsDataPipeGraphc                      g)NSTUB r       N/var/www/auris/envauris/lib/python3.13/site-packages/torch/utils/data/graph.py_stub_unpicklerr      s    r   scan_objonly_datapipecachereturnc                 >  ^ ^^ [         R                  " 5       n[        R                  " U5      n[	        5       (       a  SSKJn  U" U5      nOS n/ mS nUUU 4S jn[        [        4n	 U	 H.  n
U
R                  U5        U(       d  M  U
R                  U5        M0      UR                  T 5        U	 H.  n
U
R                  S 5        U(       d  M  U
R                  S 5        M0     [	        5       (       a  SSKJn  U" S5        T$ ! [        R                  [        [        4 a$    [	        5       (       a  UR                  T 5         Ne f = f! U	 H.  n
U
R                  S 5        U(       d  M  U
R                  S 5        M0     [	        5       (       a  SSKJn  U" S5        f f = f)Nr   )Picklerc                    S n[        U [        5      (       aC  0 nU R                  5        H+  u  p#[        U[        [        [
        45      (       d  M'  X1U'   M-     U$ [        U [        [        45      (       a@  / nU  H6  n[        U[        [        [
        45      (       d  M%  UR                  U5        M8     U$ [        U [        [        [
        45      (       a  U nU$ N)	
isinstancedictitemsr   r   r   tuplelistappend)	ori_statestatekvs       r   getstate_hook0_list_connected_datapipes.<locals>.getstate_hook'   s    i&&E!)a,Z!HII !H *  	E4=11Ea,Z!HIILLO 
  	L+z#JKKEr   c                    > U T:X  d  [        U 5      T;   a  [        eTR                  U 5        TR                  [        U 5      5        [        S4$ )Nr   )idNotImplementedErrorr   addr   )objr   captured_connectionsr   s    r   reduce_hook._list_connected_datapipes.<locals>.reduce_hook7   sD    (?bg.%% '',IIbg"B&&r   )extendF)ioBytesIOpickler   r   dillr   r   set_reduce_ex_hookset_getstate_hookdumpPickleErrorAttributeError	TypeErrorr.   )r   r   r   fpdill_Picklerdr$   r,   datapipe_classesclsdill_extendr+   s   ` `         @r   _list_connected_datapipesr@      sc    	

A		A 0O ' 0<[.I#C"";/}%%m4 $	FF8 $C""4(}%%d+ $ 2 ""NI> 	x 		 $C""4(}%%d+ $ 2 s6   )E E D ?EE EE F(4Fdatapipec                 ,    [        5       n[        U SUS9$ )a  
Traverse the DataPipes and their attributes to extract the DataPipe graph.

This only looks into the attribute from each DataPipe that is either a
DataPipe and a Python collection object such as ``list``, ``tuple``,
``set`` and ``dict``.

Args:
    datapipe: the end DataPipe of the graph
Returns:
    A graph represented as a nested dictionary, where keys are ids of DataPipe instances
    and values are tuples of DataPipe instance and the sub-graph
T)r   r   )set_traverse_helper)rA   r   s     r   r
   r
   Z   s     eEHDFFr   c                     SnU(       d  US-  n[         R                  " U[        5        Uc  Sn[        5       n[	        XU5      $ )a  
Traverse the DataPipes and their attributes to extract the DataPipe graph.

[Deprecated]
When ``only_dataPipe`` is specified as ``True``, it would only look into the
attribute from each DataPipe that is either a DataPipe and a Python collection object
such as ``list``, ``tuple``, ``set`` and ``dict``.

Note:
    This function is deprecated. Please use `traverse_dps` instead.

Args:
    datapipe: the end DataPipe of the graph
    only_datapipe: If ``False`` (default), all attributes of each DataPipe are traversed.
      This argument is deprecating and will be removed after the next release.
Returns:
    A graph represented as a nested dictionary, where keys are ids of DataPipe instances
    and values are tuples of DataPipe instance and the sub-graph
zV`traverse` function and will be removed after 1.13. Please use `traverse_dps` instead.zM And, the behavior will be changed to the equivalent of `only_datapipe=True`.F)warningswarnFutureWarningrC   rD   )rA   r   msgr   s       r   r	   r	   l   sI    *	-  ^^MM#}%eEHU;;r   c           	      ^   [        U [        [        45      (       d  [        S[	        U 5       S35      e[        U 5      nX2;   a  0 $ UR                  U5        [        XUR                  5       5      nX00 40nU H1  nXS   S   R                  [        XaUR                  5       5      5        M3     U$ )Nz.Expected `IterDataPipe` or `MapDataPipe`, but z	 is found   )r   r   r   RuntimeErrortyper'   r)   r@   copyupdaterD   )rA   r   r   dp_idr   r<   items          r   rD   rD      s     h{ ;<<<T(^<LIV
 	
 xLE~		IIe%huzz|LE"~.A 	
+DNO  Hr   r   )r/   r1   rF   collections.abcr   typingr   r   torch.utils._import_utilsr   #torch.utils.data.datapipes.datapiper   r   __all__DataPiper   intr   r   r   boolrC   r   r@   r
   r	   rD   r   r   r   <module>rZ      s    	   & " 4 I ~
&{*+S%/ 9::;
@ @ '+@ 47H@ 	(^@ FG8 G G$<x < <- <D'+47Hr   