o
    ߗi
                     @  sD  U d Z ddlmZ ddlmZmZmZmZ ddlm	  m
Z ddlmZ er,ddlmZ g Zded	< ejrddlZddlZddlm	  mZ eejjd
dd"ddZdZdD ]ZeeeZeed
dej [qW[eejd
d	d#d$ddZeejdd	d#d%ddZedg7 Zeej d
d	d#d&d d!Z ed!g7 ZdS dS )'z)
Python polyfills for torch.utils.pytree
    )annotations)AnyCallableIterableTYPE_CHECKINGN   )substitute_in_graph)PyTreez	list[str]__all__T)can_constant_fold_throughargsr   kwargsreturnboolc                  O  s   t d)NzeShould not be called directly because the original function will be called in the constant fold path.)
ValueError)r   r    r   \/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/torch/_dynamo/polyfills/pytree.py_   s   r    )is_namedtupleis_namedtuple_classis_namedtuple_instanceis_structseqis_structseq_classis_structseq_instancenamedtuple_fieldsstructseq_fieldstreer	   is_leafCallable[[PyTree], bool] | Nonec                 C  s<   | d u s|d ur|| rdS t jjt| ddd u rdS dS )NTtorch)	namespaceF)optreeregister_pytree_nodegettyper   r   r   r   r   tree_is_leaf9   s
   r'   FIterable[Any]c                 c  sX    | g}|r*|  }t||dr|V  qtj||ddd^}}|t| |sd S d S )Nr   Tr    )r   none_is_leafr!   )popr'   r"   tree_flatten_one_levelextendreversed)r   r   stacknodechildrenr   r   r   r   	tree_iterD   s   
r2   	list[Any]c                 C  s   t t| |dS )Nr)   )listr2   r&   r   r   r   tree_leavesZ   s   r5   )r   r   r   r   r   r   )N)r   r	   r   r   r   r   )r   r	   r   r   r   r(   )r   r	   r   r   r   r3   )!__doc__
__future__r   typingr   r   r   r   torch.utils._pytreeutils_pytreepython_pytree
decoratorsr   torch.utils._cxx_pytreer	   r
   __annotations___cxx_pytree_dynamo_traceabler"   	optree._C_cxx_pytree
cxx_pytree_Cis_dict_insertion_orderedr   __namegetattr__func__python_implementation__r'   r2   r5   r   r   r   r   <module>   sJ    




