
    ;i@              
          S SK r S SKrS SKrS SKJr  S SKJrJrJr  S SK	r	S SK
Jr  SSKJr  SSKJr  SSKJrJrJrJrJrJrJrJrJrJrJrJr  / r\" 5       (       a  \R=                  \R>                  5        \" 5       (       a  \R=                  \R@                  5        \" 5       (       a  \R=                  \RB                  5        \" 5       (       a  \R=                  \RD                  5        \" 5       (       a  \R=                  \RF                  5        \" 5       (       a  \R=                  \RH                  5        \" 5       (       a  \R=                  \RJ                  5        \" 5       (       a  \R=                  \RL                  5        \" 5       (       a  \R=                  \RN                  5        \" \(5      r)S	 r*S
 r+ " S S5      r, " S S\,5      r- " S S\,5      r. " S S\,5      r/ " S S\,5      r0 " S S\,5      r1 " S S\,5      r2 " S S\,5      r3 " S S\,5      r4 " S S\,5      r5\1\0\2\-\.\3\4\5\/S.	r6 S#S \7\\8\\,4      S!\\\8\Rr                  4      4S" jjr:g)$    Nwraps)AnyOptionalUnion)version   )
get_logger)PartialState)
LoggerTypecompare_versionsis_aim_availableis_clearml_availableis_comet_ml_availableis_dvclive_availableis_mlflow_availableis_swanlab_availableis_tensorboard_availableis_trackio_availableis_wandb_availablelistifyc                 0   ^  [        T 5      U 4S j5       nU$ )z
Decorator to selectively run the decorated function on the main process only based on the `main_process_only`
attribute in a class.

