L i ddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z m Z ddgZ ee e fZeeeedffZd Zd ed ed eed eefdZded efdZdded eed efdZded ed eed efdZy)N) Collection)OptionalUnion)dill_available) IterDataPipe MapDataPipetraverse traverse_dps DataPipeGraphcy)NSTUBr\/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/utils/data/graph.py_stub_unpicklerrs rscan_obj only_datapipecachereturnc tj}tj|}t rddlm}||}nd}g d} fd}t tf} | D]'} | j||s| j|) |j| D]'} | jd|s| jd)t rddlm} | d S#tjttf$r t r|jnYwxYw#| D]'} | jd|s| jd)t rddlm} | dwwxYw)Nr)Picklerczd}t|tr=i}|jD]&\}}t|ttt fs"|||<(|St|t tfr8g}|D]/}t|ttt fs|j|1|St|ttt fr|}|SN) isinstancedictitemsrrrtuplelistappend) ori_statestatekvs r getstate_hookz0_list_connected_datapipes..getstate_hook's i &E!) !1a, Z!HI E!H !  E4= 1E $a, Z!HILLO $   L+z#J KE rc|k(s t|vrtj|jt|tdfS)Nr)idNotImplementedErrorraddr)objrcaptured_connectionsrs r reduce_hookz._list_connected_datapipes..reduce_hook7sD (?bg.% % ' ' , IIbg "B& &r)extendF)ioBytesIOpicklerrdillrrset_reduce_ex_hookset_getstate_hookdump PickleErrorAttributeError TypeErrorr,) rrrfp dill_Picklerdr$r+datapipe_classescls dill_extendr*s ` ` @r_list_connected_datapipesr>se A  A0 O  '0<[.I# 5C  " "; /%%m4 5  FF8 $ ,C  " "4 (%%d+ ,   2   ""NI> x !  $ ,C  " "4 (%%d+ ,   2   s6!D&:D&C%%;D# D&"D##D&&E--E-datapipec2t}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)rr)set_traverse_helper)r?rs rr r ZseE HD FFrc~d}|s|dz }tj|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`.F)warningswarn FutureWarningrArB)r?rmsgrs rr r lsK* -  ^^ MM#}% eE HmU ;;rc Vt|ttfstdt |dt |}||vriS|j |t|||j}||ifi}|D]2}||djt|||j4|S)Nz.Expected `IterDataPipe` or `MapDataPipe`, but z is found) rrr RuntimeErrortyper&r(r>copyupdaterB)r?rrdp_idrr:items rrBrBs h{ ; <r r rBrrrrXs &"4I ~ & {* +S%/ 9::;  @ @ '+@ 47H@  (^@ FG8G G$