
    [Thy                     6    / S Qr S rS rS rS rS rS rS rg)	)hashabletransitive_getraisesreverse_dictxfailfreezec                 <     [        U 5        g! [         a     gf = f)NTF)hash	TypeError)xs    _/var/www/auris/envauris/lib/python3.13/site-packages/torch/fx/experimental/unification/utils.pyr   r      s#    Q s    
c                 f    [        U 5      (       a   X;   a  X   n [        U 5      (       a  X;   a  M  U $ )zYTransitive dict.get
>>> d = {1: 2, 2: 3, 3: 4}
>>> d.get(1)
2
>>> transitive_get(1, d)
4
)r   )keyds     r   r   r      s,     3--CHf 3--CHJ    c                 ,     U" 5         g! U  a     gf = f)NFT )errlamdas     r   r   r      s!     s   
 c                   ^ [        U 5      mTR                  5        VVs0 s H  u  pU[        U5      _M     snnmU  Vs1 s H  o3T;  d  M
  UiM     nn/ nU(       a  UR                  5       nUR	                  U5        U R                  US5       H?  nUTU   ;   d   eTU   R                  U5        TU   (       a  M.  UR                  U5        MA     U(       a  M  [        U4S jU  5       5      (       a  [        S5      eU$ s  snnf s  snf )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
r   c              3   H   >#    U  H  nTR                  US 5      v   M     g 7f)Nget).0vincoming_edgess     r   	<genexpr>_toposort.<locals>.<genexpr>?   s!     
61>a&&s   "zInput has cycles)
r   itemssetpopappendr   removeaddany
ValueError)	edgeskvalr   SLnmr   s	           @r   	_toposortr-   $   s     "%(N0>0D0D0FG0FfaaSk0FGN5Eqn4EA5
A
EEG	1b!Aq))))1$$Q'!!$$a	 " ! 
6
666+,,H H5s   D 	D
D
c                 b    0 nU  H&  nX    H  nUR                  US5      U4-   X'   M     M(     U$ )ay  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   r   )r   resultr   r(   s       r   r   r   D   s?     F6C **S"-6FK   Mr   c                 H     U " 5         [        S5      e! [          a     g f = f)NzXFailed test passed)	Exception)funcs    r   r   r   U   s*    -.. s    
!!c                 B   [        U [        5      (       a'  [        [        [        U R                  5       5      5      $ [        U [        5      (       a  [        [        [        U 5      5      $ [        U [        [        45      (       a  [        [        [        U 5      5      $ U $ )zFreeze container to hashable form
>>> freeze(1)
1
>>> freeze([1, 2])
(1, 2)
>>> freeze({1: 2})  # doctest: +SKIP
frozenset([(1, 2)])
)	
isinstancedict	frozensetmapr   r   r   tuplelist)r   s    r   r   r   ]   sn     !TVQWWY/00!SVQ((!eT]##S^$$Hr   N)__all__r   r   r   r-   r   r   r   r   r   r   <module>r;      s.   
U
@"r   