Checks at function execution rather than initialization time, not triggering the initialization of the
`PartialState`.
c                    > [        U SS5      (       a#  [        5       R                  T5      " U /UQ70 UD6$ T" U /UQ70 UD6$ )Nmain_process_onlyF)getattrr   on_main_process)selfargskwargsfunctions      c/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/accelerate/tracking.pyexecute_on_main_process0on_main_process.<locals>.execute_on_main_processV   sJ    4,e44>11(;DR4R6RRD242622    r   )r    r"   s   ` r!   r   r   M   s#     8_3 3 #"r$   c                      [         $ )z@Returns a list of all supported available trackers in the system)_available_trackers r$   r!   get_available_trackersr(   `   s    r$   c                   X    \ rS rSrSrSrSS jrS rS\4S jr	S\S\
\   4S	 jrS
 rSrg)GeneralTrackere   a8  
A base Tracker class to be used for all logging integration implementations.

Each function should take in `**kwargs` that will automatically be passed in from a base dictionary provided to
[`Accelerator`].

Should implement `name`, `requires_logging_directory`, and `tracker` properties such that:

`name` (`str`): String representation of the tracker class name, such as "TensorBoard" `requires_logging_directory`
(`bool`): Whether the logger requires a directory to store their logs. `tracker` (`object`): Should return internal
tracking mechanism used by a tracker class (such as the `run` for wandb)

Implementations can also include a `main_process_only` (`bool`) attribute to toggle if relevant logging, init, and
other functions should occur on the main process or across all processes (by default will use `True`)
Tc                 "   U(       d  Sn[        U S5      (       d  US-  n[        U S5      (       d  [        U5      S:  a  US-  nUS-  nS[        U 5      ;  a  [        U5      S:  a  US-  nUS	-  n[        U5      S:  a  [        S
U 35      eg g )N namez`name`requires_logging_directoryr   z, z`requires_logging_directory`trackerz	`tracker`zThe implementation for this tracker class is missing the following required attributes. Please define them in the class definition: )hasattrlendirNotImplementedError)r   _blankerrs      r!   __init__GeneralTracker.__init__x   s    C4((x4!=>>s8a<4KC55 D	)s8a<4KC{"3x!|)Xe   r$   c                     g)zy
Lazy initialization of the tracker inside Accelerator to avoid initializing PartialState before
InitProcessGroupKwargs.
Nr'   r   s    r!   startGeneralTracker.start       
 	r$   valuesc                     g)ak  
Logs `values` as hyperparameters for the run. Implementations should use the experiment configuration
functionality of a tracking API.

Args:
    values (Dictionary `str` to `bool`, `str`, `float` or `int`):
        Values to be stored as initial hyperparameters as key-value pairs. The values need to have type `bool`,
        `str`, `float`, `int`, or `None`.
Nr'   r   r>   s     r!   store_init_configuration'GeneralTracker.store_init_configuration   s     	r$   stepc                     g)a  
Logs `values` to the current run. Base `log` implementations of a tracking API should go in here, along with
special behavior for the `step parameter.

Args:
    values (Dictionary `str` to `str`, `float`, or `int`):
        Values to be logged as key-value pairs. The values need to have type `str`, `float`, or `int`.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
Nr'   r   r>   rC   r   s       r!   logGeneralTracker.log   s     	r$   c                     g)z
Should run any finalizing functions within the tracking API. If the API should not have one, just don't
overwrite that method.
Nr'   r:   s    r!   finishGeneralTracker.finish   r=   r$   r'   N)F)__name__
__module____qualname____firstlineno____doc__r   r7   r;   dictrA   r   intrF   rI   __static_attributes__r'   r$   r!   r*   r*   e   sA      ,
t 
$ hsm r$   r*   c                      ^  \ rS rSrSrSrSrS\S\\\	R                  4   4U 4S jjr\S 5       r\S	 5       r\S
\4S j5       r\SS
\S\\   4S jj5       r\S
\S\\   4S j5       r\S 5       rSrU =r$ )TensorBoardTracker   a  
A `Tracker` class that supports `tensorboard`. Should be initialized at the start of your script.

Args:
    run_name (`str`):
        The name of the experiment run
    logging_dir (`str`, `os.PathLike`):
        Location for TensorBoard logs to be stored.
    **kwargs (additional keyword arguments, *optional*):
        Additional key word arguments passed along to the `tensorboard.SummaryWriter.__init__` method.
tensorboardTrun_namelogging_dirc                 F   > [         TU ]  5         Xl        X l        X0l        g N)superr7   rW   logging_dir_paraminit_kwargsr   rW   rX   r   	__class__s       r!   r7   TensorBoardTracker.__init__   s     !,!r$   c                     SSK Jn  [        R
                  R                  U R                  U R                  5      U l	        UR                  " U R                  40 U R                  D6U l        [        R                  SU R                   SU R                   35        [        R                  S5        g ! [         a    SS Kn Nf = f)Nr   )rV   z Initialized TensorBoard project z logging to aMake sure to log any initial configurations with `self.store_init_configuration` before training!)torch.utilsrV   ModuleNotFoundErrortensorboardXospathjoinr\   rW   rX   SummaryWriterr]   writerloggerdebug)r   rV   s     r!   r;   TensorBoardTracker.start   s    	// 77<<(>(>N!//0@0@UDDTDTU7lSWScScRdefo	
 # 	/.	/s   B2 2CCc                     U R                   $ rZ   rj   r:   s    r!   r0   TensorBoardTracker.tracker       {{r$   r>   c                 x   U R                   R                  U0 S9  U R                   R                  5         [        R                  " 5       n[        R
                  R                  U R                  [        U5      5      n[        R                  " USS9  [        [        R
                  R                  US5      S5       n [        R                  " X5         SSS5        [        R#                  S5        g! [        R                  R                   a    [        R!                  S5        e f = f! , (       d  f       N\= f)	a  
Logs `values` as hyperparameters for the run. Should be run at the beginning of your experiment. Stores the
hyperparameters in a yaml file for future use.

Args:
    values (Dictionary `str` to `bool`, `str`, `float` or `int`):
        Values to be stored as initial hyperparameters as key-value pairs. The values need to have type `bool`,
        `str`, `float`, `int`, or `None`.
)metric_dictT)exist_okzhparams.ymlwz-Serialization to store hyperparameters failedNzQStored initial configuration hyperparameters to TensorBoard and hparams yaml file)rj   add_hparamsflushtimerf   rg   rh   rX   strmakedirsopenyamldumprepresenterRepresenterErrorrk   errorrl   )r   r>   project_run_namedir_nameoutfiles        r!   rA   +TensorBoardTracker.store_init_configuration   s     	B799;77<< 0 0#6F2GH
Ht,"'',,x7=		&* > 	hi ##44 LM >=s   <D+>C335D((D++
D9rC   c                    [        U5      nUR                  5        H  u  pE[        U[        [        45      (       a!  U R
                  R                  " XE4SU0UD6  MA  [        U[        5      (       a!  U R
                  R                  " XE4SU0UD6  Mw  [        U[        5      (       d  M  U R
                  R                  " XE4SU0UD6  M     U R
                  R                  5         [        R                  S5        g)aR  
Logs `values` to the current run.

Args:
    values (Dictionary `str` to `str`, `float`, `int` or `dict` of `str` to `float`/`int`):
        Values to be logged as key-value pairs. The values need to have type `str`, `float`, `int` or `dict` of
        `str` to `float`/`int`.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to either `SummaryWriter.add_scaler`,
        `SummaryWriter.add_text`, or `SummaryWriter.add_scalers` method based on the contents of `values`.
global_stepz"Successfully logged to TensorBoardN)r   items
isinstancerQ   floatrj   
add_scalarry   add_textrP   add_scalarsrw   rk   rl   r   r>   rC   r   kvs         r!   rF   TensorBoardTracker.log   s     LLNDA!c5\**&&qHHHAs##$$QFtFvFAt$$''I$I&I # 	9:r$   c                     UR                  5        H$  u  pEU R                  R                  " XE4SU0UD6  M&     [        R	                  S5        g)a  
Logs `images` to the current run.

Args:
    values (Dictionary `str` to `List` of `np.ndarray` or `PIL.Image`):
        Values to be logged as key-value pairs. The values need to have type `List` of `np.ndarray` or
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `SummaryWriter.add_image` method.
r   z)Successfully logged images to TensorBoardN)r   rj   
add_imagesrk   rl   r   s         r!   
log_imagesTensorBoardTracker.log_images  s?     LLNDAKK""1DTDVD #@Ar$   c                 b    U R                   R                  5         [        R                  S5        g)z
Closes `TensorBoard` writer
zTensorBoard writer closedN)rj   closerk   rl   r:   s    r!   rI   TensorBoardTracker.finish   s!    
 	01r$   )r]   rX   r\   rW   rj   rZ   )rK   rL   rM   rN   rO   r.   r/   ry   r   rf   PathLiker7   r   r;   propertyr0   rP   rA   r   rQ   rF   r   rI   rR   __classcell__r_   s   @r!   rT   rT      s    
 D!%" "5bkk9I3J " 

 

   jt j j. ;$ ;hsm ; ;2 B BXc] B B  2 2r$   rT   c                   ,  ^  \ rS rSrSrSrSrSrS\4U 4S jjr	\
S 5       r\S 5       r\
S	\4S
 j5       r\
SS	\S\\   4S jj5       r\
SS	\S\\   4S jj5       r\
    SS\S\\\      S\\\\         S\S\\   4
S jj5       r\
S 5       rSrU =r$ )WandBTrackeri)  a*  
A `Tracker` class that supports `wandb`. Should be initialized at the start of your script.

Args:
    run_name (`str`):
        The name of the experiment run.
    **kwargs (additional keyword arguments, *optional*):
        Additional key word arguments passed along to the `wandb.init` method.
wandbFrW   c                 :   > [         TU ]  5         Xl        X l        g rZ   r[   r7   rW   r]   r   rW   r   r_   s      r!   r7   WandBTracker.__init__8       !r$   c                     SS K nUR                  " SSU R                  0U R                  D6U l        [
        R                  SU R                   35        [
        R                  S5        g )Nr   projectzInitialized WandB project rb   r'   )r   initrW   r]   runrk   rl   )r   r   s     r!   r;   WandBTracker.start=  sN    ::HdmmHt7G7GH1$--ABo	
r$   c                     U R                   $ rZ   r   r:   s    r!   r0   WandBTracker.trackerG      xxr$   r>   c                    SSK n[        R                  R                  S5      S:X  a~  [	        U S5      (       a+  U R
                  (       a  U R
                  R                  5         U R                  R                  5       nXS'   UR                  " SSU R                  0UD6U l        OUR                  R                  USS	9  [        R                  S
5        g)E  
Logs `values` as hyperparameters for the run. Should be run at the beginning of your experiment.

Args:
    values (Dictionary `str` to `bool`, `str`, `float` or `int`):
        Values to be stored as initial hyperparameters as key-value pairs. The values need to have type `bool`,
        `str`, `float`, `int`, or `None`.
r   N
WANDB_MODEoffliner   configr   Tallow_val_changez5Stored initial configuration hyperparameters to WandBr'   )r   rf   environgetr1   r   rI   r]   copyr   rW   r   updaterk   rl   )r   r>   r   r]   s       r!   rA   %WandBTracker.store_init_configurationK  s     	::>>,'94tU##!**//1K$*!zzG$--G;GDHLL>LMr$   rC   c                 l    U R                   R                  " U4SU0UD6  [        R                  S5        g)a  
Logs `values` to the current run.

Args:
    values (Dictionary `str` to `str`, `float`, `int` or `dict` of `str` to `float`/`int`):
        Values to be logged as key-value pairs. The values need to have type `str`, `float`, `int` or `dict` of
        `str` to `float`/`int`.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `wandb.log` method.
rC   zSuccessfully logged to WandBNr   rF   rk   rl   rE   s       r!   rF   WandBTracker.logc  s+     	V1$1&134r$   c           
          SSK nUR                  5        H:  u  pVU R                  " XV Vs/ s H  otR                  U5      PM     sn04SU0UD6  M<     [        R                  S5        gs  snf )a  
Logs `images` to the current run.

Args:
    values (Dictionary `str` to `List` of `np.ndarray` or `PIL.Image`):
        Values to be logged as key-value pairs. The values need to have type `List` of `np.ndarray` or
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `wandb.log` method.
r   NrC   z#Successfully logged images to WandB)r   r   rF   Imagerk   rl   )r   r>   rC   r   r   r   r   images           r!   r   WandBTracker.log_imagest  s\     	LLNDAHHa!<!++e,!<=SDSFS #:; =   A)
table_namecolumnsdata	dataframec                 X    SSK nXR                  X#US90nU R                  " U4SU0UD6  g)a{  
Log a Table containing any object type (text, image, audio, video, molecule, html, etc). Can be defined either
with `columns` and `data` or with `dataframe`.

Args:
    table_name (`str`):
        The name to give to the logged table on the wandb workspace
    columns (list of `str`, *optional*):
        The name of the columns on the table
    data (List of List of Any data type, *optional*):
        The data to be logged in the table
    dataframe (Any data type, *optional*):
        The data to be logged in the table
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
r   N)r   r   r   rC   )r   TablerF   )	r   r   r   r   r   rC   r   r   r>   s	            r!   	log_tableWandBTracker.log_table  s3    4 	kk'PYkZ[-d-f-r$   c                 b    U R                   R                  5         [        R                  S5        g)z
Closes `wandb` writer
zWandB run closedNr   rI   rk   rl   r:   s    r!   rI   WandBTracker.finish  s    
 	'(r$   r]   r   rW   rZ   NNNN)rK   rL   rM   rN   rO   r.   r/   r   ry   r7   r   r;   r   r0   rP   rA   r   rQ   rF   r   listr   r   rI   rR   r   r   s   @r!   r   r   )  s9    D!&" "
 
 
   Nt N N. 5$ 5hsm 5 5  < <Xc] < <$  (,*.".. $s)$. tDI'	.
 . sm. .< ) )r$   r   c                      ^  \ rS rSrSrSrSrSrS\4U 4S jjr	\
S 5       r\S 5       r\
S	\4S
 j5       r\
SS	\S\\   4S jj5       r\
S 5       rSrU =r$ )TrackioTrackeri  a(  
A `Tracker` class that supports `trackio`. Should be initialized at the start of your script.

Args:
    run_name (`str`):
        The name of the experiment run. Will be used as the `project` name when instantiating trackio.
    **kwargs (additional keyword arguments, *optional*):
        Additional key word arguments passed along to the `trackio.init` method. Refer to this
        [init](https://github.com/gradio-app/trackio/blob/814809552310468b13f84f33764f1369b4e5136c/trackio/__init__.py#L22)
        to see all supported key word arguments.
trackioFrW   c                 :   > [         TU ]  5         Xl        X l        g rZ   r   r   s      r!   r7   TrackioTracker.__init__  r   r$   c                     SS K nUR                  " SSU R                  0U R                  D6U l        [
        R                  SU R                   35        [
        R                  S5        g )Nr   r   zInitialized trackio project rb   r'   )r   r   rW   r]   r   rk   rl   )r   r   s     r!   r;   TrackioTracker.start  sN    <<JJ9I9IJ3DMM?CDo	
r$   c                     U R                   $ rZ   r   r:   s    r!   r0   TrackioTracker.tracker  r   r$   r>   c                 j    SSK nUR                  R                  USS9  [        R	                  S5        g)r   r   NTr   z7Stored initial configuration hyperparameters to trackio)r   r   r   rk   rl   )r   r>   r   s      r!   rA   'TrackioTracker.store_init_configuration  +     	ft<NOr$   rC   c                 h    U R                   R                  " U40 UD6  [        R                  S5        g)a  
Logs `values` to the current run.

Args:
    values (Dictionary `str` to `str`, `float`, `int` or `dict` of `str` to `float`/`int`):
        Values to be logged as key-value pairs. The values need to have type `str`, `float`, `int` or `dict` of
        `str` to `float`/`int`.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `trackio.log` method.
zSuccessfully logged to trackioNr   rE   s       r!   rF   TrackioTracker.log  s&     	V&v&56r$   c                 b    U R                   R                  5         [        R                  S5        g)z
Closes `trackio` run
ztrackio run closedNr   r:   s    r!   rI   TrackioTracker.finish      
 	)*r$   r   rZ   )rK   rL   rM   rN   rO   r.   r/   r   ry   r7   r   r;   r   r0   rP   rA   r   rQ   rF   rI   rR   r   r   s   @r!   r   r     s    
 D!&" "
 
 
   Pt P P 7$ 7hsm 7 7  + +r$   r   c                      ^  \ rS rSrSrSrSrS\4U 4S jjr\	S 5       r
\S 5       r\	S	\4S
 j5       r\	SS	\S\\   4S jj5       r\	S 5       rSrU =r$ )CometMLTrackeri  a  
A `Tracker` class that supports `comet_ml`. Should be initialized at the start of your script.

API keys must be stored in a Comet config file.

Note:
    For `comet_ml` versions < 3.41.0, additional keyword arguments are passed to `comet_ml.Experiment` instead:
    https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/Experiment/#comet_ml.Experiment.__init__

Args:
    run_name (`str`):
        The name of the experiment run.
    **kwargs (additional keyword arguments, *optional*):
        Additional key word arguments passed along to the `comet_ml.start` method:
        https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/start/
comet_mlFrW   c                 :   > [         TU ]  5         Xl        X l        g rZ   r   r   s      r!   r7   CometMLTracker.__init__  r   r$   c                    SS K n[        R                  " UR                  5      n[	        USS5      (       a.  UR
                  " SSU R                  0U R                  D6U l        OB[        R                  S5        UR                  " SSU R                  0U R                  D6U l        [        R                  SU R                   35        [        R                  S5        g )	Nr   z>=z3.41.0project_namezFUpdate `comet_ml` (>=3.41.0) for experiment reuse and offline support.zInitialized CometML project rb   r'   )r   r   parse__version__r   r;   rW   r]   rj   rk   info
Experimentrl   )r   r   comet_versions      r!   r;   CometMLTracker.start  s    h&:&:;M4::"..XdmmXtGWGWXDKKK`a"--]4==]DL\L\]DK3DMM?CDo	
r$   c                     U R                   $ rZ   ro   r:   s    r!   r0   CometMLTracker.tracker&  rq   r$   r>   c                 d    U R                   R                  U5        [        R                  S5        g)r   z5Stored initial configuration hyperparameters to CometN)rj   log_parametersrk   rl   r@   s     r!   rA   'CometMLTracker.store_init_configuration*  s#     	""6*LMr$   rC   c                    Ub  U R                   R                  U5        UR                  5        H  u  pE[        U[        [
        45      (       a!  U R                   R                  " XE4SU0UD6  MA  [        U[        5      (       a  U R                   R                  " XE40 UD6  Mu  [        U[        5      (       d  M  U R                   R                  " U4SU0UD6  M     [        R                  S5        g)aJ  
Logs `values` to the current run.

Args:
    values (Dictionary `str` to `str`, `float`, `int` or `dict` of `str` to `float`/`int`):
        Values to be logged as key-value pairs. The values need to have type `str`, `float`, `int` or `dict` of
        `str` to `float`/`int`.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to either `Experiment.log_metric`, `Experiment.log_other`,
        or `Experiment.log_metrics` method based on the contents of `values`.
NrC   zSuccessfully logged to Comet)rj   set_stepr   r   rQ   r   
log_metricry   	log_otherrP   log_metricsrk   rl   r   s         r!   rF   CometMLTracker.log7  s     KK  &LLNDA!c5\**&&qA$A&AAs##%%a5f5At$$''??? # 	34r$   c                 b    U R                   R                  5         [        R                  S5        g)z
Flush `comet-ml` writer
zComet run flushedN)rj   endrk   rl   r:   s    r!   rI   CometMLTracker.finishQ  s    
 	()r$   )r]   rW   rj   rZ   )rK   rL   rM   rN   rO   r.   r/   ry   r7   r   r;   r   r0   rP   rA   r   rQ   rF   rI   rR   r   r   s   @r!   r   r     s    " D!&" "
 
 
   
