
    Ǆg              
           d dl mZmZmZmZ d dlmZmZ deeef   dedeeef   fdZ	deded	eee
   eee
   egef   defd
Zy)    )AnyCallableDictOptional)ContextTreeSpecuser_kwargsspecreturnc                 V   |j                   t        u sJ |j                  dk(  sJ |j                  d   }|j                   t        u sJ t        |       t        |j                        k7  r$t        dt        |        d|j                         i }|j                  D ]
  }| |   ||<    |S )aX  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kwarg key mismatch: Got z but expected )	typetuplenum_childrenchildren_specsdictsetcontext
ValueErrorlist)r	   r
   kwargs_specreordered_kwargskws        `/home/mcse/projects/flask_80/flask-venv/lib/python3.12/site-packages/torch/export/_tree_utils.pyreorder_kwargsr      s     99!!!%%a(Kt###
;3{2233$%^K4G4G3HJ
 	

 !! /*2/     spec1spec2equivalence_fnc                 2    || j                   | j                  |j                   |j                        syt        | j                        t        |j                        k7  ryt	        | j                  |j                        D ]  \  }}t        |||      r y y)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   lenr   zipis_equivalent)r   r   r    child_spec1child_spec2s        r   r$   r$   !   s    ( %**emmUZZO 5 C(<(<$==$'(<(<e>R>R$S  [[+~F r   N)typingr   r   r   r   torch.utils._pytreer   r   strr   r   boolr$    r   r   <module>r,      s}    0 0 1S#X h 4S> 6 htngx~wOQUUV 
	r   