
    qiC                        d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
mZmZ ddlmZmZmZ ddlmZ ddlmZ dd	lmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( dd
lm)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmBZC g dZDej                  j                  ej                  j&                  j                  g       ej                  ej                  j                  u rUddlKZ ej                  ej                        e_I        ej                  j                  j                  ej                  d       ddZPddZQdeRfdZSdeRddfdZTy)a  
TorchDynamo is a Python-level JIT compiler designed to make unmodified PyTorch programs faster.
TorchDynamo hooks into the frame evaluation API in CPython (PEP 523) to dynamically modify Python
bytecode right before it is executed. It rewrites Python bytecode in order to extract sequences of
PyTorch operations into an FX Graph which is then just-in-time compiled with a customizable backend.
It creates this FX Graph through bytecode analysis and is designed to mix Python execution with
compiled backends to get the best of both worlds: usability and performance. This allows it to
seamlessly optimize PyTorch programs, including those using modern Python features.
    N   )aot_compileconfigconvert_frame
eval_framefunctional_exportresume_execution)list_backendslookup_backendregister_backend)callback_handleron_compile_endon_compile_start)code_context)replay)allow_in_graphassume_constant_resultdisabledisable_nested_graph_breaksdisallow_in_graphdont_skip_tracingerror_on_graph_breakforbid_in_graphgraph_breakis_dynamo_disable_recursivemark_dynamicmark_staticmark_static_addressmaybe_mark_dynamicnonstrict_tracepatch_dynamo_configrun
set_stance
skip_framestep_unsupportedsubstitute_in_graph)	_reset_guarded_backend_cacheexplainexportis_dynamo_supportedis_inductor_supportedoptimizeoptimize_assertOptimizedModule
reset_code)is_compiling)GenerationTracker)reset_code_state)TensorifyState)graph_break_reasonsguard_failuresorig_code_map(register_hook_for_recompile_user_contextreset_frame_countreset_recompile_user_contexts)loader)#r   r   r   r   r   r   r   r)   r(   r   r   r0   r   r
   r   r   r   r   r   r    r,   r-   r.   r!   r   r   resetr9   r"   r   set_recursion_limitr#   r$   r%   r&   zaten::manual_seedreturnc                     ddl } | j                  t              }|j                  d       t        j
                  5  t                t        j                  j                          t                t        j                  j                          t        j                          t        j                          t        j                          t        j                  j                   j                          t#                t%                t&        j(                  j*                  j-                          dt        _        t        j0                  j                          t3        j                          t5        j                          t7        j                          t&        j(                  j8                  j:                  j                          t&        j<                  j>                  jA                  d       ddd       y# 1 sw Y   yxY w)a  
    Clear all compile caches and restore initial state.  This function is intended
    to reset Dynamo's state *as if* you had started a fresh process invocation, which
    makes it good for testing scenarios where you want to behave as if you started
    a new process.  It does NOT affect any file system caches.

    NB: this does NOT reset logging state.  Don't use this to test logging
    initialization/reinitialization.
    r   Nztorch._dynamo.resetF)!logging	getLogger__name__infor   compile_lockreset_code_cachesinput_codesclearr2   output_codesr6   r5   r4   r	   ContinueExecutionCachecacher'   r8   torch_dynamocompiled_autogradr;   FRAME_COUNTERFRAME_COMPILE_COUNTERr   r1   r3   utilswarn_once_cache_C	_autograd _saved_tensors_hooks_set_tracing)r?   logs     \/home/ubuntu/crypto_trading_bot/.venv/lib/python3.12/site-packages/torch/_dynamo/__init__.pyr;   r;      sF    


H
%CHH"#		#	# C!!'')""((*!!#//55;;=$&''--/&'#++113 !++113;;EB%C C Cs   F1G55G>c                  ~   ddl } | j                  t              }|j                  d       	 t        j
                  5  t                t        j                  j                  t        j                  j                  z   D ]  } |       }|st        |        t        j                          ddd       y# 1 sw Y   yxY w)z
    Clears in-memory code cache, which is what stores compiled products.  This
    resets less state than :func:`reset` and is mostly only used for testing
    purposes.
    r   Nztorch._dynamo.reset_code_caches)r?   r@   rA   rB   r   rC   r2   rE   seenrG   r/   r   rF   )r?   rT   	weak_codecodes       rU   rD   rD      s     


H
%CHH./=		#	# %%**]-G-G-L-LL	!I ;D4 	! 	  s   AB3	!B33B<c                  f    t         j                  j                  j                  j	                         S )z
    Returns the internal dynamo recursion limit set by `torch._dynamo.set_recursion_limit`.

    Returns -1 if no c recursion limit has been set.
    )rJ   rQ   rK   r   get_c_recursion_limit     rU   get_recursion_limitr^      s#     88&&<<>>r]   limitc                 j    t         j                  j                  j                  j	                  |        y)a  
    Sets an internal dynamo recursion limit. The limit must be >= 1, or -1 to reset
    to the default (unset) state.

    This is possibly needed in Python 3.12-3.13 since there is a separate C recursion limit
    that is not visible at the Python level. If you are getting RecursionErrors during
    Dynamo compilation and `sys.setrecursionlimit()` doesn't help, this function may alleviate
    the issue.

    NOTE: this function does NOT call `sys.setrecursionlimit()` - the user is expected to manually
        call this if required. This is because the 2 recursion limits are not sync'd up - e.g. in
        Python 3.12, functions can be inline-evaluated, which apparently doesn't use up the C stack.

    WARNING: increasing the recursion limit to an arbitrary large value may cause segfaults
        due to stack overflows! You can try also try to manually increase the stack size, e.g.
        with `$ ulimit -s ...`
    N)rJ   rQ   rK   r   set_c_recursion_limit)r_   s    rU   r<   r<      s"    $ 
HH55e<r]   )r=   N)U__doc__rJ    r   r   r   r   r   r	   backends.registryr
   r   r   callbackr   r   r   r   r   
decoratorsr   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/   external_utilsr0   mutation_guardr1   pgor2   symbolic_convertr3   rO   r4   r5   r6   r7   r8   r9   	polyfillsr:   ___all__serializationadd_safe_globalsrK   	_DimRangemanual_seedrandomtorch.jit._builtins_disable_dynamojit	_builtins_register_builtinr;   rD   intr^   r<   r\   r]   rU   <module>ry      s-     O N H H & !     .
 
 
 ) - ! ,  #$N    $ $emm&>&>&H&H%I J000 .--e.?.?@E	II))%*;*;=PQ!CH.?S ?=s =t =r]   