Nt 
N 
N 5$ 5hsm 5 52 * *r$   r   c                     ^  \ rS rSrSrSrSrSS\S\\	\\
R                  4      4U 4S jjjr\S 5       r\S	 5       r\S
\4S j5       r\S
\S\\   4S j5       r\SS
\S\\   S\\\\4      4S jj5       r\S 5       rSrU =r$ )
AimTrackeriZ  a*  
A `Tracker` class that supports `aim`. Should be initialized at the start of your script.

Args:
    run_name (`str`):
        The name of the experiment run.
    **kwargs (additional keyword arguments, *optional*):
        Additional key word arguments passed along to the `Run.__init__` method.
aimTrW   rX   c                 F   > [         TU ]  5         Xl        X l        X0l        g rZ   )r[   r7   rW   aim_repo_pathr]   r^   s       r!   r7   AimTracker.__init__h  s     (!r$   c                     SSK Jn  U" SSU R                  0U R                  D6U l        U R
                  U R                  l        [        R                  SU R
                   35        [        R                  S5        g )Nr   )RunrepozInitialized Aim project rb   r'   )	r   r  r   r]   rj   rW   r.   rk   rl   )r   r  s     r!   r;   AimTracker.startn  s\    Ft11FT5E5EF==/?@o	
r$   c                     U R                   $ rZ   ro   r:   s    r!   r0   AimTracker.trackery  rq   r$   r>   c                      XR                   S'   g)
Logs `values` as hyperparameters for the run. Should be run at the beginning of your experiment.

Args:
    values (`dict`):
        Values to be stored as initial hyperparameters as key-value pairs.
hparamsNro   r@   s     r!   rA   #AimTracker.store_init_configuration}  s     "(Ir$   rC   c                 t    UR                  5        H$  u  pEU R                  R                  " U4XBS.UD6  M&     g)a5  
Logs `values` to the current run.

Args:
    values (`dict`):
        Values to be logged as key-value pairs.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `Run.track` method.
r.   rC   N)r   rj   track)r   r>   rC   r   keyvalues         r!   rF   AimTracker.log  s2     !,,.JCKKeC#CFC )r$   r   c                 6   SSK n0 n0 nUb$  UR                  S0 5      nUR                  S0 5      nUR                  5        HV  u  px[        U[        5      (       a  Uu  pOUSpUR
                  " U	4SU
