/usr/local/lib/python3.6/site-packages/transformers/utils/__pycache__
NameSizeModeActions
doc.cpython-36.pyc345520644editdlrm
dummy_detectron2_objects.cpython-36.pyc7650644editdlrm
dummy_flax_objects.cpython-36.pyc476390644editdlrm
dummy_pt_objects.cpython-36.pyc2099100644editdlrm
dummy_pytorch_quantization_and_torch_objects.cpython-36.pyc38530644editdlrm
dummy_scatter_objects.cpython-36.pyc20440644editdlrm
dummy_sentencepiece_and_speech_objects.cpython-36.pyc6410644editdlrm
dummy_sentencepiece_and_tokenizers_objects.cpython-36.pyc4580644editdlrm
dummy_sentencepiece_objects.cpython-36.pyc76300644editdlrm
dummy_speech_objects.cpython-36.pyc6130644editdlrm
dummy_tf_objects.cpython-36.pyc985960644editdlrm
dummy_timm_and_vision_objects.cpython-36.pyc16240644editdlrm
dummy_timm_objects.cpython-36.pyc16470644editdlrm
dummy_tokenizers_objects.cpython-36.pyc147460644editdlrm
dummy_vision_objects.cpython-36.pyc65940644editdlrm
fx.cpython-36.pyc179760644editdlrm
fx_transformations.cpython-36.pyc95630644editdlrm
generic.cpython-36.pyc104930644editdlrm
hp_naming.cpython-36.pyc37510644editdlrm
hub.cpython-36.pyc316490644editdlrm
import_utils.cpython-36.pyc227740644editdlrm
logging.cpython-36.pyc95570644editdlrm
model_parallel_utils.cpython-36.pyc19760644editdlrm
notebook.cpython-36.pyc121900644editdlrm
sentencepiece_model_pb2.cpython-36.pyc128230644editdlrm
versions.cpython-36.pyc30620644editdlrm
__init__.cpython-36.pyc46450644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/utils/__pycache__/notebook.cpython-36.pyc (12190B)
3 Eg8@sddlZddlZddlmZddljZddlmZddl m Z m Z ddZ dd d Z d d ZGd ddZGdddeZGdddeZdS)N)Optional)TrainerCallback)IntervalStrategy has_lengthcCsZt|}|d|dd|d}}}|dkrH|d|dd|dS|dd|dS)z$Format `t` (in seconds) to (h):mm:ssi<r:Z02d)int)thmsrE/usr/local/lib/python3.6/site-packages/transformers/utils/notebook.py format_times r,c Cs$d|d|d|d|d|d S)Nz
z z
r)valuetotalprefixlabelwidthrrrhtml_progress_bar!srcCsd}|d7}x |dD]}|d|d7}qW|d7}x\|ddD]L}|d 7}x6|D].}t|trl|d nt|}|d |d 7}qVW|d 7}qDW|d7}|S)z*Put the texts in `items` in an HTML table.z% z* rz z Nz z.6fz z z
z
z

) isinstancefloatstr)items html_codeilineeltrrrtext_to_html_table,s  r!c@sfeZdZdZdZdZdeeee ededd d Z dee ed d dZ dddZ ddZ ddZdS)NotebookProgressBara A progress par for display in a notebook. Class attributes (overridden by derived classes) - **warmup** (`int`) -- The number of iterations to do at the beginning while ignoring `update_every`. - **update_every** (`float`) -- Since calling the time takes some time, we only do it every presumed `update_every` seconds. The progress bar uses the average time passed up until now to guess the next value for which it will call the update. Args: total (`int`): The total number of iterations to reach. prefix (`str`, *optional*): A prefix to add before the progress bar. leave (`bool`, *optional*, defaults to `True`): Whether or not to leave the progress bar once it's completed. You can always call the [`~utils.notebook.NotebookProgressBar.close`] method to make the bar disappear. parent ([`~notebook.NotebookTrainingTracker`], *optional*): A parent object (like [`~utils.notebook.NotebookTrainingTracker`]) that spawns progress bars and handle their display. If set, the object passed must have a `display()` method. width (`int`, *optional*, defaults to 300): The width (in pixels) that the bar will take. Example: ```python import time pbar = NotebookProgressBar(100) for val in range(100): pbar.update(val) time.sleep(0.07) pbar.update(100) ```g?NT,NotebookTrainingTracker)rrleaveparentrcCs@||_|dkrdn||_||_||_||_d|_d|_d|_dS)N)rrr&r'r last_valuecommentoutput)selfrrr&r'rrrr__init__eszNotebookProgressBar.__init__F)r force_updater*cCs|||_|dk r||_|jdkrbtj|_|_||_|_d|_|_|j |_ d|_ |j |n||jkrv| rvdS|s|j dks|t |j|j |jkrx|j dkr|j d8_ tj}||j|_||jkr|j||j|_nd|_||jkr|j}d|_|js6|jn|jdk r6|j|j||_|j |||_||_|jdkr`d|_ ntt|j|jd|_ dS)a The main method to update the progress bar to `value`. Args: value (`int`): The value to use. Must be between 0 and `total`. force_update (`bool`, *optional*, defaults to `False`): Whether or not to force and update of the internal state and display (by default, the bar will wait for `value` to reach the value it predicted corresponds to a time of more than the `update_every` attribute since the last update to avoid adding boilerplate). comment (`str`, *optional*): A comment to add on the left of the progress bar. Nrr)rr*r)time start_timeZ last_timeZ start_value elapsed_timepredicted_remainingwarmupZ first_callswait_for update_barminraverage_time_per_itemr&closemaxr update_every)r,rr.r* current_timerrrupdatevsB   (        zNotebookProgressBar.updatec Csdtt|jtt|t|}|jdkrHd|d|jd|_nv|jdkrtd|d|jdt|j|_nJd|d|jdt|jdt|j|_|jdd|jdd 7_|j|jdkst|jd krd n d|jd 7_|j dS) N [/z : < :z < z, rz.2fz it/sr]) lenrrr1rr2rr7r*display)r,rr*Z spaced_valuerrrr5s&  ",4zNotebookProgressBar.update_barcCspt|j|j|j|j|j|_|jdk r4|jjdS|j dkrXt jt j |jdd|_ n|j j t j |jdS)NT) display_id) rrrrrrrr'rBr+dispHTMLr<)r,rrrrBs   zNotebookProgressBar.displaycCs*|jdkr&|jdk r&|jjtjddS)zCloses the progress bar.Nr()r'r+r<rDrE)r,rrrr8szNotebookProgressBar.close)NTNr$)FN)N)__name__ __module__ __qualname____doc__r3r:r rrboolr-r<r5rBr8rrrrr"=s# 4  r"csDeZdZdZdfdd ZddZddZdd d Zd d ZZ S)r%a An object tracking the updates of an ongoing training with progress bars and a nice table reporting metrics. Args: num_steps (`int`): The number of steps during training. column_names (`List[str]`, *optional*): The list of column names for the metrics table (will be inferred from the first call to [`~utils.notebook.NotebookTrainingTracker.write_line`] if not set). Ncs*tj||dkrdn|g|_d|_dS)N)superr- inner_table child_bar)r,Z num_steps column_names) __class__rrr-s z NotebookTrainingTracker.__init__cCst|j|j|j|j|j|_|jdk r:|jt|j7_|j dk rV|j|j j7_|j dkrzt j t j |jdd|_ n|j jt j |jdS)NT)rC)rrrrrrrrLr!rMr+rDrBrEr<)r,rrrrBs   zNotebookTrainingTracker.displaycs|jdkr&tjtjg|_n`|jd}t|jdkrlx"jD]}||krH|j|qHW||jd<|jjfdd|DdS)z Write the values in the inner table. Args: values (`Dict[str, float]`): The values to display. Nrrcsg|] }|qSrr).0c)valuesrr sz6NotebookTrainingTracker.write_line..)rLlistkeysrRrAappend)r,rRcolumnskeyr)rRr write_lines   z"NotebookTrainingTracker.write_line,cCst||||d|_|jS)a Add a child progress bar displayed under the table of metrics. The child progress bar is returned (so it can be easily updated). Args: total (`int`): The number of iterations for the child progress bar. prefix (`str`, *optional*): A prefix to write on the left of the progress bar. width (`int`, *optional*, defaults to 300): The width (in pixels) of the progress bar. )rr'r)r"rM)r,rrrrrr add_childs z!NotebookTrainingTracker.add_childcCsd|_|jdS)z0 Closes the child progress bar. N)rMrB)r,rrr remove_childsz$NotebookTrainingTracker.remove_child)N)NrZ) rFrGrHrIr-rBrYr[r\ __classcell__rr)rOrr%s    r%c@sNeZdZdZddZddZddZdd d Zdd d Zdd dZ ddZ dS)NotebookProgressCallbackz A [`TrainerCallback`] that displays the progress of training or evaluation, optimized for Jupyter Notebooks or Google colab. cCsd|_d|_d|_dS)NF)training_trackerprediction_bar_force_next_update)r,rrrr-sz!NotebookProgressCallback.__init__cKsX|jtjkrdnd|_d|_d|_|jgdg}|jtjkrF|jdt|j ||_ dS)NEpochSteprz Training LosszValidation Loss) evaluation_strategyrEPOCH first_columnZ training_lossZlast_logNOrVr%Z max_stepsr_)r,argsstatecontrolkwargsrNrrron_train_begins  z'NotebookProgressCallback.on_train_begincKsVt|j|jkrt|jn|jd}|jj|jdd|d|j|jdd|_dS)Nz.2frzEpoch r?)r*r.F)r epochr_r< global_stepnum_train_epochsra)r,rhrirjrkrmrrr on_step_ends $ z$NotebookProgressCallback.on_step_endNcKsht|s dS|jdkrP|jdk r4|jjt||_ntt||_|jjdn|jj|jjddS)Nr)rr`r_r[rAr"r<r)r,rhrirjZeval_dataloaderrkrrron_prediction_step's  z+NotebookProgressCallback.on_prediction_stepcKs:|jtjkr6d|kr6d|di}|j|d<|jj|dS)Nlossz Training Lossrc)rdrrgrnr_rY)r,rhrirjZlogsrkrRrrron_log3s  zNotebookProgressCallback.on_logcKs`|jdk r\ddd}x(t|jD]}d|kr"|d|d<Pq"W|jdkrZt|j|d<n |j|d<d}x$|D]} | jdrntj d d | }qnW|j d d} |j d d} |j |d d} |j |dd} |j |dd} x\|j D]P\} } | |dkr| |d<q| j d} dj dd| ddD} | || <qW|jj||jjd|_d|_dS)NzNo log)z Training LosszValidation Lossrrz Training LossrbrcevalZ_lossz\_loss$r(Z total_flosrmZ_runtimeZ_samples_per_secondZ_steps_per_secondzValidation Loss_r=cSsg|] }|jqSr) capitalize)rPpartrrrrSUsz8NotebookProgressCallback.on_evaluate..rT)r_reversedZ log_historyrfr rmrnendswithresubpoprsplitjoinrYr\r`ra)r,rhrirjZmetricsrkrRlogZmetric_key_prefixkruvsplitsnamerrr on_evaluate;s8              z$NotebookProgressCallback.on_evaluatecKs2|jj|jdt|jd|jddd|_dS)NzEpoch r?T)r*r.)r_r<rnr rmro)r,rhrirjrkrrr on_train_end]s"z%NotebookProgressCallback.on_train_end)N)N)N) rFrGrHrIr-rlrprqrsrrrrrrr^ s   "r^)r)rzr/typingrZIPython.displayrBrDZtrainer_callbackrZ trainer_utilsrrrrr!r"r%r^rrrrs     C