
      i                         d Z ddl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 ddlmZ ddlmZ ddlmZ  G d	 d
e      Zde
de
fdZ G d d      Zy)z.Abstract base class used to build new loggers.    )ABCabstractmethod)	Namespace)wraps)AnyCallableOptionalUnion)Tensor)Module)rank_zero_onlyc            	       N   e Zd ZdZeedee   fd              Zeedee	e
ef      fd              Zedee   fd       Zedee   fd       Zedefd       Zedd	eeef   d
ee
   ddfd       Zede	eeef   ef   dededdfd       Zddedee   ddfdZddZdeddfdZy)Loggerz"Base class for experiment loggers.returnc                      y)zReturn the experiment name.N selfs    t/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/lightning_fabric/loggers/logger.pynamezLogger.name           c                      y)zReturn the experiment version.Nr   r   s    r   versionzLogger.version#   r   r   c                      y)zReturn the root directory where all versions of an experiment get saved, or `None` if the logger does not
        save data locally.Nr   r   s    r   root_dirzLogger.root_dir(        r   c                      y)z~Return directory the current version of the experiment gets saved, or `None` if the logger does not save
        data locally.Nr   r   s    r   log_dirzLogger.log_dir.   r   r   c                      y)zRReturn the default separator used by the logger to group the data into subfolders./r   r   s    r   group_separatorzLogger.group_separator4   s     r   Nmetricsstepc                      y)a  Records metrics. This method logs metrics as soon as it received them.

        Args:
            metrics: Dictionary with metric names as keys and measured quantities as values
            step: Step number at which the metrics should be recorded

        Nr   )r   r#   r$   s      r   log_metricszLogger.log_metrics9   s     	r   paramsargskwargsc                      y)a?  Record hyperparameters.

        Args:
            params: :class:`~argparse.Namespace` or `Dict` containing the hyperparameters
            args: Optional positional arguments, depends on the specific logger being used
            kwargs: Optional keyword arguments, depends on the specific logger being used

        Nr   )r   r'   r(   r)   s       r   log_hyperparamszLogger.log_hyperparamsD   r   r   modelinput_arrayc                      y)zRecord model graph.

        Args:
            model: the model with an implementation of ``forward``.
            input_array: input passes to `model.forward`

        Nr   )r   r,   r-   s      r   	log_graphzLogger.log_graphO   s     	r   c                      y)zSave log data.Nr   r   s    r   savezLogger.saveY   r   r   statusc                 $    | j                          y)zDo any processing that is necessary to finalize an experiment.

        Args:
            status: Status that the experiment finished with (e.g. success, failed, aborted)

        N)r1   )r   r2   s     r   finalizezLogger.finalize\   s     			r   N)r   N)__name__
__module____qualname____doc__propertyr   r	   strr   r
   intr   r   r   r"   dictfloatr&   r   r   r+   r   r   r/   r1   r4   r   r   r   r   r      sf   ,*hsm *  * -%S/2 -  - (3-  
 #  
    4U
#3 8C= TX   eDcNI,E&F s ^a fj  v HV4D PT s t r   r   fnr   c                 b     t               dt        dt        t        t        f   f fd       }|S )zIReturns the real experiment on rank 0 and otherwise the _DummyExperiment.r   r   c                 N    t         j                  dkD  r
t               S  |       S )a  
        Note:
            ``self`` is a custom logger instance. The loggers typically wrap an ``experiment`` method
            with a ``@rank_zero_experiment`` decorator.

            ``Union[Any, _DummyExperiment]`` is used because the wrapped hooks have several return
            types that are specific to the custom logger. The return type here can be considered as
            ``Union[return type of logger.experiment, _DummyExperiment]``.
        r   )r   rank_DummyExperiment)r   r?   s    r   
experimentz(rank_zero_experiment.<locals>.experimenti   s%     "#%%$xr   )r   r   r
   r   rC   )r?   rD   s   ` r   rank_zero_experimentrE   f   s<     2Y E#/?*?$@   r   c                   X    e Zd ZdZdededdfdZdedefdZd	edd fd
Z	dededdfdZ
y)rC   zDummy experiment.r(   kwr   Nc                      y r5   r   )r   r(   rG   s      r   nopz_DummyExperiment.nop~       r   _c                     | j                   S r5   )rI   )r   rK   s     r   __getattr__z_DummyExperiment.__getattr__   s    xxr   idxc                     | S r5   r   )r   rN   s     r   __getitem__z_DummyExperiment.__getitem__   s    r   r)   c                      y r5   r   )r   r(   r)   s      r   __setitem__z_DummyExperiment.__setitem__   rJ   r   )r6   r7   r8   r9   r   rI   r   rM   r<   rP   rR   r   r   r   rC   rC   {   s`     C D S X s '9    r   rC   N)r9   abcr   r   argparser   	functoolsr   typingr   r   r	   r
   torchr   torch.nnr   $lightning_fabric.utilities.rank_zeror   r   rE   rC   r   r   r   <module>rZ      sN    5 #   1 1   ?HS HVX ( * r   