0UD6nU R                  R                  " U4XrS.UD6  MX     g)a  
Logs `images` to the current run.

Args:
    values (`Dict[str, Union[np.ndarray, PIL.Image, Tuple[np.ndarray, str], Tuple[PIL.Image, str]]]`):
        Values to be logged as key-value pairs. The values need to have type `np.ndarray` or PIL.Image. If a
        tuple is provided, the first element should be the image and the second element should be the caption.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs (`Dict[str, dict]`):
        Additional key word arguments passed along to the `Run.Image` and `Run.track` method specified by the
        keys `aim_image` and `track`, respectively.
r   N	aim_imager  r-   captionr  )r   r   r   r   tupler   rj   r  )r   r>   rC   r   r   aim_image_kwtrack_kwr  r  imgr  r  s               r!   r   AimTracker.log_images  s     	!::k26Lzz'2.H ,,.JC%''$W$bW		#GwG,GIKKiIcII )r$   c                 8    U R                   R                  5         g)z
Closes `aim` writer
N)rj   r   r:   s    r!   rI   AimTracker.finish  s    
 	r$   )r   r]   rW   rj   ).NN)rK   rL   rM   rN   rO   r.   r/   ry   r   r   rf   r   r7   r   r;   r   r0   rP   rA   rQ   rF   r   rI   rR   r   r   s   @r!   r   r   Z  s    D!%" "8E#r{{BR<S3T " " 
 
   (t ( ( D$ Dhsm D D  J JXc] J8TXY\^bYbTcKd J J>  r$   r   c                      \ rS rSrSrSrSr       SS\\   S\\	\\
R                  4      S\\   S	\\	\\\4   \4      S
\\   S\\   S\\   4S jjr\S 5       r\S 5       r\S\4S j5       r\S\S\\   4S j5       r\S\S\4S j5       r\SS\S\\   4S jj5       r\SS\S\\   4S jj5       r\S 5       rSrg) MLflowTrackeri  u  
A `Tracker` class that supports `mlflow`. Should be initialized at the start of your script.

Args:
    experiment_name (`str`, *optional*):
        Name of the experiment. Environment variable MLFLOW_EXPERIMENT_NAME has priority over this argument.
    logging_dir (`str` or `os.PathLike`, defaults to `"."`):
        Location for mlflow logs to be stored.
    run_id (`str`, *optional*):
        If specified, get the run with the specified UUID and log parameters and metrics under that run. The run’s
        end time is unset and its status is set to running, but the run’s other attributes (source_version,
        source_type, etc.) are not changed. Environment variable MLFLOW_RUN_ID has priority over this argument.
    tags (`Dict[str, str]`, *optional*):
        An optional `dict` of `str` keys and values, or a `str` dump from a `dict`, to set as tags on the run. If a
        run is being resumed, these tags are set on the resumed run. If a new run is being created, these tags are
        set on the new run. Environment variable MLFLOW_TAGS has priority over this argument.
    nested_run (`bool`, *optional*, defaults to `False`):
        Controls whether run is nested in parent run. True creates a nested run. Environment variable
        MLFLOW_NESTED_RUN has priority over this argument.
    run_name (`str`, *optional*):
        Name of new run (stored as a mlflow.runName tag). Used only when `run_id` is unspecified.
    description (`str`, *optional*):
        An optional string that populates the description box of the run. If a run is being resumed, the
        description is set on the resumed run. If a new run is being created, the description is set on the new
        run.
mlflowFNexperiment_namerX   run_idtags
nested_runrW   descriptionc                    [         R                  R                  SU5      n[         R                  R                  SU5      n[         R                  R                  SU5      n[        U[        5      (       a  [
        R                  " U5      n[         R                  R                  SU5      nXl        X l        X0l	        X@l
        XPl        X`l        Xpl        g )NMLFLOW_EXPERIMENT_NAMEMLFLOW_RUN_IDMLFLOW_TAGSMLFLOW_NESTED_RUN)rf   r   r   r   ry   jsonloadsr   rX   r!  r"  r#  rW   r$  )r   r   rX   r!  r"  r#  rW   r$  s           r!   r7   MLflowTracker.__init__  s     **..)A?S8zz~~mT2dC  ::d#DZZ^^$7D
.&	$ &r$   c           	      .   SS K nUR                  SU R                   S3S9n[        U5      S:  a4  [        U5      S:  a  [        R                  S5        US   R                  nO/UR                  U R                  U R                  U R                  S9nUR                  U R                  UU R                  U R                  U R                  U R                  S9U l        [        R!                  S	U R                   35        [        R!                  S
5        g )Nr   zname = '')filter_stringr	   z?Multiple experiments with the same name found. Using first one.)r.   artifact_locationr"  )r!  experiment_idrW   nestedr"  r$  zInitialized mlflow experiment rb   )r  search_experimentsr   r2   rk   warningr1  create_experimentrX   r"  	start_runr!  rW   r#  r$  
active_runrl   )r   r  expsr1  s       r!   r;   MLflowTracker.start  s    (($BVBVAWWX7Y(Zt9q=4y1}`a G11M"44))"&"2"2YY 5 M !**;;']]??(( + 
 	5d6J6J5KLMo	
r$   c                     U R                   $ rZ   )r7  r:   s    r!   r0   MLflowTracker.tracker  s    r$   r>   c           
         SSK n[        UR                  5       5       H|  u  p4[        [	        U5      5      UR
                  R                  R                  :  d  M=  [        R                  SU SU SUR
                  R                  R                   S35        X	 M~     [        UR                  5       5      n[        S[        U5      UR
                  R                  R                  5       H?  nUR                  [        XVXbR
                  R                  R                  -    5      5        MA     [        R                  S5        g)r  r   Nz,Accelerate is attempting to log a value of "z" for key "zJ" as a parameter. MLflow's log_param() only accepts values no longer than z) characters so we dropped this attribute.z6Stored initial configuration hyperparameters to MLflow)r  r   r   r2   ry   utils
validationMAX_PARAM_VAL_LENGTHrk   warning_oncerangeMAX_PARAMS_TAGS_PER_BATCH
log_paramsrP   rl   )r   r>   r  r.   r  values_listis          r!   rA   &MLflowTracker.store_init_configuration  s    	/KD3u:!8!8!M!MM##B5'UYTZ [GGM||G^G^GsGsFt  u^_ L 0 6<<>* q#k*FLL,C,C,],]^Ad;1||7N7N7h7h3h#ijk _ 	MNr$   rC   c           
         0 nUR                  5        HN  u  pE[        U[        [        45      (       a  XSU'   M&  [        R                  SU S[        U5       SU S35        MP     SSKnUR                  X2S9  [        R                  S5        g)	z
Logs `values` to the current run.

Args:
    values (`dict`):
        Values to be logged as key-value pairs.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
z/MLflowTracker is attempting to log a value of "
" of type 
 for key "zc" as a metric. MLflow's log_metric() only accepts float and int types so we dropped this attribute.r   N)rC   zSuccessfully logged to mlflow)
r   r   rQ   r   rk   r@  typer  r   rl   )r   r>   rC   metricsr   r   r  s          r!   rF   MLflowTracker.log8  s     LLNDA!c5\**
##EaS
SWXYSZR[[efgeh ik k	 # 	7.45r$   figureartifact_filec                 ^    SSK nUR                  " SXS.UD6  [        R                  S5        g)a|  
Logs an figure to the current run.

Args:
    figure (Any):
    The figure to be logged.
    artifact_file (`str`, *optional*):
    The run-relative artifact file path in posixpath format to which the image is saved.
    If not provided, the image is saved to a default location.
    **kwargs:
    Additional keyword arguments passed to the underlying mlflow.log_image function.
r   N)rM  rN  z#Successfully logged image to mlflowr'   )r  
log_figurerk   rl   )r   rM  rN  save_kwargsr  s        r!   rP  MLflowTracker.log_figureQ  s*     	TTT:;r$   	local_dirartifact_pathc                 T    SSK nUR                  XS9  [        R                  S5        g)a  
Logs an artifacts (all content of a dir) to the current run.

    local_dir (`str`):
        Path to the directory to be logged as an artifact.
    artifact_path (`str`, *optional*):
        Directory within the run's artifact directory where the artifact will be logged. If omitted, the
        artifact will be logged to the root of the run's artifact directory. The run step. If included, the
        artifact will be affiliated with this step.
r   N)rS  rT  &Successfully logged artofact to mlflow)r  log_artifactsrk   rl   )r   rS  rT  r  s       r!   rW  MLflowTracker.log_artifactsd  s%     	yN=>r$   
local_pathc                 T    SSK nUR                  XS9  [        R                  S5        g)a  
Logs an artifact (file) to the current run.

    local_path (`str`):
        Path to the file to be logged as an artifact.
    artifact_path (`str`, *optional*):
        Directory within the run's artifact directory where the artifact will be logged. If omitted, the
        artifact will be logged to the root of the run's artifact directory. The run step. If included, the
        artifact will be affiliated with this step.
r   N)rY  rT  rV  )r  log_artifactrk   rl   )r   rY  rT  r  s       r!   r[  MLflowTracker.log_artifactu  s%     	zO=>r$   c                 ,    SSK nUR                  5         g)z
End the active MLflow run.
r   N)r  end_run)r   r  s     r!   rI   MLflowTracker.finish  s    
 	r$   )r7  r$  r   rX   r#  r!  rW   r"  )NNNNFNNrZ   )rK   rL   rM   rN   rO   r.   r/   r   ry   r   rf   r   rP   r   boolr7   r   r;   r   r0   rA   rQ   rF   rP  rW  r[  rI   rR   r'   r$   r!   r  r    s   6 D!& *.9= $59%*"&%)'!#' eC$456' 	'
 uT#s(^S012' TN' 3-' c]'4 
 
:   Ot O O6 6$ 6hsm 6 60 < <S < <$ ?s ?8C= ? ?  ?s ?8C= ? ?   r$   r  c                   V  ^  \ rS rSrSrSrSrSS\\   4U 4S jjjr	\
S 5       r\S 5       r\
S	\4S
 j5       r\
SS	\\\\\4   4   S\\   4S jj5       r\
SS	\S\\   4S jj5       r\
    SS\S\\\      S\\\\         S\S\\   4
S jj5       r\
S 5       r\S 5       rSrU =r$ )ClearMLTrackeri  a  
A `Tracker` class that supports `clearml`. Should be initialized at the start of your script.

Args:
    run_name (`str`, *optional*):
        Name of the experiment. Environment variables `CLEARML_PROJECT` and `CLEARML_TASK` have priority over this
        argument.
    **kwargs (additional keyword arguments, *optional*):
        Kwargs passed along to the `Task.__init__` method.
clearmlFrW   c                 H   > [         TU ]  5         Xl        SU l        X l        g )NF)r[   r7   user_provided_run_name_initialized_externallyr]   r   s      r!   r7   ClearMLTracker.__init__  s"    &.#',$!r$   c                    SSK Jn  UR                  5       nU(       a  SU l        X l        g 0 U R
                  EnUR                  S[        R                  R                  SU R                  5      5        UR                  S[        R                  R                  SU R                  5      5        UR                  " S0 UD6U l        g )	Nr   )TaskTr   CLEARML_PROJECT	task_nameCLEARML_TASKr'   )rc  ri  current_taskrf  taskr]   
setdefaultrf   r   r   re  r   )r   ri  rm  task_init_argss       r!   r;   ClearMLTracker.start  s     ((*+/D($I-D,,-!!."**..ARTXToTo2pq!!+rzz~~ndNiNi/jkII//	r$   c                     U R                   $ rZ   )rn  r:   s    r!   r0   ClearMLTracker.tracker      yyr$   r>   c                 8    U R                   R                  U5      $ )z
Connect configuration dictionary to the Task object. Should be run at the beginning of your experiment.

Args:
    values (`dict`):
        Values to be stored as initial hyperparameters as key-value pairs.
)rn  connect_configurationr@   s     r!   rA   'ClearMLTracker.store_init_configuration  s     yy..v66r$   rC   c           
      ~   U R                   R                  5       nUR                  5        H  u  pV[        U[        [
        45      (       d*  [        R                  SU S[        U5       SU S35        MJ  Uc  UR                  " SXVS.UD6  Mc  [        R                  U5      u  pxUR                  " SXxXbS.UD6  M     g)	aP  
Logs `values` dictionary to the current run. The dictionary keys must be strings. The dictionary values must be
ints or floats

Args:
    values (`Dict[str, Union[int, float]]`):
        Values to be logged as key-value pairs. If the key starts with 'eval_'/'test_'/'train_', the value will
        be reported under the 'eval'/'test'/'train' series and the respective prefix will be removed.
        Otherwise, the value will be reported under the 'train' series, and no prefix will be removed.
    step (`int`, *optional*):
        If specified, the values will be reported as scalars, with the iteration number equal to `step`.
        Otherwise they will be reported as single values.
    kwargs:
        Additional key word arguments passed along to the `clearml.Logger.report_single_value` or
        `clearml.Logger.report_scalar` methods.
z-Accelerator is attempting to log a value of "rH  rI  zn" as a scalar. This invocation of ClearML logger's  report_scalar() is incorrect so we dropped this attribute.N)r.   r  )titleseriesr  	iterationr'   )rn  r
   r   r   rQ   r   rk   r@  rJ  report_single_valuerb  _get_title_seriesreport_scalar	r   r>   rC   r   clearml_loggerr   r   ry  rz  s	            r!   rF   ClearMLTracker.log  s    $ --/LLNDAa#u..##s*T!WIZs ;AA |22MMfM*<<Q?ME((gu1g`fg #r$   c           	          U R                   R                  5       nUR                  5        H1  u  pV[        R	                  U5      u  pxUR
                  " SXxX&S.UD6  M3     g)a  
Logs `images` to the current run.

Args:
    values (`Dict[str, List[Union[np.ndarray, PIL.Image]]`):
        Values to be logged as key-value pairs. The values need to have type `List` of `np.ndarray` or
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `clearml.Logger.report_image` method.
)ry  rz  r{  r   Nr'   )rn  r
   r   rb  r}  report_imager  s	            r!   r   ClearMLTracker.log_images  sS     --/LLNDA*<<Q?ME''fedf_ef #r$   r   r   r   r   c                     UnUc  Uc  [        S5      eU(       a  U/U-   OUn[        R                  U5      u  pU R                  R	                  5       R
                  " SXXuS.UD6  g)a  
Log a Table to the task. Can be defined eitherwith `columns` and `data` or with `dataframe`.

Args:
    table_name (`str`):
        The name of the table
    columns (list of `str`, *optional*):
        The name of the columns on the table
    data (List of List of Any data type, *optional*):
        The data to be logged in the table. If `columns` is not specified, then the first entry in data will be
        the name of the columns of the table
    dataframe (Any data type, *optional*):
        The data to be logged in the table
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `clearml.Logger.report_table` method.
NzW`ClearMLTracker.log_table` requires that `data` to be supplied if `dataframe` is `None`)ry  rz  
table_plotr{  r'   )
ValueErrorrb  r}  rn  r
   report_table)
r   r   r   r   r   rC   r   	to_reportry  rz  s
             r!   r   ClearMLTracker.log_table  so    8 	| m  -4	D(I&88D		++w%S\wpvwr$   c                     U R                   (       a-  U R                  (       d  U R                   R                  5         ggg)z
Close the ClearML task. If the task was initialized externally (e.g. by manually calling `Task.init`), this
function is a noop
N)rn  rf  r   r:   s    r!   rI   ClearMLTracker.finish  s(     99T99IIOO :9r$   c                 x    S H1  nU R                  US-   5      (       d  M  U [        U5      S-   S  U4s  $    U S4$ )N)evaltesttrain_r	   r  )
startswithr2   )r.   prefixs     r!   r}   ClearMLTracker._get_title_series&  sF    /Fv|,,CK!O-.66 0 W}r$   )rf  r]   rn  re  rZ   r   )rK   rL   rM   rN   rO   r.   r/   r   ry   r7   r   r;   r   r0   rP   rA   r   rQ   r   rF   r   r   r   r   rI   staticmethodr}  rR   r   r   s   @r!   rb  rb    sq   	 D!&"# " " 0 0   7t 7 7 h$sE#u*$556 hhsm h hB g gXc] g g"  (,*."#x#x $s)$#x tDI'	#x
 #x sm#x #xJ    r$   rb  c                      ^  \ rS rSrSrSrSrSS\\   S\\	   4U 4S jjjr
\S 5       r\S	 5       r\S
\4S j5       r\SS
\S\\   4S jj5       r\S 5       rSrU =r$ )DVCLiveTrackeri.  a  
A `Tracker` class that supports `dvclive`. Should be initialized at the start of your script.

Args:
    run_name (`str`, *optional*):
        Ignored for dvclive. See `kwargs` instead.
    kwargs:
        Additional key word arguments passed along to [`dvclive.Live()`](https://dvc.org/doc/dvclive/live).

Example:

```py
from accelerate import Accelerator

accelerator = Accelerator(log_with="dvclive")
accelerator.init_trackers(project_name="my_project", init_kwargs={"dvclive": {"dir": "my_directory"}})
```
dvcliveFrW   livec                 :   > [         TU ]  5         X l        X0l        g rZ   )r[   r7   r  r]   )r   rW   r  r   r_   s       r!   r7   DVCLiveTracker.__init__E  s    	!r$   c                 |    SSK Jn  U R                  b  U R                  U l        g U" S0 U R                  D6U l        g )Nr   )Liver'   )r  r  r  r]   )r   r  s     r!   r;   DVCLiveTracker.startJ  s-     !%!6DII	D<T4CSCS<T	r$   c                     U R                   $ rZ   )r  r:   s    r!   r0   DVCLiveTracker.trackerP  rt  r$   r>   c                 :    U R                   R                  U5        g)a  
Logs `values` as hyperparameters for the run. Should be run at the beginning of your experiment. Stores the
hyperparameters in a yaml file for future use.

Args:
    values (Dictionary `str` to `bool`, `str`, `float`, `int`, or a List or Dict of those types):
        Values to be stored as initial hyperparameters as key-value pairs. The values need to have type `bool`,
        `str`, `float`, or `int`.
N)r  rC  r@   s     r!   rA   'DVCLiveTracker.store_init_configurationT  s     			V$r$   rC   c           
      V   SSK Jn  Ub  X R                  l        UR	                  5        Hb  u  pVUR                  U5      (       a  U R                  R                  " XV40 UD6  M:  [        R                  SU S[        U5       SU S35        Md     U R                  R                  5         g)a  
Logs `values` to the current run.

Args:
    values (Dictionary `str` to `str`, `float`, or `int`):
        Values to be logged as key-value pairs. The values need to have type `str`, `float`, or `int`.
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to `dvclive.Live.log_metric()`.
r   )MetricNz)Accelerator attempted to log a value of "rH  rI  zh" as a scalar. This invocation of DVCLive's Live.log_metric() is incorrect so we dropped this attribute.)dvclive.plotsr  r  rC   r   	could_logr   rk   r@  rJ  	next_step)r   r>   rC   r   r  r   r   s          r!   rF   DVCLiveTracker.loga  s     	)!IINLLNDA""		$$Q4V4##s*T!WIZs ;AA	 # 			r$   c                 8    U R                   R                  5         g)z
Closes `dvclive.Live()`.
N)r  r   r:   s    r!   rI   DVCLiveTracker.finish~  s    
 			r$   )r]   r  r  rZ   )rK   rL   rM   rN   rO   r.   r/   r   ry   r   r7   r   r;   r   r0   rP   rA   rQ   rF   rI   rR   r   r   s   @r!   r  r  .  s    & D!&"# "Xc] " "
 U U
   
