U
    D‹Ñh«  ã                   @   sh  d dl mZmZmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZ ddlmZ ddgZdZdd	„ Zd
d„ ZeedƒZdd„ e_dd„ e_edd�eƒ eedƒZdd„ e_dd„ e_edd�eƒ eeef eee ef dœdd„Zee eeeef dœdd„Zee eee ef dœdd„Zee eee dœdd„Zeeeeded � eeeed!ed � d"S )#é    )ÚAnyÚDictÚIterableÚListÚTuple)Ú_dict_flattenÚ_dict_flatten_with_keysÚ_dict_unflattenÚ_list_flattenÚ_list_flatten_with_keysÚ_list_unflattenÚContextÚregister_pytree_nodeé   )ÚcompatibilityÚimmutable_listÚimmutable_dictzÒIf you are attempting to modify the kwargs or args of a torch.fx.Node object,
instead create a new copy of it and assign the copy to the node:
    new_args = ... # copy and mutate args
    node.args = new_args
c                 O   s   t dt| ƒj› dt› �ƒ‚d S )Nú'z$' object does not support mutation. )ÚNotImplementedErrorÚtypeÚ__name__Ú_help_mutation)ÚselfÚargsÚkwargs© r   úL/tmp/user/2202/pip-unpacked-wheel-bf9o3bgk/torch/fx/immutable_collections.pyÚ_no_mutation   s    ÿr   c                 C   s.   t d| j | fi ƒ}|D ]}t||tƒ q|S )NZ
immutable_)r   r   Úsetattrr   )ÚbaseZmutable_functionsÚ	containerÚattrr   r   r   Ú_create_immutable_container"   s    r"   )Ú__delitem__Ú__iadd__Ú__imul__Ú__setitem__ÚappendÚclearÚextendÚinsertÚpopÚremoveÚreverseÚsortc                 C   s   t tt| ƒƒffS ©N)r   ÚtupleÚiter©r   r   r   r   Ú<lambda>:   ó    r3   c                 C   s   t t| ƒƒS r/   )Úhashr0   r2   r   r   r   r3   ;   r4   T)Zis_backward_compatible)r#   Ú__ior__r&   r(   r+   ÚpopitemÚ
setdefaultÚupdatec                 C   s   t t|  ¡ ƒffS r/   )r   r1   Úitemsr2   r   r   r   r3   L   r4   c                 C   s   t t|  ¡ ƒƒS r/   )r5   r0   r:   r2   r   r   r   r3   M   r4   )ÚdÚreturnc                 C   s   t | ƒS r/   )r   ©r;   r   r   r   Ú_immutable_dict_flattenR   s    r>   )ÚvaluesÚcontextr<   c                 C   s   t t| |ƒƒS r/   )r   r	   ©r?   r@   r   r   r   Ú_immutable_dict_unflattenV   s    rB   c                 C   s   t | ƒS r/   )r
   r=   r   r   r   Ú_immutable_list_flatten]   s    rC   c                 C   s   t t| |ƒƒS r/   )r   r   rA   r   r   r   Ú_immutable_list_unflattena   s    rD   z-torch.fx.immutable_collections.immutable_dict)Zserialized_type_nameZflatten_with_keys_fnz-torch.fx.immutable_collections.immutable_listN)Útypingr   r   r   r   r   Ztorch.utils._pytreer   r   r	   r
   r   r   r   r   Z_compatibilityr   Ú__all__r   r   r"   Úlistr   Ú
__reduce__Ú__hash__Údictr   r>   rB   rC   rD   r   r   r   r   Ú<module>   sX   (þ

þ

$
ý ýûû