
    sh                     F   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJr  S SK	J
r
  S SK Jr  S SKJrJrJrJrJrJr  S SKJr  S SKJr  S SKJrJrJr  S S	KJr  S S
KJr  S SKJ r J!r!  S SK"J#r#J$r$  S SK%J&r&  \(       a
  S SK'r'S SK(J)r)  S SK*r*S SK+J,s  J-r.  S SK/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>  S SK?J@r@  S SKAJBrB  S SKJCrC  S SKDJErEJFrF  S SKGJHrH  S SKIJJrJ  S SKKJLrL  S SKMJNrN  SSKOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\  / SQr]\\*R                  R                  /\\L   4   r`\R                   " S S5      5       rb\R                   " S S5      5       rcS rdS \\e   S!\.R                  S"\\e   S#\.R                  S$\g4
S% jrh\*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  /rw\*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  R                  \*R                  R                  GR                   /	r\S@S& j5       r\S' 5       rS(\\*GR
                  GR                  \4   S$\\\*GR
                  GR                  \4   S)4   4S* jrSAS+ jrS,\\*GR
                  GR                  \4   S-\\*GR
                  GR                  \4   S.\\   4S/ jrS0\*R                  R                  S1\SS$\\*R                  R                  \S4   4S2 jrS0\*R                  R                  4S3 jrS0\*R                  R                  S4\\c   4S5 jrS,\\*GR
                  GR                  \4   S-\\*GR
                  GR                  \4   S.\\   S6\g4S7 jr " S8 S95      rS: r SBS0\*R                  R                  S;S<S$S=4S> jjrS? rg)C    N)
namedtuple)Iterator)contextmanager)AnyCallablefinalOptionalTYPE_CHECKINGUnion)autograd_not_implemented)FakeScriptObject)_deregister_op_impl_is_op_registered_to_fake_ruleregister_op_impl)FakeTensorMode)#first_call_function_nn_module_stack)_PyTreeCodeGen_PyTreeInfo)immutable_dictimmutable_list)insert_deferred_runtime_asserts)ValueRanges)_collect_all_valid_cia_ops_collect_and_set_constant_attrs_collect_param_buffer_metadata_detect_fake_mode_from_gm_fakify_params_buffers_get_decomp_for_cia_is_preservable_cia_op_name_hoo_subgraph_placeholders7_override_graph_signature_for_temp_registered_constants/_overwrite_signature_for_non_persistent_buffers)_populate_param_buffer_metadata_to_new_gm_register_constants_as_buffers_rename_without_collisions_special_op_to_preserve_ciaplaceholder_naming_pass)Verifierdetect_fake_modeunset_fake_temporarily)is_equivalentreorder_kwargsCustomDecompTable)compatibility)
PassResult)PassManager   )ArgumentSpecConstantArgumentCustomObjArgumentExportGraphSignature	InputKind	InputSpec
OutputKind
OutputSpecSymBoolArgumentSymFloatArgumentSymIntArgumentTensorArgumentTokenArgument)ExportedProgramModuleCallEntryModuleCallSignaturedefault_decompositionsc                       \ rS rSr% \\   \S'   \\   \S'   \R                  \S'   \R                  \S'   Sr	\
\\      \S'   S rS	rg)
rD   ^   inputsoutputsin_specout_specNforward_arg_namesc                    U R                    H0  nUR                  UR                  :X  d  M  UR                  Ul        M2     U R                   H0  nUR                  UR                  :X  d  M  UR                  Ul        M2     g N)rH   namerI   )selforiginal_nodenew_nodeios        q/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/torch/export/exported_program.pyreplace_all_uses_with)ModuleCallSignature.replace_all_uses_withf   sZ    Avv+++!  Avv+++!      )__name__
__module____qualname____firstlineno__listr5   __annotations__pytreeTreeSpecrL   r	   strrV   __static_attributes__rY   rX   rU   rD   rD   ^   sE    ,__oo-1xS	*1'rX   rD   c                   4    \ rS rSr% \\S'   Sr\\   \S'   Sr	g)rC   o   fqnN	signaturerY   )
rZ   r[   r\   r]   rb   r_   rg   r	   rD   rc   rY   rX   rU   rC   rC   o   s    	H/3Ix+,3rX   rC   c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc                  ^   > [        5          T" U 0 UD6sS S S 5        $ ! , (       d  f       g = frN   r+   )argskwargsfns     rU   wrapper/_disable_prexisiting_fake_mode.<locals>.wrapperv   s"    #%t&v& &%%s   
,)	functoolswraps)rl   rm   s   ` rU   _disable_prexisiting_fake_moderq   u   s%    __R' ' NrX   
spec1_typespec1_context
spec2_typespec2_contextreturnc                 .   U b  Uc  XL =(       a    X:H  $ [        U [        [        45      (       a  [        U[        [        45      (       a  X:H  $ [        U [        [        45      (       a  [        U[        [        45      (       a  X:H  $ XL =(       a    X:H  $ )z]Treat containers and their immutable variants as the same type. Otherwise
compare as normal.
)
issubclassdictr   r^   r   )rr   rs   rt   ru   s       rU   _fx_collection_equivalence_fnrz   ~   s     Z/'JM,JJ*t^455*T>*; ; --*t^455*T>*; ; --#F(FFrX   c           	   #     #    0 n[        5       nU R                  5        GH  u  pEUR                  R                  5       X$'   UR	                  U5        [
         H3  nXdR                  ;  d  M  UR                  U5      " [        USS95        M5     [        U5      n[        R                  R                  R                  UR                  ;   a/  UR                  [        R                  R                  R                  	 U(       a9  UR                  [        R                  R                  R                  5      " U5        S n[        U5      (       d$  [        U5      " [        R                   " UUS95        ["         H+  n	XR                  ;  d  M  UR                  U	5      " U5        M-     GM      S v   U H_  n
U
R                  R%                  5         U
R                  R'                  X*   5        U
R(                  R%                  5         [+        U
5        Ma     g ! U H_  n
U
R                  R%                  5         U
R                  R'                  X*   5        U
R(                  R%                  5         [+        U
5        Ma     f = f7f)NT)deferred_errorc                 \    US   nUS	 U    U" U0 UD6sS S S 5        $ ! , (       d  f       g = f)Noriginal_callablerY   )fake_tensor_modeoprj   rk   orig_cia_callables        rU   $_force_dispatch_to_orig_cia_callableQ_override_composite_implicit_decomp.<locals>._force_dispatch_to_orig_cia_callable   s3     &': ;*+!($9&9 "!!s   
+)r~   )setitems
py_kernelscopyadd(_AUTOGRAD_ALIAS_BACKEND_KEYS_TO_OVERRIDEpy_implr   r   torch_CDispatchKeyCompositeImplicitAutogradr   r   ro   partial_BACKEND_KEYS_TO_OVERRIDEclearupdate_dispatch_cacher   )cia_ops_to_callablesafesaved_tablespatched_opsop_overloaddecomp_callableoverride_dispatch_keyr   r   keyr   s              rU   #_override_composite_implicit_decompr      s      L%K(;(A(A(C$$/$:$:$?$?$A!$%M!$,B,BB##$9:,[N &N 0<8899[=S=SS&&uxx';';'U'UV 4 4 N NO	: .k::[)!!8&7 -C000  ##C():;# -[ )D@$BMM!MM  !12$$&#	 +BMM!MM  !12$$&#	 s-   A&J,DJ J-H 1A&JA'I>>Jc               #   $  #    [        [        R                  R                  R                  R
                  [        [        R                  R                  R                  R                  [        0SS9   S v   S S S 5        g ! , (       d  f       g = f7f)NF)r   )r   r   opsatentodtype_layoutr&   dtyperY   rX   rU   !_override_decomp_aten_to_variantsr     sa     
 
-IINN**,GIINN##%@	
 
 	
 
 
s   A/B1A?6	B?
B	Bdecomp_table.c                 ^   [        [        5       5      n0 n[        U R                  5       5       Hh  nX1;   a  X   X#'   UR	                  U5        X	 M#  [        U5      (       d  M5  UR                  5       nUR                  S5      (       a   S5       eX   X#'   Mj     U H  n[        X%'   M     X 4$ )Nr   zThis should be a custom op)	r   r   r^   keysremover   rO   
startswithr&   )r   all_preservable_cia_opsr   r   op_nameks         rU   ,_split_decomp_table_to_cia_and_python_decompr   '  s     ""<">?<$$&'$ (&2&6##**2.  $B''ggiG))&11O3OO1&2&6#9 (@ %!< % ,,rX   c                      [        5       $ )z
This is the default decomposition table which contains decomposition of
all ATEN operators to core aten opset. Use this API together with
:func:`run_decompositions()`
r/   rY   rX   rU   rE   rE   S  s     rX   cia_to_decomppython_decomp_tablejoint_loss_indexc                   SSK Jn  SSKJn  SSKJnJnJn	Jn
J	nJ
n  SSKJn  S nU" X5      (       Gd  U R                  5       n0 [        UR                  SS95      E[        UR!                  SS95      EnSS	KJn  U" U5        0 [        UR                  SS95      E[        UR!                  SS95      En['        U R(                  5      nUc  [+        U" 5       S
S9nUR,                  nUR.                  R0                  R2                  R4                  nUR6                  [8        [:        4;  a  [<        R>                  " [:        S U/5      n[A        [C        UURD                  U5      5      UR.                  l        URG                  5         [I        U RJ                  U RL                  U5        [O        XRP                  U RJ                  RR                  5      n[U        UU5      n[W        U5      nSSK,J-nJ.n  / nUR.                  R^                   H  nUR`                  S:X  d  M  [c        URd                  S   [f        5      (       ay  S nURd                  S   Rh                  c'  U RL                  URd                  S   Rj                     nO#URd                  S   Rh                  Rl                  nURo                  U5        M  URo                  URd                  S   5        M     U   [q        5          [s        U5         U" U Rt                  5         [<        Rv                  " UURD                  5      nU" U/ US   QUS   Ry                  5       Q70 U5       u  nn n!n"n#U" UU U!UU"USSUS9	n$U$RL                  R{                  5        V%V&s0 s H#  u  n%n&U%[c        U&[|        5      (       a  U#U&   OU&_M%     sn&n%U$l&        U$R~                  n'U$R                  n([        U(U5      n([        UU'U(5        [        U RJ                  U(5      n(U" U'U(U"5      n)[        U'U(UU U!UU)5        S S S 5        S S S 5        S S S 5        S S S 5        S S S 5        U
" W'5        U" U'5        U" U'W(5        [        U'U(5      u  n'n(UR{                  5        H  u  n*n+U*U;  d  M  U+U RP                  U*'   M     UR{                  5        Hv  u  n*n+U*U RP                  ;  a+  [c        U+[        R                  R                  5      (       a   eU*U RP                  ;   d  MS  U*U;  d  M[  U RP                  R                  U*5        Mx     U'U(U RP                  4$ U R(                  R.                  R^                   Vs/ s H  nUR`                  S:X  d  M  UPM     n,nU, Vs/ s H  nURd                  S   PM     n-nU R(                  R!                  5        V*V.s/ s H  u  n*n.U*PM
     n/n*n.U/ H  n*[        U R(                  U*5        M     [        U-5      nUc  [        R                  " 5       OUnU(       a  [        R                  OUn0U	" 5          U   [s        U5         U0" 5          U" U R(                  U-UUb  S
OSUb  UOS S9u  n'n1U'R.                  R                  5         S S S 5        S S S 5        S S S 5        S S S 5        S n2W'R.                  R^                   Vs/ s H  nUR`                  S:X  d  M  UPM     n3n[9        U'R.                  R^                  5      S   R                  S   n4[        U35      [        U,5      :X  d   e[        U,U35       H  u  n5n6U5Rj                  =U6l5        U6lR        M      U3 V7s0 s H  n7U7Rj                  U7Rj                  _M     n8n7U'R.                  R^                   H;  nUR`                  S:X  a  M  [        U8URj                  URj                  5      Ul5        M=     [        U'5        SSKUJVn9JWn:  SSKXJYn;  [        R                  R                  R                  (       dW  Sn<[        U'5      n=U=bG  U:" U'[        R                  " U9U<S95         [        U'U=S[        U'R.                  5       3S
S9  S S S 5        U'RG                  5         [        U;" U'5      5       H>  u  n>n*[c        U4U>   [        R                  R                  5      (       d  M4  U*U4U>   l5        M@     [        U RJ                  R                  5       V>V?s0 s HK  u  n>n?[c        U?R                  [        5      (       a  M'  U?R                  Rj                  U3U>   Rj                  _MM     n@n>n?[        U RJ                  R                  5       V>V?s/ s HF  u  n>n?[        U?R                  U2" U?R                  U3U>   5      U?R                  U?R                  5      PMH     nAn>n?/ nB[        W1R                  5       V>V*s0 s H	  u  n>n*U*U>_M     nCn>n*[9        U1R                  R                  5       5      nDUDU4S [        UD5        Vs/ s H  nURj                  PM     sn:X  d   eU1R                  R{                  5        H  u  nEnFWCUF   n>U RJ                  R                  U>   nGUGR                  [        R                  [        R                  4;   d   eWGR                  [        R                  :X  a  [        R                  O[        R                  nHWGR                  [        R                  :X  a  WGR                  OWGR                  Rj                  nIWBRo                  [        WH[        WES9UIS95        M     [        U RJ                  R                  5       H  u  n>n?WBRo                  [        U>U:X  a  [        R                  OU?R                  U2" U?R                  U4[        WD5      U>-      5      W@R                  U?R                  U?R                  5      5      5        M     UGb  U1R                  c   eU1R                  R                  nJ[        U1R                  5      [        U RJ                  R                  5      :X  d   e[        U RJ                  R                  5       V>V?s0 s H7  u  n>n?[c        U?R                  [        5      (       d  M'  U1R                  U>   U?_M9     nKn>n?[        U4[        WB5      S  5       H  u  n>nWJURj                     nLWKUL   n?U?R                  [        R                  :X  a  [        R                  nMU?R                  nIOIU?R                  [        R                  :X  a  [        R                  nMWLnIO[        SU?R                   35      eWBRo                  [        WM[        URj                  S9WI5      5        M     [        U35      [        U,5      :X  d   e[        WAWBS9n([        U,U35       H  u  nNnO[c        UNRd                  S   [        GR                   5      (       d  WNRd                  S   WORd                  S'   WOR                  U(GR                  ;   d  WOR                  U(GR                  ;   d  M  WNRd                  R{                  5        H  u  nPnQUQWORd                  UP'   M     M     U'U(U RP                  4$ s  sn&n%f ! , (       d  f       G
N= f! , (       d  f       G
N= f! , (       d  f       G
N= f! , (       d  f       G
N= f! , (       d  f       G
N= fs  snf s  snf s  sn.n*f ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= fs  snf s  sn7f ! , (       d  f       GN= fs  sn?n>f s  sn?n>f s  sn*n>f s  snf s  sn?n>f )Nr   )_materialize_and_lift_constants)aot_export_module)2_disable_custom_triton_op_functional_decomposition_export_to_aten_ir_ignore_backend_decomps_verify_nn_module_stack_verify_placeholder_names_verify_stack_trace)ShapeEnvc                 H    US L=(       d    U R                   R                  S L$ rN   )graph_signaturebackward_signature)epr   s     rU   _is_joint_ir_decompO_decompose_and_get_gm_with_new_signature_constants.<locals>._is_joint_ir_decompp  s)    D( A!!44D@	
rX   F)remove_duplicate)!unwrap_tensor_subclass_parametersT)	shape_envexport)&_enable_graph_inputs_of_type_nn_module_fakify_script_objectsplaceholdervalr4   )r   _check_autograd_state_prettify_placeholder_namesdecompose_custom_triton_ops)decompositionstrace_jointoutput_loss_indexc                    [        U [        5      (       a  U $ [        U [        5      (       a  [        UR                  S9$ [        U [        5      (       a  [	        UR                  S9$ [        U [
        5      (       a  [        UR                  S9$ [        U [        5      (       a  [        UR                  S9$ [        S[        U 5       35      e)NrO   zType of old_arg not supported: )	
isinstancer6   r@   rO   r?   r>   r=   RuntimeErrortype)old_argnew_phs     rU   
update_argF_decompose_and_get_gm_with_new_signature_constants.<locals>.update_argb  s    g/00N00!v{{3300!v{{33!122#5511"44<T']OLMMrX   )_node_metadata_hook_set_node_metadata_hook)_graph_output_nameszUFile "torch/fx/passes/runtime_assert.py", line 24, in insert_deferred_runtime_asserts)stack_tracezexported program: )r   r   )kindargtargetzUnknown input kind: input_specsoutput_specs)(torch._export.passes.lift_constants_passr   torch._functorch.aot_autogradr   torch.export._tracer   r   r   r   r   r   %torch.fx.experimental.symbolic_shapesr   modulery   named_parametersnamed_buffers7torch._functorch._aot_autograd.subclass_parametrizationr   r   graph_moduler   	_out_specgraph_codegenpytree_info	orig_argsr   r^   tupler`   ra   r   r   _in_spec	recompiler   r   	constantsr$   
state_dictnon_persistent_buffersr   r   torch._export.non_strict_utilsr   r   nodesr   r   metar7   fake_valrO   real_objappendr   r   example_inputstree_unflattenvaluesr   r   gmsigr!   r#   r"   r'   !_remove_unneccessary_copy_op_passr   nn	Parameterpopdelattrr*   
contextlibnullcontexteliminate_dead_coderj   lenzipr   r%   r    (torch._export.passes._node_metadata_hookr   r   4torch._functorch._aot_autograd.input_output_analysisr   _dynamoconfigdo_not_emit_runtime_asserts_get_shape_envro   r   r   r   	enumeratefxNoder   r   r6   r:   r   
persistentuser_inputsuser_inputs_to_mutater   r9   
USER_INPUTBUFFERr;   BUFFER_MUTATIONUSER_INPUT_MUTATIONr<   r@   r   LOSS_OUTPUTgetr   gradients_to_user_inputs	PARAMETERGRADIENT_TO_PARAMETERGRADIENT_TO_USER_INPUTAssertionErrorr8   Tensorinputs_to_parametersinputs_to_buffers)Rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   modwrapped_params_buffersr   unwrapped_params_buffers	fake_moderK   orig_arg_namestemp_registered_constantsfake_params_buffersparams_buffers_to_node_metar   r   retracing_argsnodereal_script_objretracing_args_unwrappedpatched_modnew_fake_argsnew_fake_kwargsnew_fake_constant_attrsmap_fake_to_realaten_export_artifactrf   objr   new_graph_signaturer   rO   pold_placeholders	fake_args_buffers_to_remove#custom_triton_ops_decomposition_ctxr   r   new_placeholdersnew_outputsold_phr   phname_mapr   r   r   r   r   rS   specold_new_placeholder_mapr   r   user_inputs_indexmutation_namesoutput_name
input_name
input_specoutput_kindr   	gradientsspecssourcer   old_noderR   r   vsR                                                                                     rU   2_decompose_and_get_gm_with_new_signature_constantsrR  \  s    Y?  ?
 r44iik"
3'''?@"
3$$e$<="

	
 	*#.$
3'''?@$
3$$e$<=$
  .boo>	&DII ==++77AA ==u-udXJ?H+
		 	
 	((:(:BLL#N %C 2 2 I I%
!
 5YD&DS&I#
	

 IIOODww-'dii.0ABB&*Oyy'008*,,,tyy7G7L7L*M*.))E*:*C*C*L*L"))/:"))$))E*:; $ ,.0S1
1
 (.'<'<($ (-a0-a0779 ' '9!#'+!4*/050K
($& %9$B$B$H$H$J2 %KS %c+;<< )- !
 %K2$. *,,&:&>&>#
 L+-F $ :/5H
 'V&&(;'# <+-D	 ('!#'{
1
. b 	 #B!"&9:"C##
 0557GD!11&'d# 8 .335GD!2==(%a););<<<<r}}$77MM%%d+ 6 &55 ..444=8P4   /??.>d5!.>I?-/__-J-J-LM-L'$-LM!& " !+I,5,=
&&(9I ' 	? (
 
!	"I/R0*,/OO. 0 <%$4$@ d
O 	$$& -0I	" N *,T477m;STrxx~~&r*//2K  C(8$9999.0@A&,kk1fm B ,<<+;R +;H<77m#.xDIIN	  $B' Y==;;1 	 #2&	 (I%%&9{S 0()LRXX)V(WX	 LLN0454k!nehhmm44"&KN 6 !!3!3!?!?@@GAt$(($45 	0'*///@   !!3!3!?!?@ AGAt 	IItxx!1!!45KKOO		
 A   L 1:/:U:U0VW0VWQq0VW/??DDFGNK@U#nBU4VW4VDdii4VWWWW#2#H#H#N#N#PZj)''33A6
9#7#79I9I"JJJJ )"2"22 &&// 	 )"2"22 $$ 	
 	 "4	
 $Q. R//<<=4*+/?*?
&&TYY488[^1Dq1H%IJ'++DKKE	
 > #11===#66OO	?../3r7I7I7U7U3VVVV %R%7%7%C%CD
D4$((N3 1O''*D0D 	 

 !S->-@!ABGAttyy)F=DyyI///!77i222!88$';DII;%GHH"		2 C&  C(8$9999.l ""24DE((--.==#+==#7HMM%  OO2GGG"5"G"GG ++-1#$a  . F "BMM11g29 
 
1
 1
.. I^ @M -,0 0II	"	": U =0 $" XWJ
s5  {*{6z4	Az"	2z*z
+A+zz"	z4&{.{{**{*6{/.{4$|0'|3|;<{:	7|?||02}
}!}3#}#&}(}A}$}*}0&&}5}5
z
zz"	"
z1,z44
{>{
{	{
{':
|	|
||
|-	(|00
|?
}r   r9  c                    U R                  UR                  5       5         U R                  R                   GH  nUR                  S:X  d  M  [
        R                  " UR                  5      u  p4U H  n[        U[        R                  R                  5      (       d  M.  UR                  UR                  ;   d  MJ  UR                  S:X  d  M\  UR                  [        R                  R                   R"                  R$                  :X  d  M  UR'                  UR                  S   5        U R                  R)                  U5        M     GM     U R+                  5         SSS5        X4$ ! , (       d  f       X4$ = f)zI
Removes redundant copy_ node that was introduced due to mutated buffer.
outputcall_functionr4   N)_set_replace_hookget_replace_hookr   r   r   r`   tree_flattenrj   r   r   r  r  rO   buffers_to_mutater   r   r   r   defaultrV   
erase_noder   )r   r9  r/  rj   r=  outs         rU   r  r    s	    
		1BBD	EHHNNDww(" --dii8C"366HH(;(M(MM  FFo5 #

eiinn.A.A.I.I I55chhqkBHH//4   # 	 
F  ""! 
F	E  ""s+   )E(AE(E(;E(:E(AE((
E8c           	         U R                  UR                  5       5         U R                  5        GH!  n[        U[        R
                  R                  5      (       d  M/  0 n0 n[        UR                  R                  5       H  nUR                  S:X  a  UR                  [        R                  :X  a  UR                  u  pxXG    SU 3n	X;   af  UR                  XY   5        U H0  n
U
R                   c  M  U
R                   R                  XeU	   5        M2     UR                  R#                  U5        M  XeU	'   XU'   M  UR$                  XF'   M     GM$     S S S 5        g ! , (       d  f       g = f)NrU  .)rV  rW  modulesr   r   r  GraphModuler^   r   r   r   r   operatorgetitemrj   rV   rg   r[  rO   )r   r   module_call_graphr   node_idgetitemsr/  rO  idxnew_identrys              rU    _common_getitem_elimination_passri  '  s#    
		o>>@	AjjlFfehh&:&:;;02G13HV\\//077o-$++AQAQ2Q"&))KF '0#7F)2283CD%6E$: % E E$(6*:!" &7
 //5+/((.$(IIGM! 1 # 
B	A	As   CE 7A E  
E.old_module_call_graphc                    [         R                  " U5      n0 nU R                  R                   HC  nUR                  R                  S/ 5      =n(       d  M(  UR                  X5S   R                  '   ME     U H`  nUR                  nUc  M  / UR                  QUR                  Q H.  nUR                  UR                  UR                  5      Ul        M0     Mb     U$ )N	from_noder   )
r   deepcopyr   r   r   r  rO   rg   rH   rI   )	r   rj  new_module_call_graph
provenancer/  historyrh  rg   xs	            rU   _get_updated_module_call_graphrr  D  s     !MM*?@ "$JiimmK4474+/99Jr{''( 
 'OO	89##8i&7&78A^^AFFAFF3AF 9	 ' ! rX   r   c                :   [        U UUUUS9u  nnn[        UU R                  5      nUR                  R	                  U R
                  R                  5        [        UU R                  5      n	[        UUR                  UUU	UU R                  U R                  S9n
U
$ )Nr   r   r   r   )rootr   r   r   range_constraintsrc  r   r   )rR  rr  rc  r   r   r   _get_updated_range_constraintsrv  rB   r   r   r   )r   r   r   r   r   r   r9  r   rn  new_range_constraintsexported_programs              rU   _decompose_exported_programrz  \  s     	;
#/)$?		
 ;

 GGNN2??''(:


 'hh+//((,,	 rX   c                      \ rS rSrSr  SFSS.S\\R                  R                  \	\
\4   4   S\R                  R                  S\S\	\
\\R                  \R                  R                   4   4   S	S
S\\   S\\\\S4   \	\
\4   4      S\\	\
\\R                  \\R,                  R.                  4   4      S\\\\         4S jjjr\\" SS9S 5       5       r\R<                  \" SS9S 5       5       r\\" SS9S 5       5       r\R<                  \" SS9S 5       5       r\\" SS9S 5       5       r \ R<                  \" SS9S 5       5       r \\" SS9S 5       5       r!\!R<                  \" SS9S 5       5       r!\" SS9S\"\R                  R                      4S j5       r#\" SS9S\"\\
\R                  R                   4      4S j5       r$\" SS9S\"\R                     4S j5       r%\" SS9S\"\\
\R                  4      4S j5       r&\\" SS9S  5       5       r'\'R<                  \" SS9S! 5       5       r'\\" SS9S" 5       5       r(\(R<                  \" SS9S# 5       5       r(\\" SS9S$ 5       5       r)\)R<                  \" SS9S% 5       5       r)\\" SS9S& 5       5       r*\*R<                  \" SS9S' 5       5       r*\\" SS9S\4S( j5       5       r+\+R<                  \" SS9S) 5       5       r+\\" SS9S\
4S* j5       5       r,\,R<                  \" SS9S+ 5       5       r,\\" SS9S, 5       5       r-\-R<                  \" SS9S- 5       5       r-\\" SS9S. 5       5       r.\.R<                  \" SS9S/ 5       5       r.\\" SS9S0 5       5       r/\/R<                  \" SS9S1 5       5       r/S2 r0S3\S4\S\4S5 jr1S3\S4\S\4S6 jr2S7 r3S\
4S8 jr4S\R                  R                  4S9 jr5S: r6\7  SGS;\\	\Rp                  Rr                  \:4      S<\;SS 4S= jj5       r<S>\=SS 4S? jr>S@ r?\" SS9SA 5       r@\ASB 5       rBSSSSC. SHSD jjrCSErDg)IrB   i  a  
Package of a program from :func:`export`. It contains
an :class:`torch.fx.Graph` that represents Tensor computation, a state_dict containing
tensor values of all lifted parameters and buffers, and various metadata.

You can call an ExportedProgram like the original callable traced by
:func:`export` with the same calling convention.

To perform transformations on the graph, use ``.module`` property to access
an :class:`torch.fx.GraphModule`. You can then use
`FX transformation <https://pytorch.org/docs/stable/fx.html#writing-transformations>`_
to rewrite the graph. Afterwards, you can simply use :func:`export`
again to construct a correct ExportedProgram.
N)	verifiersru  r   r   r   rv  dict[sympy.Symbol, Any]rc  r   .r   r|  c	                >   [         R                  R                  R                  5       Ul        [        X5      U l        [        U[         R                  R                  5      (       a/  U R                  R                  R                  UR                  5        [        U R                  X65        X0l        X@l        XPl        Uc   eX`l        Xpl        U=(       d    0 U l        U	=(       d    [$        /n	['        S U	 5       5      (       d   eXl        U R+                  5         g )Nc              3   B   #    U  H  n[        U[        5      v   M     g 7frN   )rx   r(   ).0rQ  s     rU   	<genexpr>+ExportedProgram.__init__.<locals>.<genexpr>  s     >Iq:a**Is   )r   r  r   CodeGenr   _create_graph_module_for_export_graph_moduler   r`  r   r   ri  _graph_signature_state_dict_range_constraints_module_call_graph_example_inputs
_constantsr(   all
_verifiersvalidate)
rP   ru  r   r   r   rv  rc  r   r   r|  s
             rU   __init__ExportedProgram.__init__  s      //1<TIdEHH0011##**4995(	
 7F+5CT ,,,9J-#/r+(	>I>>>>>#rX   F)is_backward_compatiblec                     U R                   $ rN   )r  rP   s    rU   r   ExportedProgram.graph_module  s     !!!rX   c                     [        S5      e)Nz7Unable to set ExportedProgram's graph_module attribute.r   rP   values     rU   r   r    s     TUUrX   c                 .    U R                   R                  $ rN   )r   r   r  s    rU   r   ExportedProgram.graph  s       &&&rX   c                     [        S5      e)Nz0Unable to set ExportedProgram's graph attribute.r  r  s     rU   r   r    s     MNNrX   c                     U R                   $ rN   )r  r  s    rU   r   ExportedProgram.graph_signature  s     $$$rX   c                     [        S5      e)Nz:Unable to set ExportedProgram's graph_signature attribute.r  r  s     rU   r   r    s     WXXrX   c                     U R                   $ rN   )r  r  s    rU   r   ExportedProgram.state_dict  s     rX   c                     [        S5      e)Nz5Unable to set ExportedProgram's state_dict attribute.r  r  s     rU   r   r    s     RSSrX   rv   c              #   F   #    U R                  5        H	  u  pUv   M     g7f)z8
Returns an iterator over original module's parameters.
N)r   )rP   r=  params      rU   
parametersExportedProgram.parameters  s!     
 --/HAK 0   !c              #   j   #    U R                   R                   H  nXR                  U   4v   M     g7f)z
Returns an iterator over original module parameters, yielding
both the name of the parameter as well as the parameter itself.
N)r   r  r   )rP   
param_names     rU   r    ExportedProgram.named_parameters  s/      ..99Jooj999 :s   13c              #   F   #    U R                  5        H	  u  pUv   M     g7f)z3
Returns an iterator over original module buffers.
N)r   )rP   r=  bufs      rU   buffersExportedProgram.buffers   s!     
 ((*FAI +r  c              #      #    [        U R                  R                  5      nU R                  R                   H.  nX!;   a  X R                  U   4v   M  X R
                  U   4v   M0     g7f)zv
Returns an iterator over original module buffers, yielding
both the name of the buffer as well as the buffer itself.
N)r   r   r   r  r   r   )rP   r   buffer_names      rU   r   ExportedProgram.named_buffers  s^      "%T%9%9%P%P!Q//77K4!>>+#>>>!??;#???	 8s   A)A+c                     U R                   $ rN   )r  r  s    rU   rv  !ExportedProgram.range_constraints       &&&rX   c                     [        S5      e)Nz<Unable to set ExportedProgram's range_constraints attribute.r  r  s     rU   rv  r         J
 	
rX   c                     U R                   $ rN   )r  r  s    rU   rc  !ExportedProgram.module_call_graph!  r  rX   c                     [        S5      e)Nz<Unable to set ExportedProgram's module_call_graph attribute.r  r  s     rU   rc  r  &  r  rX   c                     U R                   $ rN   )r  r  s    rU   r   ExportedProgram.example_inputs-  s     ###rX   c                 0   Uc  Xl         g [        U[        5      (       a?  [        U5      S:X  a0  [        US   [        5      (       a  [        US   [        5      (       d  [        S5      eUu  p#SSKJn  U" X#U R                  R                  5        Xl         g )N   r   r4   zqExample inputs should be a tuple containing example arguments (as a tuple), and example kwargs (as a dictionary).)_check_inputs_match)
r  r   r   r
  ry   
ValueError_unliftr  	call_specrJ   )rP   r  rj   rk   r  s        rU   r   r  2  s    
 =#(  ue$$E
a58U++58T**B 
 0D$..*@*@A$rX   c                 .   [        SSS/5      n[        U R                  5      S:X  a  U" S S S9$ U R                  S   R                  S:X  d   eU" U R                  S   R                  R
                  U R                  S   R                  R                  S9$ )NCallSpecrJ   rK   r   )rJ   rK    )r   r
  rc  rf   rg   rJ   rK   )rP   r  s     rU   r  ExportedProgram.call_specM  s     j9j*ABt%%&!+D488%%a(,,222**1-77??++A.88AA
 	
rX   c                     [        S5      e)Nz4Unable to set ExportedProgram's call_spec attribute.r  r  s     rU   r  r  Z       QRRrX   c                      U R                   S   $ Nr   r  r  s    rU   verifierExportedProgram.verifier_  s     q!!rX   c                     [        S5      e)Nz3Unable to set ExportedProgram's verifier attribute.r  r  s     rU   r  r  d  s     PQQrX   c                 R    U R                   c   eU R                   S   R                  $ r  )r  dialectr  s    rU   r  ExportedProgram.dialecti  s)     ***q!)))rX   c                     [        S5      e)Nz2Unable to set ExportedProgram's dialect attribute.r  r  s     rU   r  r  o  s     OPPrX   c                     U R                   $ rN   r  r  s    rU   r|  ExportedProgram.verifierst       rX   c                     [        S5      e)Nz4Unable to set ExportedProgram's verifiers attribute.r  r  s     rU   r|  r  y  r  rX   c                     U R                   $ rN   r  r  s    rU   tensor_constants ExportedProgram.tensor_constants~  r  rX   c                     [        S5      e)Nz;Unable to set ExportedProgram's tensor_constants attribute.r  r  s     rU   r  r    s     I
 	
rX   c                     U R                   $ rN   r  r  s    rU   r   ExportedProgram.constants  r  rX   c                     [        S5      e)Nz4Unable to set ExportedProgram's constants attribute.r  r  s     rU   r   r    r  rX   c                     U R                   R                  nUb  [        X#5      n[        R                  " X45      u  pEU R                  U5        [        S U 5       5      nXe4$ )af  Flatten args, kwargs using pytree, then, check specs.

Args:
    args: List[Any] original args passed to __call__
    kwargs: Dict[str, Any] original kwargs passed to __call

Returns:
    A tuple of (flat_args, received_spec)
    flat_args is flattend args / kwargs
    received_spec is the pytree spec produced while flattening the
    tuple (args, kwargs)
c              3   *   #    U  H	  oS    v   M     g7f)r4   NrY   )r  rq  s     rU   r  <ExportedProgram._get_flat_args_with_check.<locals>.<genexpr>  s     <(;1A$(;s   )r  rJ   r.   r`   tree_flatten_with_path_check_input_constraintsr   )rP   rj   rk   rJ   flat_args_with_pathreceived_spec	flat_argss          rU   _get_flat_args_with_check)ExportedProgram._get_flat_args_with_check  sg     ..((#F4F-3-J-JN.
* 	%%&9:<(;<<	''rX   rj   rk   c                    U R                   R                  nU R                  X5      u  pEUb&  [        XS[        5      (       d  [        SU SU 35      e/ nU R                  R                   GH  nUR                  [        R                  :X  a  M$  UR                  [        R                  [        R                  4;   ac  UR                  SL a*  UR                  U R                  UR                      5        M  UR                  U R"                  UR                      5        M  UR                  [        R$                  [        R&                  4;   d  M  UR                  U R                  UR                      5        GM     [)        U5      nXd-   $ )a  Transform args, kwargs of __call__ to args for graph_module.

self.graph_module takes stuff from state dict as inputs.
The invariant is for ep: ExportedProgram is
ep(args, kwargs) ==
  ep.postprocess(ep.graph_module(ep.graph_module_flat_inputs(args, kwargs)))
z>Trying to flatten user inputs with exported input tree spec: 
z-
but actually got inputs with tree spec of: 
F)r  rJ   r  r-   rz   r  r   r   r   r9   r  r  r  r  r   r   r   r   CONSTANT_TENSOR
CUSTOM_OBJr   )rP   rj   rk   rJ   r  r  additional_inputsinput_s           rU   _graph_module_flat_inputs)ExportedProgram._graph_module_flat_inputs  s\    ..((#'#A#A$#O 	}$A(
 (
 Q) @ /#  **66F{{i222##  !  $$- &,,T^^FMM-JK%,,T__V]]-KL))$$!  "(()FG# 7$ ""34 !,,rX   c                     [        S5      e)Nz\Unable to call ExportedProgram directly. You should use `exported_program.module()` instead.r  )rP   rj   rk   s      rU   __call__ExportedProgram.__call__  s    B
 	
rX   c           	      r  ^ SSK Js  Jn  U R                  X#5      u  pVU R                  R
                  Gb  U R                  R                  nU R                  R                  n[        U5      [        U5      -   n	USU	 n
U R                  R                  nUb'  [        [        UR                  5       5      5      nUSU nXS n [        R                  " XR                  R
                  5      n U R                  R&                   Vs/ s H%  nUR(                  [*        R,                  :X  d  M#  UPM'     nn[/        U
5       H  u  nnU R                  R0                  U   mTR(                  [2        R4                  :X  a*  TR6                  c   eUU R8                  TR6                  '   Mg  TR(                  [2        R:                  :X  aC  TR6                  c   e[        U4S j[/        U5       5       5      nUU   R=                  U5        M  [?        STR(                   35      e   U$ U$ ! [          aD    [        R"                  " U5      u  pmUR%                  SU R                  R
                   SU 35      ef = fs  snf ! U R                  R&                   Vs/ s H%  nUR(                  [*        R,                  :X  d  M#  UPM'     Os  snf nn[/        U
5       H  u  nnU R                  R0                  U   mTR(                  [2        R4                  :X  a*  TR6                  c   eUU R8                  TR6                  '   Mg  TR(                  [2        R:                  :X  aC  TR6                  c   e[        U4S j[/        U5       5       5      nUU   R=                  U5        M  [?        STR(                   35      e   f = f)zProcess potential mutations to the input.

Because self.graph_module is functional, so mutations has to be written
back after execution of graph_module.
r   Nz@Trying to flatten user outputs with exported output tree spec: 
z.
but actually got outputs with tree spec of: 
c              3   x   >#    U  H/  u  pUR                   R                  TR                  :X  d  M+  Uv   M1     g 7frN   )r   rO   r   )r  rS   rE  output_specs      rU   r  DExportedProgram._postprocess_graph_module_outputs.<locals>.<genexpr>  s2      %+A#xx}}0B0BB A+As   *:	:zUnexpected kind: ) torch._export.error_exporterrorr  r  rK   r   rY  r  r
  assertion_dep_tokennextiterr   r`   r   	ExceptionrX  InternalErrorr   r   r9   r  r  r   r;   r  r   r   r  copy_r"  )rP   resr   orig_kwargsr  r  r=  buffer_mutationuser_input_mutationnum_mutatedmutated_valuesr  assertion_dep_token_indexr  rE  r  rS   r  indexr  s                      @rU   !_postprocess_graph_module_outputs1ExportedProgram._postprocess_graph_module_outputs  st    	,+55iM	>>""."22DDO"&"6"6"L"Lo.5H1IIK +.N #'"6"6"J"J".,06I6N6N6P1Q,R)445l#CU++C1H1HI !% 4 4 @ @ @yyI$8$88  @  
 !*. 9HAu"&"6"6"C"CA"FK"'':+E+EE*11===>C(:(:;$))Z-K-KK*11=== $ %+4[+A% !
 "%(..u5,/@AQAQ@R-STT !: 
s
;  #)#6#6s#; ))W~~../ 0E$o'  $ 4 4 @ @ @yyI$8$88  @ 
 !*. 9HAu"&"6"6"C"CA"FK"'':+E+EE*11===>C(:(:;$))Z-K-KK*11=== $ %+4[+A% !
 "%(..u5,/@AQAQ@R-STT !:s8   *H% "I6,I6%AI33I; ;N6"K:K C6N6c                     U R                   R                  SSS9R                  SS5      nSU SU R                   SU R                   S3nU$ )NF)print_outputcolored
z
    zExportedProgram:
    z
Graph signature: z
Range constraints: )r   print_readablereplacer   rv  )rP   r   strings      rU   __str__ExportedProgram.__str__  sp    ((77 8 

'$
! 	. !  $ 4 45 6""&"8"8!9= 	 rX   c                     SSK Jn  U" U 5      nSS[        4S jjnSS[        4S jjn[        R                  " X25      Ul        [        R                  " XB5      Ul        U$ )zO
Returns a self contained GraphModule with all the parameters/buffers inlined.
r4   )&_unlift_exported_program_lifted_statesmodec                     [        S5      e)Nz%Calling train() is not supported yet.NotImplementedErrorrP   r  s     rU   _train&ExportedProgram.module.<locals>._train*  s    %&MNNrX   c                     [        S5      e)Nz$Calling eval() is not supported yet.r  r  s     rU   _eval%ExportedProgram.module.<locals>._eval-  s    %&LMMrX   T)r  r  booltypes
MethodTypetraineval)rP   r  r   r  r  s        rU   r   ExportedProgram.module"  sY     	D7=	Ot 	O	Nd 	N ''7&&u5rX   c                     [        S [        U R                  R                  5       5       [	        U R                  R                  5      5      $ )Nc              3   j   #    U  H)  u  pUR                   [        R                  :X  d  M%  Uv   M+     g 7frN   )r   r9   r  )r  rS   ss      rU   r  =ExportedProgram._num_lifted_params_buffers.<locals>.<genexpr>6  s-      HDA66Y111 Hs   $3	3)r  r  r  r   r
  r  s    rU   _num_lifted_params_buffers*ExportedProgram._num_lifted_params_buffers4  sC    %d&;&;&G&GH
 %%112
 	
rX   r   r   c                     Uc
  [        5       O
[        U5      n[        U[        5      (       a  UR	                  5       n[        U5      u  nn[        U UUSUS9$ )a  
Run a set of decompositions on the exported program and returns a new
exported program. By default we will run the Core ATen decompositions to
get operators in the
`Core ATen Operator Set <https://pytorch.org/docs/stable/torch.compiler_ir.html>`_.

For now, we do not decompose joint graphs.

Args:
    decomp_table:
     An optional argument that specifies decomp behaviour for Aten ops
     (1) If None, we decompose to core aten decompositions
     (2) If empty, we don't decompose any operator


Some examples:

If you don't want to decompose anything

.. code-block:: python

    ep = torch.export.export(model, ...)
    ep = ep.run_decompositions(decomp_table={})

If you want to get a core aten operator set except for certain operator, you can do following:

.. code-block:: python

    ep = torch.export.export(model, ...)
    decomp_table = torch.export.default_decompositions()
    decomp_table[your_op] = your_custom_decomp
    ep = ep.run_decompositions(decomp_table=decomp_table)
Nrt  )rE   ry   r   r0   materializer   rz  )rP   r   r   _decomp_tabler   r   s         rU   run_decompositions"ExportedProgram.run_decompositions>  sn    P )5(<"$$|BT 	 m%677)557M" 9G	
 +' 3!(C
 	
rX   passesc                 j   [        [        U5      5      nSSKJn  U" 5          U" U R                  5      nS S S 5        Wb  UR                  OU R                  nUc   eXPR                  L a  UR
                  (       d  U $ S[        S[        R                  R                  S[        4S jn[        UUR                  U" U R                  U5      U R                  [        UU R                  5      [         R"                  " U R$                  5      U R&                  U R(                  U R*                  S9	nUR                  R,                  R/                  U R                  R,                  5        UR                  R,                  R/                  UR                  R,                  5        U$ ! , (       d  f       GNu= f)Nr   )r   old_signaturenew_gmrv   c           	      &   / n[        UR                  R                  5       H  u  p4UR                  S:w  a    OU[	        U R
                  5      :  d   S5       eU R
                  U   n[        UR                  [        [        45      (       a  UR                  O$[        UR                  5      " UR                  5      nUR                  [        UR                  UUR                  UR                   5      5        M     [#        UR                  R                  5      S   nUR                  S:X  d   e/ n[        UR$                  S   5       H  u  p4U[	        U R&                  5      :  d   S5       eU R&                  U   n	[        U	R                  [        [        45      (       a  U	R                  O$[        U	R                  5      " UR                  5      nUR                  [)        U	R                  XiR                  5      5        M     [+        X(S9n
U
$ )z7
Update the graph signature's user_input/user_outputs.
r   z-Number of inputs changed after transformationr   rT  r   z.Number of outputs changed after transformationr   )r  r   r   r   r
  r   r   r   r6   r7   r   rO   r   r:   r   r   r  r^   rj   r   r<   r8   )r1  r2  new_input_specsrS   r/  old_input_specr   output_nodenew_output_specsold_output_specnew_signatures              rU   _get_updated_graph_signatureKExportedProgram._transform_do_not_use.<locals>._get_updated_graph_signature  s    !O$V\\%7%7877m+3!--  CBC  "/!:!:1!= "&**-=?P,Q  #&& n001$))<   &&&++&--&11	 90 v||11226K>>X---!$[%5%5a%893!..  DCD  #0"<"<Q"? "'++.>@Q-R  $'' o112499=  !''33S:P:PQ :  1+M ! rX   	ru  r   r   r   rv  rc  r   r   r|  )r3   r^   r   r   r   modifiedr8   r   r  r`  rB   r   r   r   rw  rv  r   rm  r  r   r   r|  r   r   )rP   r/  pmr   r  transformed_gmr:  transformed_eps           rU   _transform_do_not_use%ExportedProgram._transform_do_not_use  sf   f& 	@$&T&&'C '-0_))$BSBS)))...s||K7	!/7	!HH((7	! "7	!r ) &&8$$n <&& #mmD,C,CD..nnnn
  	##((//0A0A0F0FG##((//0@0@0E0EFi '&s   F##
F2c                 `   SSK Jn  U R                  R                   Vs/ s H  o3R                  S:X  d  M  UPM     nn[        X@R                  R                  5       VVs/ s H'  u  p5UR                  [        R                  :X  d  M%  UPM)     nnnU" XaU R                  5        g s  snf s  snnf )Nr   )"_check_input_constraints_for_graphr   )torch._export.utilsrD  r   r   r   r  r   r   r   r9   r  rv  )rP   r  rD  r:  placeholdersr&  input_placeholderss          rU   r  (ExportedProgram._check_input_constraints  s    J#'::#3#3M#3att}7L#3M L*>*>*J*JK
Kvv--- K 	 

 	+T5K5K	
 N
s   B%B% $B*B*c                 $    U R                  5         g rN   )	_validater  s    rU   r  ExportedProgram.validate  s    rX   c                     [        U R                  5      S:  d   S5       eU R                   H  nU" 5       R                  U 5        M     g )Nr   z0ExportedProgram must have at least one verifier.)r
  r|  check)rP   rQ  s     rU   rJ  ExportedProgram._validate  s@     !#	>=	>#ACIIdO  rX   )r   r   r|  c                "   [        UUR                  UUb  UOU R                  [        R                  " U R
                  5      [        R                  " U R                  5      U R                  Ub  UOU R                  Ub  US9	$ U R                  S9	$ )Nr<  )
rB   r   r   r   rm  rv  r  r   r   r|  )rP   r   r   r   r   r|  s         rU   _updateExportedProgram._update  s     $$+%/%;z"mmD,B,BC"mmD,C,CD..#,#8idnn#,#8i

 
	
 ?Cnn

 
	
rX   )r  r  r  r  r  r  r  r  )NN)NF)rv   rB   )ErZ   r[   r\   r]   __doc__r   r   r  Modulery   rb   r   r  Graphr8   r#  r  r^   rC   r	   r   r   r   ScriptObjectr   r(   r  propertyr1   r   setterr   r   r   r   r  r   r  r   rv  rc  r   r  r  r  r|  r  r   r  r  r  r  r  r   r(  rq   _opsOperatorBaser   r  r-  PassTyperA  r  r  r   rJ  rP  rc   rY   rX   rU   rB   rB     s   . LP % 59%EHHOOT#s(^34% xx~~% .	%
 eELL%((2D2D$DEEF% 5%  0% !uS#XS#X'F!GH% eELL*:EHH<Q<QQRRS
% Dh01%N %0" 1 " %0V 1 V %0' 1 ' \\%0O 1 O %0% 1 % %0Y 1 Y %0  1   %0T 1 T %0HUXX%7%78  1 %0:(5ehh6H6H1H+I"J : 1: %0%,,/  1 %0
@xc5<<.?(@A 
@ 1
@ %0' 1 ' %0
 1 

 %0' 1 ' %0
 1 

 %0$ 1 $ %0% 1 %2 %0	
 1 	
 %0S 1 S %0"# " 1 " __%0R 1 R %0* * 1 * ^^%0Q 1 Q %0 1  %0S 1 S %0 1  %0
 1 

 %0 1  %0S 1 S(.,-c ,-3 ,-3 ,-\
c 
S 
S 
5n
 
 $
 $ KO,1D
tEJJ$;$;X$EFGD
 &*D
 
	D
 $D
LZX Z:K Zx
 %0 1   
 

 
rX   rB   c                 l   U R                   R                   Vs/ s H1  nUR                  R                  SS 5      c  M"  UR                  S   PM3     nnSSKJn  U" U5      nUb  UR                  $ U H:  n[        U[        R                  5      (       d  M$  UR                  R                  s  $    g s  snf )Nr   r   r)   )r   r   r   r  torch._guardsr*   r   r   r   SymIntr/  )r   r/  valsr*   r)  rQ  s         rU   r  r    s     HHNN"D99==% 			%" 	 
 / &I"""a&&66### s
   !B1B1old_range_constraintsz!Optional[dict[sympy.Symbol, Any]]r}  c                 P   Uc   e[        U 5      nUc  0 $ [        R                  " U5      nUR                  5        VVs0 s H  u  pEXBR                  ;  d  M  XE_M     nnnUR                  R                  5        H!  u  pEXBR                  ;  d  M  XC;  d  M  XSU'   M#     U$ s  snnf rN   )r  r   r   replacementsvar_to_range)r   r_  r   rv  r   rQ  s         rU   rw  rw  "  s     !,,,r"I			"78*0022a?U?U6U2   &&,,.***q/I#$a  / s   B"B"c                     [         R                  R                  X5      nU$ ! [         a\    [        R
                  " S5        [         R                  R                  U [         R                  R                  5       5      nXl         U$ f = f)NzUnable to execute the generated python source code from the graph. The graph module will no longer be directly callable, but you can still run the ExportedProgram, and if needed, you can run the graph module eagerly using torch.fx.Interpreter.)r   r  r`  SyntaxErrorwarningswarnrT  _graph)ru  r   r   s      rU   r  r  9  st    XX!!$.  I   	G	
 XX!!$(89	Is   # A"B	B	r  )rv   r0   rN   )r  r   dataclassesro   ra  r  re  collectionsr   collections.abcr   r   typingr   r   r   r	   r
   r   torch._higher_order_ops.utilsr   "torch._library.fake_class_registryr   torch._subclasses.fake_implsr   r   r   torch._subclasses.fake_tensorr   torch.fx._utilsr   torch.fx.graphr   r   torch.fx.immutable_collectionsr   r   torch.fx.passes.runtime_assertr   sympytorch.utils._sympy.value_rangesr   r   torch.utils._pytreeutils_pytreer`   rE  r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   torch._export.verifierr(   r\  r*   r,   torch.export._tree_utilsr-   r.   torch.export.decomp_utilsr0   torch.fx._compatibilityr1   torch.fx.passes.infra.pass_baser2   "torch.fx.passes.infra.pass_managerr3   r   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   __all__r  r`  rZ  	dataclassrD   rC   rq   r   Contextr  rz   r   r   AutogradCPUAutogradCUDAAutogradMetaAutogradXLAAutogradLazyAutogradIPUAutogradXPUAutogradMPSAutogradHPUAutogradPrivateUse1AutogradPrivateUse2AutogradPrivateUse3r   CPUCUDAMetaXLALazyIPUXPUMPSHPUr   r   r   ry   rX  rY  r   r   rE   intrR  r  ri  r^   rr  rz  rB   r  rw  r  rY   rX   rU   <module>r     s          " $ % G G B ? 
 9 ? 6 I J 
 ;  $ $    " , * @ B 7 1 6 :   " UXX))*HZ,@@A ' ' '  4 4 4
GG>>G G >>	G
 
G: 
HH$$	HH%%	HH%%	HH$$	HH%%	HH$$	HH$$	HH$$	HH$$	HH,,	HH,,	HH,,, (, 
HH	HH	HH	HH	HH	HH	HH	HH	HH
  X$ X$v  )-uzz..89)-
4

''12C78)-Xo2 

//9:o2 ejj55x?@	o2
 smo2d##3G#
588!556#2..:!!0!01 

//9:1 ejj55x?@	1
 sm1 "&1h	
 	
D$$ BF> .rX   