%t 
% 
% $ hsm  8  r$   r  c                      ^  \ rS rSrSrSrSrSrS\4U 4S jjr	\
S 5       r\S 5       r\
S	\4S
 j5       r\
SS	\S\\   4S jj5       r\
SS	\S\\   4S jj5       r\
S 5       rSrU =r$ )SwanLabTrackeri  a.  
A `Tracker` class that supports `swanlab`. Should be initialized at the start of your script.

Args:
    run_name (`str`):
        The name of the experiment run.
    **kwargs (additional keyword arguments, *optional*):
        Additional key word arguments passed along to the `swanlab.init` method.
swanlabFrW   c                 :   > [         TU ]  5         Xl        X l        g rZ   r   r   s      r!   r7   SwanLabTracker.__init__  r   r$   c                     SS K nUR                  " SSU R                  0U R                  D6U l        SUR
                  S'   [        R                  SU R                   35        [        R                  S5        g )Nr   r   u   🤗Accelerate	FRAMEWORKzInitialized SwanLab project rb   r'   )r  r   rW   r]   r   r   rk   rl   )r   r  s     r!   r;   SwanLabTracker.start  s\    <<JJ9I9IJ&6{#3DMM?CDo	
r$   c                     U R                   $ rZ   r   r:   s    r!   r0   SwanLabTracker.tracker  r   r$   r>   c                 j    SSK nUR                  R                  USS9  [        R	                  S5        g)r   r   NTr   z7Stored initial configuration hyperparameters to SwanLab)r  r   r   rk   rl   )r   r>   r  s      r!   rA   'SwanLabTracker.store_init_configuration  r   r$   rC   c                 l    U R                   R                  " U4SU0UD6  [        R                  S5        g)a  
Logs `values` to the current run.

