§
    ŠŠtj  ã                  ó˜   — d dl mZ d dlmZmZ erd dlmZmZ ddlm	Z	  ed¦  «        Z
g d¢Zd!d„Zd"d„Zd#d„Zd$d„Zd%d„Zd&d„Zd'd„Zd S )(é    )Úannotations)ÚTYPE_CHECKINGÚTypeVar)ÚCallableÚIterableé   )ÚVarÚ_T)ÚhashableÚtransitive_getÚraisesÚreverse_dictÚxfailÚfreezeÚxÚobjectÚreturnÚboolc                óH   — 	 t          | ¦  «         dS # t          $ r Y dS w xY w)NTF)ÚhashÚ	TypeError)r   s    úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/fx/experimental/unification/utils.pyr   r      s9   € ðÝˆQ‰ŒˆØˆtøÝð ð ð Øˆuˆuðøøøs   ‚ “
! !ÚkeyÚdúdict[Var, object]c                ób   — t          | ¦  «        r| |v r||          } t          | ¦  «        r| |v °| S )zqTransitive dict.get
    >>> d = {1: 2, 2: 3, 3: 4}
    >>> d.get(1)
    2
    >>> transitive_get(1, d)
    4
    )r   )r   r   s     r   r   r      s@   € õ �3‰-Œ-ð ˜C 1˜H˜HØ�Œfˆõ �3‰-Œ-ð ˜C 1˜H˜Hà€Jó    Úerrútype[BaseException]ÚlamdaúCallable[[], object]c                ó4   — 	  |¦   «          dS # | $ r Y dS w xY w)NFT© )r   r    s     r   r   r   &   s9   € ðØˆ‰ŒˆØˆuøØð ð ð Øˆtˆtðøøøs   ‚
 Ž–Úedgesúdict[_T, Iterable[_T]]úlist[_T]c                ó  ‡— t          | ¦  «        Šd„ ‰                     ¦   «         D ¦   «         Šˆfd„| D ¦   «         }g }|rœ|                     ¦   «         }|                     |¦  «         |                      |d¦  «        D ]Z}|‰|         vrt          d|› d|› d�¦  «        ‚‰|                              |¦  «         ‰|         s|                     |¦  «         Œ[|°œt          ˆfd„| D ¦   «         ¦  «        rt          d¦  «        ‚|S )	a
  Topological sort algorithm by Kahn [1] - O(nodes + vertices)
    inputs:
        edges - a dict of the form {a: {b, c}} where b and c depend on a
    outputs:
        L - an ordered list of nodes that satisfy the dependencies of edges
    >>> # xdoctest: +SKIP
    >>> _toposort({1: (2, 3), 2: (3,)})
    [1, 2, 3]
    Closely follows the wikipedia page [2]
    [1] Kahn, Arthur B. (1962), "Topological sorting of large networks",
    Communications of the ACM
    [2] http://en.wikipedia.org/wiki/Toposort#Algorithms
    c                ó4   — i | ]\  }}|t          |¦  «        “ŒS r#   )Úset)Ú.0ÚkÚvals      r   ú
