
    sh                     d    S SK rS SKJrJr  SSKJrJr  SS\4S jjr	SS jr
S rS	 rSS
 jrS rg)    N)tree_flattentree_unflatten   )add_step_closurerun_step_closuresdevicec                 j    [         R                  R                  R                  U / US9  [	        5         g)aB  Triggers a mark step, which amounts to
- collecting a group of 'live' lazy tensors to index into the compilation cache
  (lowering/compiling their IR graphs if not cached)
- kicking off execution of the compiled function
- (optionally, wait=True) waiting for cpu-side execution to complete (does not sync the accelerator)
)waitN)torch_C_lazy
_mark_stepr   )r   r
   s     h/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/torch/_lazy/__init__.py	mark_stepr   	   s'     
HHNNfbt4    c                 \    U c  / n [         R                  R                  R                  U S9  g)zWaits for all the async operations on the given devices to complete.
Args:
  devices (string..., optional): The devices whose async ops need to be waited
    for. If empty, all the local devices will be waited for.
Ndevices)r   r   r   _wait_device_opsr   s    r   wait_device_opsr      s'     	HHNN##G#4r   c                 V    [         R                  R                  R                  X5        g)z
Sync the list of lazy tensors so there IR get lowered for the activate backend
and the compiled computation graph get cached.
N)r   r   r   _sync_multi)tensorsr   s     r   
sync_multir   !   s    
 
HHNNw0r   c                 T    [         R                  R                  R                  U 5      $ )z7Return a unique id of the lazy tensor maintained by LTC)r   r   r   _get_tensor_id)tensors    r   get_tensor_idr   )   s    88>>((00r   c                     U=(       d    S/n[        U 5      u  p#[        X!5        [        U Vs/ s H  oDR                  S5      PM     snU5      $ s  snf )Nlazycpu)r   r   r   to)r   r   	flattenedspects        r   to_cpur&   .   sG    !&G"7+OIy"	:	144;	:DAA:s   Ac                 J    [         R                  " [        U 5      /UQ70 UD6  g N)r   saver&   )r   argskwargss      r   r)   r)   6   s    	JJvg000r   ) Fr(   )torch._C._lazyr   torch.utils._pytreer   r   closurer   r   strr   r   r   r   r&   r)    r   r   <module>r2      s6     < 8
c 
511
B1r   