Args:
data : Dict[str, DataType]
    Data must be a dict. The key must be a string with 0-9, a-z, A-Z, " ", "_", "-", "/". The value must be a
    `float`, `float convertible object`, `int` or `swanlab.data.BaseType`.
step : int, optional
    The step number of the current data, if not provided, it will be automatically incremented.
If step is duplicated, the data will be ignored.
    kwargs:
        Additional key word arguments passed along to the `swanlab.log` method. Likes:
            print_to_console : bool, optional
                Whether to print the data to the console, the default is False.
rC   zSuccessfully logged to SwanLabNr   rE   s       r!   rF   SwanLabTracker.log  s+    " 	V1$1&156r$   c           
          SSK nUR                  5        H:  u  pVU R                  " XV Vs/ s H  otR                  U5      PM     sn04SU0UD6  M<     [        R                  S5        gs  snf )a&  
Logs `images` to the current run.

Args:
    values (Dictionary `str` to `List` of `np.ndarray` or `PIL.Image`):
        Values to be logged as key-value pairs. The values need to have type `List` of `np.ndarray` or
    step (`int`, *optional*):
        The run step. If included, the log will be affiliated with this step.
    kwargs:
        Additional key word arguments passed along to the `swanlab.log` method. Likes:
            print_to_console : bool, optional
                Whether to print the data to the console, the default is False.
