o
    !if                     @   sB  U d dl mZmZmZmZmZmZmZ d dlm	Z	m
Z
mZ d dlmZ ee	e
gef Zi Zeee ef ed< dededdfd	d
Zde	de
dee fddZdeeef de
dee fddZdee de
dee fddZdee de
dee fddZdede
dee fddZeee eee eee eee dS )    )CallableAnyTupleListDictType
NamedTuple)PyTreeTreeSpecLeafSpec)
namedtupleSUPPORTED_NODEStypflatten_fn_specreturnNc                 C   s   |t | < d S )N)r   )r   r    r   _/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/torch/fx/_pytree.pyregister_pytree_flatten_spec   s   r   pytreespecc                 C   sp   t |tr| gS |jtvrtt|  dt|j }|| |}g }t||jD ]\}}t||}||7 }q(|S )Nz does not have a flatten_fn_spec associated with it. Please register one with torch.fx._pytree.register_pytree_flatten_spec.  If you have serialized your model, make sure that any custom pytrees have been registered before loading it.)
isinstancer   typer   RuntimeErrorzipchildren_specstree_flatten_spec)r   r   r   Zchild_pytreesresultchildZ
child_specZflatr   r   r   r      s   





r   dc                    s    fdd|j D S )Nc                       g | ]} | qS r   r   ).0kr   r   r   
<listcomp>       z&_dict_flatten_spec.<locals>.<listcomp>)contextr   r   r   r"   r   _dict_flatten_spec   s   r'   c                        fddt t|jD S )Nc                    r   r   r   r    ir"   r   r   r#      r$   z&_list_flatten_spec.<locals>.<listcomp>rangelenr   r&   r   r"   r   _list_flatten_spec      r.   c                    r(   )Nc                    r   r   r   r)   r"   r   r   r#   "   r$   z'_tuple_flatten_spec.<locals>.<listcomp>r+   r&   r   r"   r   _tuple_flatten_spec!   r/   r0   c                    r(   )Nc                    r   r   r   r)   r"   r   r   r#   %   r$   z,_namedtuple_flatten_spec.<locals>.<listcomp>r+   r&   r   r"   r   _namedtuple_flatten_spec$   r/   r1   )typingr   r   r   r   r   r   r   Ztorch.utils._pytreer	   r
   r   collectionsr   ZFlattenFuncSpecr   __annotations__r   r   r'   r.   r0   r1   dictlisttupler   r   r   r   <module>   s   & "