<dictcomp>z_toposort.<locals>.<dictcomp>B   s$   € ÐGÐGÐG¡f a¨�a�˜S™œÐGÐGÐGr   c                ó   •— h | ]}|‰v¯|’Œ	S r#   r#   ©r*   ÚvÚincoming_edgess     €r   ú	<setcomp>z_toposort.<locals>.<setcomp>C   s#   ø€ Ð5Ð5Ð5ˆq˜Q nÐ4Ð4ˆÐ4Ð4Ð4r   r#   z	Expected z in incoming_edges[ú]c              3  óB   •K  — | ]}‰                      |¦  «        V — Œd S )N©Úgetr/   s     €r   ú	<genexpr>z_toposort.<locals>.<genexpr>O   s1   øè è € Ð
0Ð
0 Qˆ>×Ò˜aÑ Ô Ð
0Ð
0Ð
0Ð
0Ð
0Ð
0r   zInput has cycles)
r   ÚitemsÚpopÚappendr6   ÚAssertionErrorÚremoveÚaddÚanyÚ
ValueError)r$   ÚSÚLÚnÚmr1   s        @r   Ú	_toposortrD   3   s=  ø€ õ " %Ñ(Ô(€NØGÐG°×0DÒ0DÑ0FÔ0FÐGÑGÔG€NØ5Ð5Ð5Ð5�EÐ5Ñ5Ô5€AØ
€Aà
ð Ø�EŠE‰GŒGˆØ	�Š�‰ŒˆØ—’˜1˜bÑ!Ô!ð 	ð 	ˆAØ˜ qÔ)Ð)Ð)Ý$Ð%K°Ð%KÐ%KÀqÐ%KÐ%KÐ%KÑLÔLÐLØ˜1Ô×$Ò$ QÑ'Ô'Ð'Ø! !Ô$ð Ø—’�a‘”�øð ð õ Ð
0Ð
0Ð
0Ð
0¨%Ð
0Ñ
0Ô
0Ñ0Ô0ð -ÝÐ+Ñ,Ô,Ð,Ø€Hr   údict[_T, tuple[_T, ...]]c                ód   — i }| D ]*}| |         D ]}|                      |d¦  «        |fz   ||<   Œ Œ+|S )a§  Reverses direction of dependence dict.

    >>> d = {"a": (1, 2), "b": (2, 3), "c": ()}
    >>> reverse_dict(d)  # doctest: +SKIP
    {1: ('a',), 2: ('a', 'b'), 3: ('b',)}

    .. note::
        dict order are not deterministic. As we iterate on the
        input dict, it make the output of this function depend on the
        dict order. So this function output order should be considered
        as undeterministic.
    r#   r5   )r   Úresultr   r,   s       r   r   r   T   sW   € ð €FØð 7ð 7ˆØ�S”6ð 	7ð 	7ˆCà Ÿ*š* S¨"Ñ-Ô-°°Ñ6ˆF�3‰KˆKð	7ð €Mr   ÚfuncÚNonec                óX   — 	  | ¦   «          t          d¦  «        ‚# t           $ r Y d S w xY w)NzXFailed test passed)Ú	Exception)rH   s    r   r   r   i   sC   € ðØˆ‰ŒˆÝÐ-Ñ.Ô.Ð.øÝð ð ð Øˆˆðøøøs   ‚ ›
)¨)c                ó‚  — t          | t          ¦  «        r4t          t          t          |                      ¦   «         ¦  «        ¦  «        S t          | t          ¦  «        r"t          t          t          | ¦  «        ¦  «        S t          | t          t          f¦  «        r"t          t          t          | ¦  «        ¦  «        S | S )z¡Freeze container to hashable form
    >>> freeze(1)
    1
    >>> freeze([1, 2])
    (1, 2)
    >>> freeze({1: 2})  # doctest: +SKIP
    frozenset([(1, 2)])
    )	Ú
isinstanceÚdictÚ	frozensetÚmapr   r8   r)   ÚtupleÚlist)r   s    r   r   r   q   s�   € õ �!•TÑÔð 1Ý��V Q§W¢W¡Y¤YÑ/Ô/Ñ0Ô0Ð0Ý�!•SÑÔð )Ý��V Q™œÑ(Ô(Ð(Ý�!•e�T�]Ñ#Ô#ð %Ý•S� ‘^”^Ñ$Ô$Ð$Ø€Hr   N)r   r   r   r   )r   r   r   r   r   r   )r   r   r    r!   r   r   )r$   r%   r   r&   )r   r%   r   rE   )rH   r!   r   rI   )r   r   r   r   )Ú
__future__r   Útypingr   r   Úcollections.abcr   r   Úvariabler	   r
   Ú__all__r   r   r   rD   r   r   r   r#   r   r   ú<module>rX      s  ðØ "Ð "Ð "Ð "Ð "Ð "à )Ð )Ð )Ð )Ð )Ð )Ð )Ð )ð ð Ø2Ð2Ð2Ð2Ð2Ð2Ð2Ð2àÐÐÐÐÐà€WˆT�]„]€ð VÐ
UÐ
U€ðð ð ð ð
ð 
ð 
ð 
ðð ð ð ðð ð ð ðBð ð ð ð*ð ð ð ðð ð ð ð ð r   