
    Χg              	       6   d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZmZ ddgZeeef         Zeee
edf         f         Zd	 Zd
edede	e         dee         fdZdedefdZddedee         defdZdedede	e         defdZdS )    N)
Collection)DictListOptionalSetTupleTypeUnion)dill_available)IterDataPipeMapDataPipetraversetraverse_dpsDataPipeGraphc                      dS )NSTUB r       R/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/utils/data/graph.py_stub_unpicklerr      s    6r   scan_objonly_datapipecachereturnc                 @    t          j                    }t          j        |          }t	                      rddlm}  ||          }nd }g d } fd}t          t          f}		 |	D ].}
|
                    |           |r|
	                    |           /	 |
                                nG# t          j        t          t          f$ r( t	                      r|
                                n Y nw xY w|	D ].}
|
                    d            |r|
	                    d            /t	                      rddlm}  |d           nV# |	D ].}
|
                    d            |r|
	                    d            /t	                      rddlm}  |d           w w xY wS )Nr   )Picklerc                    d }t          | t                    rDi }|                                 D ],\  }}t          |t          t          t
          f          r|||<   -nt          | t          t          f          r?g }| D ]9}t          |t          t          t
          f          r|                    |           :n$t          | t          t          t
          f          r| }|S N)	
isinstancedictitemsr   r   r   tuplelistappend)	ori_statestatekvs       r   getstate_hookz0_list_connected_datapipes.<locals>.getstate_hook'   s    i&& 	E!)) ! !1a,Z!HII ! E!H! 	E4=11 	E $ $a,Z!HII $LLOOO$ 	L+z#JKK 	Er   c                     | k    st          |           v rt                              |                                t          |                      t          dfS )Nr   )idNotImplementedErrorr$   addr   )objr   captured_connectionsr   s    r   reduce_hookz._list_connected_datapipes.<locals>.reduce_hook7   sY    (??bgg..%% '',,,IIbgg"B&&r   )extendF)ioBytesIOpickler   r   dillr   r   set_reduce_ex_hookset_getstate_hookdumpPickleErrorAttributeError	TypeErrorr1   )r   r   r   fpdill_Picklerdr)   r0   datapipe_classesclsdill_extendr/   s   ` `         @r   _list_connected_datapipesrC      sL    	
A		 	A  000000LOO   ' ' ' ' ' ' ' 0<[.I# 	5 	5C"";/// 5%%m444	FF8"NI> 	 	 	 x     ! 	 $ 	, 	,C""4((( ,%%d+++ 	222222K $ 	, 	,C""4((( ,%%d+++ 	222222K	  s2   (1E B0 /E 0AC41E 3C44E AFdatapipec                 B    t                      }t          | d|          S )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)rD   r   s     r   r   r   Z   s"     eeEHDFFFFr   c                     d}|s|dz  }t          j        |t                     |d}t                      }t	          | ||          S )a6  
    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`.NF)warningswarnFutureWarningrF   rG   )rD   r   msgr   s       r   r   r   l   sZ    *	-   _^^M#}%%%eeEHmU;;;r   c           	         t          | t          t          f          s t          dt	          |            d          t          |           }||v ri S |                    |           t          | ||                                          }|| i fi}|D ]D}||         d         	                    t          |||                                                     E|S )Nz.Expected `IterDataPipe` or `MapDataPipe`, but z	 is found   )r   r   r   RuntimeErrortyper+   r-   rC   copyupdaterG   )rD   r   r   dp_idr!   r?   items          r   rG   rG      s     h{ ;<< 
VT(^^VVV
 
 	
 xLLE~~		IIe%huzz||LLE"~.A P P 	
%+D-NNOOOOHr   r   )r2   r4   rI   collections.abcr   typingr   r   r   r   r   r	   r
   torch.utils._import_utilsr   #torch.utils.data.datapipes.datapiper   r   __all__DataPipeintr   r   boolrC   r   r   rG   r   r   r   <module>r]      s   				   & & & & & & @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 4 4 4 4 4 4 I I I I I I I I ~
&{*+S%/ 9::;  
@ @ '+@ 47H@ 	(^@  @  @  @ FG8 G G G G G$< <x < <- < < < <D'+47H     r   