o
    "i                     @   s(   G d d dZ e  Zdd Zdd ZdS )c                   @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )CompilationCallbackHandlerc                 C   s   g | _ g | _d S )N)start_callbacksend_callbacksself r   T/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/torch/_dynamo/callback.py__init__   s   
z#CompilationCallbackHandler.__init__c                 C      | 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   callbackr   r   r   register_start_callback      z2CompilationCallbackHandler.register_start_callbackc                 C   r	   )z
        Register a callback function to be called when the compilation ends.

        Args:
        - callback (callable): The callback function to register.
        )r   r
   r   r   r   r   register_end_callback   r   z0CompilationCallbackHandler.register_end_callbackc                 C      | j | dS )z
        Remove a registered start callback function.

        Args:
        - callback (callable): The callback function to remove.
        N)r   remover   r   r   r   remove_start_callback      z0CompilationCallbackHandler.remove_start_callbackc                 C   r   )z
        Remove a registered end callback function.

        Args:
        - callback (callable): The callback function to remove.
        N)r   r   r   r   r   r   remove_end_callback$   r   z.CompilationCallbackHandler.remove_end_callbackc                 C      | j D ]}|  qdS )z9
        Execute all registered start callbacks.
        N)r   r   r   r   r   run_start_callbacks-      
z.CompilationCallbackHandler.run_start_callbacksc                 C   r   )z7
        Execute all registered end callbacks.
        N)r   r   r   r   r   run_end_callbacks4   r   z,CompilationCallbackHandler.run_end_callbacksc                 C   s   | j   | j  dS )z1
        Clear all registered callbacks.
        N)r   clearr   r   r   r   r   r   ;   s   
z CompilationCallbackHandler.clearN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r   r   r      s    

		r   c                 C      t |  | S )zU
    Decorator to register a callback function for the start of the compilation.
    )callback_handlerr   r   r   r   r   on_compile_startF      
r    c                 C   r   )zS
    Decorator to register a callback function for the end of the compilation.
    )r   r   r   r   r   r   on_compile_endN   r!   r"   N)r   r   r    r"   r   r   r   r   <module>   s   A