r   NrC   z%Successfully logged images to SwanLab)r  r   rF   r   rk   rl   )r   r>   rC   r   r  r   r   r   s           r!   r   SwanLabTracker.log_images  s\     	LLNDAHHaA>A5--.A>?UdUfU #<= ?r   c                 b    U R                   R                  5         [        R                  S5        g)z
Closes `swanlab` writer
zSwanLab run closedNr   r:   s    r!   rI   SwanLabTracker.finish  r   r$   r   rZ   )rK   rL   rM   rN   rO   r.   r/   r   ry   r7   r   r;   r   r0   rP   rA   r   rQ   rF   r   rI   rR   r   r   s   @r!   r  r    s     D!&" "
 
 
   Pt P P 7$ 7hsm 7 7& > >Xc] > >( + +r$   r  )	r   r   r  rV   r   rc  r  r  r   log_withrX   c                    / nU Gb  [        U [        [        45      (       d  U /n SU ;   d  [        R                  U ;   a@  U  Vs/ s H%  n[        [        U5      [        5      (       d  M#  UPM'     sn[        5       -   nU$ U  GH  nU[        ;  aB  [        [        U5      [        5      (       d$  [        SU S[        R                  " 5        35      e[        [        U5      [        5      (       a  UR                  U5        M  [        U5      nXB;  d  M  U[        5       ;   aH  [        [        U5         nUR                  (       a  Uc  [        SU S35      eUR                  U5        M  [        R                  SU S35        GM     U$ s  snf )a+  
Takes in a list of potential tracker types and checks that:
    - The tracker wanted is available in that environment
    - Filters out repeats of tracker types
    - If `all` is in `log_with`, will return all trackers in the environment
    - If a tracker requires a `logging_dir`, ensures that `logging_dir` is not `None`

Args:
    log_with (list of `str`, [`~utils.LoggerType`] or [`~tracking.GeneralTracker`], *optional*):
        A list of loggers to be setup for experiment tracking. Should be one or several of:

        - `"all"`
        - `"tensorboard"`
        - `"wandb"`
        - `"trackio"`
        - `"aim"`
        - `"comet_ml"`
        - `"mlflow"`
        - `"dvclive"`
        - `"swanlab"`
        If `"all"` is selected, will pick up all available trackers in the environment and initialize them. Can
        also accept implementations of `GeneralTracker` for custom trackers, and can be combined with `"all"`.
    logging_dir (`str`, `os.PathLike`, *optional*):
        A path to a directory for storing logs of locally-compatible loggers.
allz Unsupported logging capability: z. Choose between zLogging with `z+` requires a `logging_dir` to be passed in.zTried adding logger z+, but package is unavailable in the system.)r   r   r  r   ALL
issubclassrJ  r*   r(   r  appendLOGGER_TYPE_TO_CLASSry   r/   rk   rl   )r  rX   loggersolog_typetracker_inits         r!   filter_trackersr    sW   : G(T5M22 zHH
( :"*R(Qja..Qq(RUkUmmG* N' %:-jhQ_6`6`$'GzQbcmcrcrctbu%vwwd8nn==NN8,)(3H.#'='??+?H+NL+FF#.#6*4*8
Bm(n+& %& $NN84"LL+?zIt)uv# %& N+ Ss   "F
)F
rZ   );r*  rf   rx   	functoolsr   typingr   r   r   r|   	packagingr   loggingr
   stater   r=  r   r   r   r   r   r   r   r   r   r   r   r   r&   r  TENSORBOARDWANDBCOMETMLAIMMLFLOWCLEARMLDVCLIVESWANLABTRACKIOrK   rk   r   r(   r*   rT   r   r   r   r   r  rb  r  r  r  r   ry   r   r  r'   r$   r!   <module>r     sO  $  	   ' '          z556z//0z112z~~.z001z112z112z112z112	H	#&
N Nbp2 p2fC)> C)LJ+^ J+Z[*^ [*|d dNLN L^[^ [|U^ Upa+^ a+J %
  6:75j.89:7%R[[ 0127r$   