
    Ig                     2     G d  d      Z  e        Zd Zd Zy)c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
CompilationCallbackHandlerc                      g | _         g | _        y )N)start_callbacksend_callbacksselfs    S/var/www/html/answerous/venv/lib/python3.12/site-packages/torch/_dynamo/callback.py__init__z#CompilationCallbackHandler.__init__   s    !    c                 <    | j                   j                  |       |S )z
        Register a callback function to be called when the compilation starts.

        Args:
        - callback (callable): The callback function to register.
        )r   appendr   callbacks     r	   register_start_callbackz2CompilationCallbackHandler.register_start_callback   s     	##H-r   c                 <    | j                   j                  |       |S )z
        Register a callback function to be called when the compilation ends.

        Args:
        - callback (callable): The callback function to register.
        )r   r   r   s     r	   register_end_callbackz0CompilationCallbackHandler.register_end_callback   s     	!!(+r   c                 :    | j                   j                  |       y)z
        Remove a registered start callback function.

        Args:
        - callback (callable): The callback function to remove.
        N)r   remover   s     r	   remove_start_callbackz0CompilationCallbackHandler.remove_start_callback   s     	##H-r   c                 :    | j                   j                  |       y)z
        Remove a registered end callback function.

        Args:
        - callback (callable): The callback function to remove.
        N)r   r   r   s     r	   remove_end_callbackz.CompilationCallbackHandler.remove_end_callback$   s     	!!(+r   c                 4    | j                   D ]	  } |         y)z9
        Execute all registered start callbacks.
        N)r   r   s     r	   run_start_callbacksz.CompilationCallbackHandler.run_start_callbacks-   s     ,, 	HJ	r   c                 4    | j                   D ]	  } |         y)z7
        Execute all registered end callbacks.
        N)r   r   s     r	   run_end_callbacksz,CompilationCallbackHandler.run_end_callbacks4   s     ** 	HJ	r   c                 l    | j                   j                          | j                  j                          y)z1
        Clear all registered callbacks.
        N)r   clearr   r   s    r	   r   z CompilationCallbackHandler.clear;   s(     	""$  "r   N)__name__
__module____qualname__r
   r   r   r   r   r   r   r    r   r	   r   r      s*     .,#r   r   c                 0    t         j                  |        | S )zU
    Decorator to register a callback function for the start of the compilation.
    )callback_handlerr   r   s    r	   on_compile_startr%   F   s     ,,X6Or   c                 0    t         j                  |        | S )zS
    Decorator to register a callback function for the end of the compilation.
    )r#   r   r$   s    r	   on_compile_endr'   N   s     **84Or   N)r   r#   r%   r'   r!   r   r	   <module>r(      s%   ># >#B ./ r   