o
    1 i)                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	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 d dlZd dlZd dlZd dlmZ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) d d
l*m+Z+ d dl,m-Z- d dl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 zd dl9Z9d dl:Z9d dl;Z9W n e<y   dZ9Y nw e=e>Z?e@e1de2de'de3de4de0diZAh dZBeCeDejEejFejGejHeIdhZJe-jKe-jLe-jMe-jNe-jOgZPG dd deZQejRjST ZUdeeCeQe8f deeQ fddZVdeeWef deeW fddZXdeDd eDdeeWeWf fd!d"ZYd#ee- deeWee- f fd$d%ZZd#ee- dee- fd&d'Z[dwd#ee- d)eCdeeW fd*d+Z\d#ee- d,eeW d-eeW deee- eeW f fd.d/Z]eG d0d1 d1Z^eG d2d3 d3Z_dxd6ed7eCd8e`defd9d:Zad;e-d<eeW d=eeW deeW fd>d?Zb	5dyd@eWd#ee- d<eeW d=eeW dAe`dee^ fdBdCZc	5	5dzd#ee- d<eeW d=eeW dDe`dEe`de_fdFdGZdd;e-d,eWfdHdIZe	Jd{dKeWdLedMeWdeeeWeWf  fdNdOZf			d|dPedQee dRee dSee fdTdUZgejhrHejhjirHejhjijdVrHe"e!dWdXdXdYe!dZdXdXd[de!d\dXdXd]e d^d_d^e d^d_d^d`ddaZkn#e"e!dbdcdcdbe!dbdcdcdbde!dbdcdcdbe ddd_dde ddd_ddd`ddaZk				d}dPedeeeW dQeeeW  dReeeW  dfeeeW  f
dgdhZlG didj dje+Zm					d~dkeQdleCdmee% d,eeW d-eeW dee dneeeeW eeeWeWf  f  fdodpZnG dqdr dremZoG dsdt dteoZpG dudv dvemZqdS )    N)	dataclass)IntEnum)Any
CollectionDictIterableListOptionalTupleUnion)flatten_dictunflattened_lookup)DataRowLineTableFormattabulate)AirEntrypoint)TRAINING_ITERATION)
Checkpoint)Callback)Trial)AUTO_RESULT_KEYSEPISODE_REWARD_MEANMEAN_ACCURACY	MEAN_LOSSTIME_TOTAL_STIMESTEPS_TOTAL)Domain)	VerbosityaccZlossiterztotal time (s)tsZreward>   hostnameZnode_ipdoneZshould_checkpointZ
_report_onconfigZtime_since_restoreZiterations_since_restoretrial_iddatepid	timestampZexperiment_tagc                   @   s    e Zd ZdZdZdZdd ZdS )AirVerbosityr         c                 C   s
   t | jS N)strvalueself r1   h/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/ray/tune/experimental/output.py__repr__k   s   
zAirVerbosity.__repr__N)__name__
__module____qualname__ZSILENTDEFAULTVERBOSEr3   r1   r1   r1   r2   r)   f   s
    r)   verbosereturnc                 C   sJ   t jdddkrd S t| tr| S t| tr| n| j}td|}t|S )NZRAY_AIR_NEW_OUTPUT10r+   )osenvironget
isinstancer)   intr.   min)r9   Zverbose_intr1   r1   r2   get_air_verbosityr   s   

rC   r$   c                 C   sR   g }t | }| D ]\}}t|tr|| |dr&||d d  q
|S )Nz/grid_searchi)r   itemsr@   r   appendendswith)r$   paramsZflat_configkeyvalr1   r1   r2   _infer_params   s   


rJ   
start_timecurrent_timec                 C   s   t j |}t j | }|| }| }t|d }||d 8 }t|d }||d 8 }t|d }t||d  }	d}
|dkrH|
|dd7 }
|dksN|
rV|
|dd7 }
|dks\|
rd|
|dd	7 }
|
|	dd
7 }
|d|
fS )a  Get strings representing the current and elapsed time.

    Args:
        start_time: POSIX timestamp of the start of the tune run
        current_time: POSIX timestamp giving the current time

    Returns:
        Current time and elapsed time for the current run
    iQ i  <    r   dzd zhr zmin sz%Y-%m-%d %H:%M:%S)datetimefromtimestamptotal_secondsrA   )rK   rL   Zcurrent_time_dtZstart_time_dtdeltarestdayshoursminutessecondsZrunning_for_strr1   r1   r2   _get_time_str   s&   
