
    Vh
                        d dl Z d dlZd dlZd dlmZ dej
                  j                  deej
                  j                  ej                  j                  j                  f   fdZdej
                  j                  dej                  j                  j                  ddfdZ	 ddej                  j                  d	edej                  j                  fd
Zy)    N)_decompose_exported_programepreturnc                 V   t        j                  | j                        }t        j                  | j                        }t	        | j                  j                         |j                               D ]  \  }}|j                  j                  D cg c]  }|j                  dk(  s| }}|j                  j                  D cg c]  }|j                  dk(  s| }}t        |      t        |      k(  sJ t	        ||      D ]  \  }}	|j                  |	_
          ||fS c c}w c c}w )Nplaceholder)copydeepcopygraph_modulegraph_signaturezipmodulesgraphnodesoplenname)
r   gmnew_graph_signatureold_gmnew_gmnodeold_phsnew_phsold_nodenew_nodes
             R/home/dcms/DCMS/lib/python3.12/site-packages/torch/export/experimental/__init__.py _copy_graph_module_and_signaturer      s     
r	'B--(:(:; boo557F *$*LL$6$6SD$'']:R4SS$*LL$6$6SD$'']:R4SS7|s7|+++"%gw"7 	*Hh$MMHM	** """ TSs   D!$D!D&D&r   sigc                    | j                  |j                               5  t        t        | j                  j
                              D ]  }|j                  dk7  r|j                  t        j                  j                  j                  j                  k(  sOt        |j                        dk(  sht        t!        |j                              j                  t        j                  j                  j                  j                  k(  st        t!        |j                              j#                  |        	 d d d        | j                  j%                          | j'                          y # 1 sw Y   4xY w)Ncall_function   )_set_replace_hookget_replace_hooklistreversedr   r   r   targettorchopsatendetachdefaultr   usersnextiterreplace_all_uses_witheliminate_dead_code	recompile)r   r   r   s      r   _remove_detach_passr2      s     
		c224	5 	C"((..12 	CDww/)uyy~~44<<<

Oq(djj)*11UYY^^5J5J5R5RRT$**%&<<TB	C	C HH  "LLN	C 	Cs   A7E,E,1AE,	/E,,E5joint_loss_indexc                     ddl m} t        | i  |       |d      } t        |       \  }}t	        ||       | j                  ||      S )z[
    WARNING: This API is highly unstable and will be subject to change in the future.
    r   )core_aten_decompositionsF)cia_to_decomppython_decomp_tabler3   decompose_custom_triton_ops)torch._decompr5   r   r   r2   _update)r   r3   r5   r   r   s        r   _export_forward_backwardr;   0   sT     7	$
46) %*	
B ?rBB/0::b-..    )r   )r   typingr'   torch.export.exported_programr   fxGraphModuletupleexportr   ExportGraphSignaturer   r2   ExportedProgramintr;    r<   r   <module>rG      s       E##
588!=!=!R!RRS#,#(<<#?#?#T#T	& ?@/$$/8;/
\\!!/r<   