
    ȅi              
           S SK Jr  S SKJr  S SKJrJr  S\\\4   S\S\\\4   4S jr	S\S	\S
\\
S-  \\
S-  \/\4   S\4S jrg)    )Callable)Any)ContextTreeSpecuser_kwargsspecreturnc                 b   UR                   [        L d   eUR                  S:X  d   eUR                  S5      nUR                   [        L d   e[        U 5      [        UR                  5      :w  a$  [        S[        U 5       SUR                   35      e0 nUR                   H	  nX   X4'   M     U$ )aD  Reorder user-provided kwargs to match the order in `spec`. `spec` is
expected to be the in_spec of an exported program, i.e. the spec that
results from flattening `(args, kwargs)`.

We need this to provide consistent input ordering, such so that users can
pass in foo(a=a, b=b) OR foo(b=b, a=a) and receive the same result.
      z>Ran into a kwarg keyword mismatch: Got the following keywords z but expected )	typetuplenum_childrenchilddictsetcontext
ValueErrorlist)r   r   kwargs_specreordered_kwargskws        R/home/james-whalen/.local/lib/python3.13/site-packages/torch/export/_tree_utils.pyreorder_kwargsr      s     99!!!**Q-Kt###
;3{2233**.{*;)<N;K^K^J_a
 	

 !!* "     spec1spec2equivalence_fnNc                 4   U" U R                   U R                  UR                   UR                  5      (       d  gU R                  UR                  :w  a  g[        U R	                  5       UR	                  5       5       H  u  p4[        X4U5      (       a  M    g   g)a  Customizable equivalence check for two TreeSpecs.

Arguments:
    spec1: The first TreeSpec to compare
    spec2: The second TreeSpec to compare
    equivalence_fn: A function to determine the equivalence of two
        TreeSpecs by examining their types and contexts. It will be called like:

            equivalence_fn(spec1.type, spec1.context, spec2.type, spec2.context)

        This function will be applied recursively to all children.

Returns:
    True if the two TreeSpecs are equivalent, False otherwise.
FT)r   r   r   zipchildrenis_equivalent)r   r   r   child_spec1child_spec2s        r   r"   r"   "   sy    ( %**emmUZZOO U///$'(8%..:J$K [~FF %L r   )collections.abcr   typingr   torch.utils._pytreer   r   r   strr   r   boolr"    r   r   <module>r+      s|    $  1S#X h 4S> 6 dTk7D4KI4OP 
	r   