
    sh                     l   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rS SK	J
r
  \R                  " \5      rSr\R                  " 5       r\R"                  r\ R&                  " \R(                  5        \R+                  S\5        \R,                  R/                  \5        S rS rS r SS	 jrS
 rg)    N)Optional)get_remote_module_template_remote_module_z#Created a temporary directory at %sc                 L   [        U SS5      (       d   S5       e[        R                  R                  U 5      n[        R                  R
                  R                  nUR                  U5      nSUR                  5       ;   d   SUR                  5        35       eUR                  S5      n/ n/ nUc   eUR                   Hs  nUR                  UR                  5        UR                  5       (       a  SUR                   3nOSnUR                   SUR                   U 3n	UR                  U	5        Mu     US	S  nS
R!                  U5      n
US	S  nS
R!                  U5      n[#        UR$                  5      S	:X  d   eUR$                  S   n['        UR                  5      nXU4$ )N__torch_script_interface__FzGExpect a TorchScript class interface decorated by @torch.jit.interface.forwardz2Expect forward in interface methods, while it has z =  z:    z, r   )getattrtorch_jit_internal_qualified_namejit_state
_python_cuget_interfacegetMethodNames	getMethod	argumentsappendnamehas_default_valuedefault_valuetypejoinlenreturnsstr)module_interfacequalified_namecumodule_interface_cmethod_schemaarg_str_listarg_type_str_listargumentdefault_value_strarg_type_strargs_strarg_types_strreturn_type_strs                y/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/torch/distributed/nn/jit/instantiator.py#get_arg_return_types_from_interfacer-      s   #%A5II QI ((889IJN				$	$B)).9*99;; 
<=O=^=^=`<ab; '00;ML$$$!++HMM*%%''"%h&<&<%= > ""--8==/:K9LM  . ,  #Lyy&H)!"-II/0M}$$%***$$Q'H(--(OO33    c                 h    [        U 5       nUR                  5       nS S S 5        WU:w  a=  [        U S5       n[        R	                  SU 5        UR                  U5        S S S 5        g [        R	                  SU 5        g ! , (       d  f       Nh= f! [         a    S n Nyf = f! , (       d  f       g = f)Nwz
Writing %szSkipped writing %s)openreadOSErrorloggerinfowrite)out_pathtextfold_texts       r,   _writer;   B   s    (^qvvxH  4(C AKKh/GGDM !  	((3 ^  ! s8   B B B (B# 
B
B B B B #
B1c                     [        U5      R                  " S0 UD6n[        R                  R	                  [
        U  S35      n[        XC5        [        R                  " 5         [        R                  " U  5      nU$ )Nz.py )
r   formatospathr   INSTANTIATED_TEMPLATE_DIR_PATHr;   	importlibinvalidate_cachesimport_module)generated_module_namestr_dict!enable_moving_cpu_tensors_to_cudagenerated_code_textr7   generated_modules         r,   &_do_instantiate_remote_module_templaterJ   Q   s~     5)f  ww||&+@*A(EH 8) ! ..2G1HJr.   c           
      \   [        U SS5      (       d  [        SU  S35      e[        R                  R	                  U 5      R                  SS5      n[         U 3nSU R                   SU R                   S	3n[        U 5      u  pVnS
nSU 3n	SU S3n
[        UUU	U
UUSS9n[        X;U5      $ )Nr   Fzmodule_interface_cls z8 must be a type object decorated by @torch.jit.interface._zfrom z import z as module_interface_clsr	   z -> z -> Future[]z@torch.jit.script)assign_module_interface_cls	arg_typesarrow_and_return_typearrow_and_future_return_typeargskwargsjit_script_decorator)r   
ValueErrorr   r   r   replace_FILE_PREFIX
__module____name__r-   dictrJ   )module_interface_clsrG   module_interface_cls_namerE   assign_module_interface_cls_strr)   r*   r+   
kwargs_strarrow_and_return_type_str arrow_and_future_return_type_strrF   s               r,   -instantiate_scriptable_remote_module_templaterb   f   s    ')EuMM#$8#9 :# #
 	
 !& 3 3 C C!gc3   ,n-F,GH $//0((
))A	C $ 0S0,H_ J"&&7 8)4_4EQ'G$$C7%E0H 2)J r.   c            
      J    [          S3n [        SSSSSSSS9n[        XS5      $ )	Nnon_scriptablezmodule_interface_cls = Nonez*argsz**kwargsz*args, **kwargsr	   )rO   rS   rT   rP   rQ   rR   rU   T)rX   r[   rJ   )rE   rF   s     r,   1instantiate_non_scriptable_remote_module_templatere      s?    +nN;$A# %'H 22GSWXXr.   )T)atexitrB   loggingr?   systempfiletypingr   r   9torch.distributed.nn.jit.templates.remote_module_templater   	getLoggerrZ   r4   rX   TemporaryDirectory	_TEMP_DIRr   rA   registercleanupr5   r@   r   r-   r;   rJ   rb   re   r=   r.   r,   <module>rq      s       	 
   
 
		8	$ !'')	!*  	!! " 13Q R . /#4L4, =A&RYr.   