Ë
    M²j:  ã                   óV   — d dl mZ d dlmZmZ d dlmZ d„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zy)é    )ÚRefine)ÚunifyÚVar)Ú
TensorTypec                 ó�   — t        | «      }|j                  «        t        |j                  «      }t	        | j
                  |«       y)z-
    Calls our symbolic inferencer once.
    N)r   ÚrefineÚunify_eqÚconstraintsÚsubstitute_all_typesÚgraph©ÚtracedÚrÚmgus      úf/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/torch/fx/experimental/unify_refinements.pyÚ infer_symbolic_types_single_passr      s2   € ô 	ˆv‹€AØ‡H�H„JÜ
�1—=‘=Ó
!€CÜ˜Ÿ™ sÕ+ó    c                 ó<  — t        | «      }|j                  «        t        |j                  «      }t	        | j
                  |«       t        | «      }|j                  «        t        |j                  «      }t	        | j
                  |«       |j                  «        y)z¥
    Calls our symbolic inferencer twice.
    This is useful when one pass is not enough
    to infer all the information such as the case
    for broadcasting.
    N)r   r   r	   r
   r   r   Úsymbolic_relationsr   s      r   Úinfer_symbolic_typesr      sl   € ô 	ˆv‹€AØ‡H�H„JÜ
�1—=‘=Ó
!€CÜ˜Ÿ™ sÔ+äˆv‹€AØ‡H�H„JÜ
�1—=‘=Ó
!€CÜ˜Ÿ™ sÔ+à×ÑÕr   c                 ó°   — g }g }| D ]8  }|j                  |j                  «       |j                  |j                  «       Œ: t        |«      t        |«      fS )za
    Convert equality constraints in the right format
    to be used by unification library.
    )ÚappendÚlhsÚrhsÚtuple)Ú
list_of_eqr   r   Úeqs       r   Ú
convert_eqr   %   sR   € ð
 €CØ
€CØò ˆØ�
‰
�2—6‘6ÔØ�
‰
�2—6‘6Õðô �‹:”u˜S“zÐ!Ð!r   c                 ó6   — t        | «      \  }}t        ||«      S )z@
    Apply unification to a set of
    equality constraints
    )r   r   )r   r   r   s      r   r	   r	   2   s   € ô
 ˜*Ó%�H€CˆÜ��c‹?Ðr   c                 óè  — t        |t        «      r|| v r| |   S |S t        |t        «      rQg }|j                  D ],  }|| v r|j	                  | |   «       Œ|j	                  |«       Œ. t        t        |«      «      S t        |t        «      r&g }|D ]  }|j	                  t        | |«      «       Œ |S t        |t
        «      r/g }|D ]  }|j	                  t        | |«      «       Œ t        |«      S |S )z2
    Apply the most general unifier to a type
    )Ú
isinstancer   r   Ú__args__r   r   ÚlistÚsubstitute_solution_one_type)ÚmappingÚtÚnew_typeÚtyps       r   r$   r$   ;   sø   € ô �!”SÔØ�‰<Ø˜1‘:ÐàˆHä	�A”zÔ	"ØˆØ—:‘:ò 	%ˆCØ�g‰~Ø—‘ ¨¡Õ-à—‘ Õ$ð		%ô
 œ% ›/Ó*Ð*ä	�A”tÔ	ØˆØò 	HˆCØ�O‰OÔ8¸À#ÓFÕGð	Hàˆä	�A”uÔ	ØˆØò 	HˆCØ�O‰OÔ8¸À#ÓFÕGð	Hä�X‹Ðð ˆr   c                 óÄ   — d}|r0d}|D ]&  }||   }||   |v r||   }||   ||<   |||   k7  sŒ%d}Œ( |rŒ0| j                   D ]  }t        ||j                  «      |_        Œ y)zž
    Apply the most general unifier to all types in a graph
    till reaching a fixed point. If the input and output graph
    are the same, we converge.
    TFN)Únodesr$   Útype)r   r%   ÚflagÚkÚold_mapping_valÚnew_keyÚns          r   r   r   ^   s‰   € ð €DÙ
ØˆØò 	ˆAØ% a™jˆOØ�q‰z˜WÑ$Ø! !™*�Ø$ WÑ-�˜‘
Ø '¨!¡*Ó,Ø‘ð	ò ð �[‰[ò ?ˆÜ-¨g°q·v±vÓ>ˆ�ñ?r   c                 óŠ   — t        | j                  |j                  «      D ]   \  }}|j                  |j                  k7  sŒ  y y)zv
    A check equality to be used in fixed points.
    We do not use graph equality but instead type
    equality.
    FT)Úzipr*   r+   )Úg1Úg2r0   Úms       r   Úcheck_for_type_equalityr6   s   s>   € ô �B—H‘H˜bŸh™hÓ'ò ‰ˆˆ1Ø�6‰6�Q—V‘VÓÙðð r   N)Ú/torch.fx.experimental.graph_gradual_typecheckerr   Ú!torch.fx.experimental.unificationr   r   Útorch.fx.tensor_typer   r   r   r   r	   r$   r   r6   © r   r   ú<module>r;      s2   ðå Bß 8Ý +ò,òò(
"òò òF?ó*	r   