rZ   trialsc                 C   s(   t t}| D ]
}||j | q|S r,   )collectionsdefaultdictliststatusrE   )r[   trials_by_statetr1   r1   r2   _get_trials_by_state   s   
rb   c                 C   s   dd | D S )Nc                 S   s   g | ]}|j r|qS r1   )
error_file.0ra   r1   r1   r2   
<listcomp>   s    z*_get_trials_with_error.<locals>.<listcomp>r1   r[   r1   r1   r2   _get_trials_with_error   s   rh      limitc                 C   s~   t  }| D ]2}|jsq|j D ]&\}}|tvr'|tvr't|tv r'd||< t||kr7t	|
     S qqt	|
 S )zTry to infer the metrics to print out.

    By default, only the first 4 meaningful metrics in `last_result` will be
    inferred as user implied metrics.
    rN   )r\   OrderedDictlast_resultrD   DEFAULT_COLUMNSr   typeVALID_SUMMARY_TYPESlenr^   keys)r[   rj   resultra   metricr.   r1   r1   r2   _infer_user_metrics   s   rt   rs   modec                 C   s~   | r|r|sdS |dkrdnd}t d}d}| D ]"}|jsqt||jdd}t|r,q|r4|| |kr:|| }|}q||fS )a9  
    Returns the best trial and the metric key. If anything is empty or None,
    returns a trivial result of None, None.

    Args:
        trials: List of trials.
        metric: Metric that trials are being ranked.
        mode: One of "min" or "max".

    Returns:
         Best trial and the metric key.
    NNmaxg      ?g      -infNdefault)floatrl   r   pdZisnull)r[   rs   ru   Z	metric_opZbest_metricZ
best_trialra   Zmetric_valuer1   r1   r2   _current_best_trial   s    
r}   c                   @   s&   e Zd ZU eee  ed< eed< dS )_PerStatusTrialTableDatatrial_infos	more_infoN)r4   r5   r6   r   r-   __annotations__r1   r1   r1   r2   r~      s   
 r~   c                   @   s&   e Zd ZU ee ed< ee ed< dS )_TrialTableDataheaderdataN)r4   r5   r6   r   r-   r   r~   r1   r1   r1   r2   r     s   
 r      Fr.   max_lenwrapc                 C   s   | du st | tttjtfr| S t| }t||kr|S |r>t| |d kr2d|d|d  d  } tj	| |d}d
|S d|d| d  }|S )a=  Abbreviate a string representation of an object to `max_len` characters.

    For numbers, booleans and None, the original value will be returned for
    correct rendering in the table formatting tool.

    Args:
        value: Object to be represented as a string.
        max_len: Maximum return string length.
    Nr+   z...   )width
)r@   rA   r{   numbersNumberboolr-   rp   textwrapr   join)r.   r   r   stringwrappedrr   r1   r1   r2   _max_len  s   

r   trial
param_keysmetric_keysc                    sH   j  tjg}|fdd|D  | fdd|D  |S )zReturns the following information about a trial:

    name | status | metrics...

    Args:
        trial: Trial to get information for.
        param_keys: Names of parameters to include.
        metric_keys: Names of metrics to include.
    c                    s    g | ]}t t| jd dqS Nry   )r   r   r$   )re   param)r   r1   r2   rf   6  s    z#_get_trial_info.<locals>.<listcomp>c                    s   g | ]}t t| d dqS r   )r   r   )re   rs   )rr   r1   r2   rf   ?  s    )rl   r-   r_   extend)r   r   r   Z
trial_infor1   )rr   r   r2   _get_trial_info%  s   
	
r   r_   force_max_rowsc           
      C   sp   |rdnt j}|sdS t }d}|D ] }t||kr)t|| }	|	 d|  } n
|t||| qt||S )aS  Gather all information of trials pertained to one `status`.

    Args:
        status: The trial status of interest.
        trials: all the trials of that status.
        param_keys: *Ordered* list of parameters to be displayed in the table.
        metric_keys: *Ordered* list of metrics to be displayed in the table.
            Including both default and user defined.
        force_max_rows: Whether or not to enforce a max row number for this status.
            If True, only a max of `5` rows will be shown.

    Returns:
        All information of trials pertained to the `status`.
       Nz more )mathinfr^   rp   rE   r   r~   )
r_   r[   r   r   r   Zmax_rowr   r   ra   	remainingr1   r1   r2    _get_trial_table_data_per_statusI  s   
r   all_rowswrap_headersc                    s   d}d t }fdd|D } fdd|D } fdd|D }dd t||D }	|}
ddg|
 |	 }t }tD ]}t||| ||| oOt|kd	}|rY|| q>t||S )
as  Generate a table showing the current progress of tuning trials.

    Args:
        trials: List of trials for which progress is to be shown.
        param_keys: Ordered list of parameters to be displayed in the table.
        metric_keys: Ordered list of metrics to be displayed in the table.
            Including both default and user defined.
            Will only be shown if at least one trial is having the key.
        all_rows: Force to show all rows.
        wrap_headers: If True, header columns can be wrapped with ``
``.

    Returns:
        Trial table data, including header and trial table per each status.
    r   c                    s&   g | ] t  fd dD r qS )c                 3   s$    | ]}t  |jd dd uV  qd S r   )r   rl   rd   kr1   r2   	<genexpr>  s
    
z3_get_trial_table_data.<locals>.<listcomp>.<genexpr>)any)re   rg   r   r2   rf     s    z)_get_trial_table_data.<locals>.<listcomp>c                       g | ]	}t | d qS )r   r   r   re   r   max_column_lengthr   r1   r2   rf         c                    r   r   r   r   r   r1   r2   rf     r   c                 S   s$   g | ]\}}|t v rt | n|qS r1   )rm   )re   rs   	formattedr1   r1   r2   rf     s    
Trial namer_   )r   r   r   )rb   zipr^   ORDERr   rp   rE   r   )r[   r   r   r   r   Zmax_trial_num_to_showr`   Zformatted_metric_columnsZformatted_param_columnsZmetric_headerZparam_headerr   Z
trial_dataZt_statusZtrial_data_per_statusr1   )r   r[   r   r2   _get_trial_table_datan  s<   



r   c                    sZ   t || jdd}| jdi  t  } fdd|D }d| j d| d| d	| S )
z:Returns a readable message stating the current best trial.Nry   r$   c                    s   i | ]}|t | qS r1   )r   )re   pr$   r1   r2   
<dictcomp>  s    z#_best_trial_str.<locals>.<dictcomp>zCurrent best trial: z with =z and params=)r   rl   r?   r^   rq   r%   )r   rs   rI   Zparameter_columnsrG   r1   r   r2   _best_trial_str  s   r   rN   rH   itemprefixc                 c   s    ||  } t |tjr|j}t |tr| |ddfV  d S t |trBt|}t|	 D ]\}}| d t
| t|fV  q.d S | t|dfV  d S )Nz.5fr<   /r   )r@   argparse	Namespace__dict__r{   rstripdictr   sortedrD   r-   r   )rH   r   r   Z	flattenedr   vr1   r1   r2   _render_table_item  s   

r   r   includeexclude
upper_keysc           
      C   s   |pt  }|p	t  }|pt  }g }g }t|  D ]8\}}||v r"qtt||D ]'\}}	||v r2q)|r=||vr=||vr=q)||v rI|||	g q)|||	g q)q|sV|S |sZ|S || S )a  Get ``data`` dict as table rows.

    If specified, excluded keys are removed. Excluded keys can either be
    fully specified (e.g. ``foo/bar/baz``) or specify a top-level dictionary
    (e.g. ``foo``), but no intermediate levels (e.g. ``foo/bar``). If this is
    needed, we can revisit the logic at a later point.

    The same is true for included keys. If a top-level key is included (e.g. ``foo``)
    then all sub keys will be included, too, except if they are excluded.

    If keys are both excluded and included, exclusion takes precedence. Thus, if
    ``foo`` is excluded but ``foo/bar`` is included, it won't show up in the output.
    )setr   rD   r   r-   rE   )
r   r   r   r   upperlowerrH   r.   r   r   r1   r1   r2   _get_dict_as_table_data  s,   


r   utfu   ╭u   ─u   ╮u   ├u   ┤u   ╰u   ╯u   │ r*   )Z	lineaboveZlinebelowheaderZlinebetweenrowsZ	linebelowZ	headerrowZdatarowpaddingZwith_header_hide+-|r   divisionc                 C   s@   t | |||d}|r|dgng }|sd S tt||dtd d S )N)r   r   r   r   rN   )leftright)headerscolaligntablefmt)r   printr   AIR_TABULATE_TABLEFMT)r   r   r   r   r   
table_datar   r1   r1   r2   _print_dict_as_table+  s   r   c                   @   s  e Zd ZdZdZdZdZdZdZ	d<de	de
eee eeeef  f  fddZede	fd	d
Z	d<de
e fddZdefddZdd Zded fddZ	d<dededededede
e fddZedd  Zd!d"d#efd$d%Zd!d"d#efd&d'Zd=d(e
e d#efd)d*Zd+d, Zd-edee  d.e d(efd/d0Z!d-edee  d.e fd1d2Z"d-eded d.dfd3d4Z#d-eded d.dfd5d6Z$d-edee  d.e d7e%fd8d9Z&d-edee  d.e fd:d;Z'dS )>ProgressReporterz&Periodically prints out status update.   N	verbosityprogress_metricsc                 C   s:   || _ t | _td| _t | _|| _i | _d| _dS )zC

        Args:
            verbosity: AirVerbosity level.
        rx   N)
_verbositytime_start_timer{   _last_heartbeat_time_progress_metrics_trial_last_printed_results	_in_block)r0   r   r   r1   r1   r2   __init__P  s   




zProgressReporter.__init__r:   c                 C   s   | j S r,   )r   r/   r1   r1   r2   r   c  s   zProgressReporter.verbosityrK   c                 K   s
   || _ d S r,   )r   )r0   rK   kwargsr1   r1   r2   setupg  s   
zProgressReporter.setup	indicatorc                 C   s   | j |kr	|   || _ d S r,   )r   
_end_block)r0   r   r1   r1   r2   _start_blockn  s   

zProgressReporter._start_blockc                 C   s   | j rtd d | _ d S )NrN   )r   r   r/   r1   r1   r2   r   s  s   
zProgressReporter._end_blockr[   r   c                 K   s   |    d S r,   )r   )r0   r[   infor1   r1   r2   on_experiment_endx  s   z"ProgressReporter.on_experiment_endexperiment_nameexperiment_pathsearcher_strscheduler_strtotal_num_samplestensorboard_pathc                 K   s4   |  d td|  |rtd| d d S d S )NZ	exp_startz
View detailed results here: zGTo visualize your results with TensorBoard, run: `tensorboard --logdir `)r   r   )r0   r   r   r   r   r   r   r   r1   r1   r2   experiment_started{  s   

z#ProgressReporter.experiment_startedc                 C   s$   t | jt \}}d| d| S )NzCurrent time: . Total running time: )rZ   r   r   )r0   Zcurrent_time_strrunning_time_strr1   r1   r2   _time_heartbeat_str  s
   
z$ProgressReporter._time_heartbeat_strFforcer   c                G   sR   | j | jk rd S |st | j | jkr'| j|g|R d|i t | _d S d S )Nr   )r   _heartbeat_thresholdr   r   _heartbeat_freq_print_heartbeatr0   r[   r   argsr1   r1   r2   print_heartbeat  s   z ProgressReporter.print_heartbeatc                G      t r,   NotImplementedErrorr   r1   r1   r2   r        z!ProgressReporter._print_heartbeatrr   c                 C   sh   |p|j }| j|jd}|td}||ks|r2t|| j| d| jt	t
d || j|j< dS dS )zHOnly print result if a different result has been reported, or force=Truer   z result)r   r   r   r   N)rl   r   r?   r%   r   r   _addressing_tmplformatr   BLACKLISTED_KEYSr   )r0   r   rr   r   Zlast_result_iterZ	this_iterr1   r1   r2   _print_result  s   
zProgressReporter._print_resultc                 C   s    t |j| j| dd d S )Nz config)r   )r   r$   r  r  )r0   r   r1   r1   r2   _print_config  s   
zProgressReporter._print_config	iterationr   c                 K   sx   | j | jk rd S | d| d|t   t| jt \}}t| j	| d|t  d| d|  | 
|| d S )Ntrial__result_z finished iteration z at r   )r   _intermediate_result_verbosityr   r   rZ   r   r   r   r  r  r  )r0   r	  r[   r   rr   r   curr_time_strr   r1   r1   r2   on_trial_result  s   z ProgressReporter.on_trial_resultc                 K   s   | j | jk rd S t| jt \}}d}|jr!t|jv r!|jt }| d| d t| j	
| d| d| d|  | | d S )Nr   r
  Z	_completez completed after  iterations at r   )r   _start_end_verbosityrZ   r   r   rl   r   r   r   r  r  r  r0   r	  r[   r   r   r  r   Zfinished_iterr1   r1   r2   on_trial_complete  s"   
z"ProgressReporter.on_trial_completec              
   K   s   t | jt \}}d}|jrt|jv r|jt }| d| d t| j| d| d| d| d|j	 	 | 
| d S )Nr   r
  _errorz errored after r  r   z
Error file: )rZ   r   r   rl   r   r   r   r  r  rc   r  r  r1   r1   r2   on_trial_error  s"   
zProgressReporter.on_trial_errorc                 K   s   | j d|||d| d S )N)r	  r[   r   r1   )r  )r0   r	  r[   r   r   r1   r1   r2   on_trial_recover  s   z!ProgressReporter.on_trial_recover
checkpointc                 K   s~   | j | jk rd S d}|jrt|jv r|jt }| d| d|  d|jj d|j }t| j	
| d| d|  d S )N?r
  r  ()z" saved a checkpoint for iteration z at: )r   r  rl   r   r   
filesystem	type_namepathr   r  r  )r0   r	  r[   r   r  r   Z
saved_iterlocr1   r1   r2   on_checkpoint  s   
zProgressReporter.on_checkpointc                 K   sn   | j | jk rd S t|j}| d| d |r*t| j| d | | d S t| j| d d S )Nr
  _startz started with configuration:z& started without custom configuration.)	r   r  r   r$   r   r   r  r  r  )r0   r	  r[   r   r   Z
has_configr1   r1   r2   on_trial_start  s   
zProgressReporter.on_trial_startr,   )NF)(r4   r5   r6   __doc__r   r   r  r  r  r)   r	   r   r   r-   r   r   propertyr   r{   r   r   r   r   r   rA   r   r   r   r   r   r  r  r   r  r  r  r  r   r  r   r1   r1   r1   r2   r   E  s    









r   r   num_samples
entrypointr   c                 C   s<   |t jt jt jhv rt| |||||d}|S t| |d}|S )N)r#  rs   ru   r$   r   )r   )r   ZTUNE_RUNZTUNE_RUN_EXPERIMENTSZTUNERTuneTerminalReporterTrainReporter)r   r#  r$  rs   ru   r$   r   reporterr1   r1   r2   _detect_reporter  s    	
r(  c                       s   e Zd ZejZdZejZejZ	dZ
					ddededee dee d	ee d
eeee eeeef  f  f fddZ		ddee dee f fddZdd Zdddedeee ef fddZdddefddZ  ZS )TuneReporterBaseFzTrial {}r   Nr   r#  rs   ru   r$   r   c                    s>   || _ || _|| _d | _t|pi | _tt| j||d d S )N)r   r   )	_num_samples_metric_mode_inferred_metricrJ   _inferred_paramssuperr)  r   )r0   r   r#  rs   ru   r$   r   	__class__r1   r2   r   ?  s   	

zTuneReporterBase.__init__rK   total_samplesc                    s   t  j|d || _d S )N)rK   )r/  r   r*  )r0   rK   r2  r   r0  r1   r2   r   R  s   
zTuneReporterBase.setupc                 C   s&   d dd t| D }d| S )Nz | c                 S   s"   g | ]\}}t | d | qS )r   )rp   )re   r_   r[   r1   r1   r2   rf   ]  s    zDTuneReporterBase._get_overall_trial_progress_str.<locals>.<listcomp>zTrial status: )r   rb   rD   )r0   r[   rr   r1   r1   r2   _get_overall_trial_progress_str[  s   

z0TuneReporterBase._get_overall_trial_progress_strforce_full_outputr5  r:   c          	      G   s   t  }|| | || j || t|| j| j\}}|r*|t|| | j	s2t
|| _	t t | j	 }t|| j||| jd}||fS )N)r   r   r   r   )r^   rE   r3  r   r   r}   r+  r,  r   r-  rt   rm   rq   r   r.  _wrap_headers)	r0   r[   r5  sys_argsrr   Zcurrent_best_trialrs   Zall_metricsZtrial_table_datar1   r1   r2   _get_heartbeate  s(   


zTuneReporterBase._get_heartbeatr   r   c                G   r   r,   r   )r0   r[   r   r7  r1   r1   r2   r     r  z!TuneReporterBase._print_heartbeat)r   NNNNrv   )r4   r5   r6   r)   r7   r   r6  r8   r  r  r  rA   r	   r-   r   r   r   r   r{   r   r3  r   r
   r   r8  r   __classcell__r1   r1   r0  r2   r)  8  sN    	
 r)  c                       sR   e Zd Z	ddedededededee f fdd	Zd
ddefddZ  Z	S )r%  Nr   r   r   r   r   r   c           	   	      sd   |t jkrd}nt|}ttd|gd|gd|ggd|gtd t jd||||||d| d S )	NZinfinitezSearch algorithmZ	SchedulerzNumber of trialszConfiguration for experiment)r   r   )r   r   r   r   r   r   r1   )sysmaxsizer-   r   r   r   r/  r   )	r0   r   r   r   r   r   r   r   Ztotal_num_samples_strr0  r1   r2   r     s.   


z'TuneTerminalReporter.experiment_startedFr   r   c                G   s,  | j | jk r
|s
d S | j|g|R d|i\}}| d |D ]}t| qg }g }|j}	|jD ]}
||
j |
j	rA|
|
j	 q0tt||	tdd |rUtd| |sYd S t|}|sad S | d tdt|  g d}	d	d
 |D }tt||	tddd tdd |D rtd d S d S )Nr5  	heartbeatF)r   r   	showindexz, Zstatus_erroredzNumber of errored trials: )r   z
# failuresz
error filec                 S   s8   g | ]}t |t |jj|jtjkrd nd |jgqS )rN   *)r-   Zrun_metadataZnum_failuresr_   r   ERRORrc   re   r   r1   r1   r2   rf     s    
z9TuneTerminalReporter._print_heartbeat.<locals>.<listcomp>)r   r   r   )r   r   r=  r   c                 s   s    | ]	}|j tjkV  qd S r,   )r_   r   
TERMINATEDr@  r1   r1   r2   r     s    z8TuneTerminalReporter._print_heartbeat.<locals>.<genexpr>z3* The trial terminated successfully after retrying.)r   r   r8  r   r   r   r   r   r   r   rE   r   r   r   rh   rp   r   )r0   r[   r   r7  Zheartbeat_strsr   rP   Z
more_infosZall_dataZfail_headerZ	sub_tableZtrials_with_errorZfail_table_datar1   r1   r2   r     sj   




		z%TuneTerminalReporter._print_heartbeatr,   )
r4   r5   r6   r-   rA   r	   r   r   r   r9  r1   r1   r0  r2   r%    s     $r%  c                       st   e Zd ZejZejZejZdZ	dde
e defddZdddefd	d
Zdede
e dedef fddZ  ZS )r&  ZTrainingFr[   r5  c                 C   sz   t |dkrd S |d }|jtjkrdd|j d| jgS |jr't|jvr*d}n|jt d }dd| d| jgS )Nr   r   zTraining is in z status.r*   zTraining on iteration .)rp   r_   r   RUNNINGr   r   rl   r   )r0   r[   r5  r   Ziter_numr1   r1   r2   r8    s   zTrainReporter._get_heartbeatr   r   c                G   s   t | j||d d S )Nr4  )r   r8  r   r1   r1   r2   r     s   zTrainReporter._print_heartbeatr	  r   rr   c                    s*   t   | _t jd||||d| d S )N)r	  r[   r   rr   r1   )r   r   r/  r  )r0   r	  r[   r   rr   r   r0  r1   r2   r    s   

zTrainReporter.on_trial_resultF)r4   r5   r6   r)   r8   r   r7   r  r  r  r   r   r   r8  r   rA   r   r  r9  r1   r1   r0  r2   r&    s     r&  )ri   )r   FrD  )FF)rN   )NNN)NNNN)NNNNN)rr   r\   rQ   loggingr   r   r=   r:  r   r   dataclassesr   enumr   typingr   r   r   r   r   r	   r
   r   numpynpZpandasr|   ZrayZray._private.dictr   r   Z)ray._private.thirdparty.tabulate.tabulater   r   r   r   Zray.air._internal.usager   Zray.air.constantsr   Zray.tuner   Zray.tune.callbackr   Zray.tune.experiment.trialr   Zray.tune.resultr   r   r   r   r   r   Zray.tune.search.sampler   Zray.tune.utils.logr   richZrich.layoutZ	rich.liveImportError	getLoggerr4   loggerrk   rm   r  rA   r{   Zfloat32Zfloat64Zint32Zint64rn   ro   rC  rA  ZPAUSEDPENDINGr?  r   r)   ZwidgetsutilZin_notebookZIS_NOTEBOOKrC   r-   rJ   rZ   rb   rh   rt   r}   r~   r   r   r   r   r   r   r   r   r   stdoutencoding
startswithr   r   r   r(  r)  r%  r&  r1   r1   r1   r2   <module>   s   ( 
		
"( 
!
)
)
E


"8







 \
Qd