
    Mi                     D   S SK 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  S SKrS SKrS SKJr  SSKJr  SSKJr  \(       a  SSKJr  S	S
.S\	\   S\	\   S\S\\	\   \	\   \	\   4   4S jjr   SS\S\S\
\\\4      4S jjr   SS\
\   S\S\
\\\4      4S jjrg)    N)Path)	IOTYPE_CHECKINGAnyCallableDictListOptionalTupleUnion)Printer   )util)Errors)Language   )	max_widthcolswidthsr   returnc                     / n/ n[        X5       Hb  u  pV[        U5      U:  a  US US-
   S-   nUR                  UR                  5       5        UR                  [	        [        U5      U5      5        Md     X4U Vs/ s H  nSPM     sn4$ s  snf )N   z...r)ziplenappenduppermax)r   r   r   
final_colsfinal_widthscolwidth_s           p/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/spacy/training/loggers.pysetup_tabler%      s     JL$'
s8io	A&.C#))+&CC%01	 (
 <%@<ac<%@@@%@s   ;Bprogress_barconsole_outputoutput_filec                 &    [        U SL a  SOSUUS9$ )aw  The ConsoleLogger.v2 prints out training logs in the console and/or saves them to a jsonl file.
progress_bar (bool): Whether the logger should print a progress bar tracking the steps till the next evaluation pass.
console_output (bool): Whether the logger should print the logs on the console.
output_file (Optional[Union[str, Path]]): The file to save the training logs to.
FNevalr&   r'   r(   )console_logger_v3r+   s      r$   console_loggerr-      s#     )U2T%     c                   ^ ^^^ SmT(       ak  [         R                  " T5      mTR                  5       (       a  SmTR                  S   R                  5       (       d  TR                  S   R	                  SS9  [
        R                  [
        R                  4SSS[        S[        S	[        [        [        [        [        [        4      /S
4   [        / S
4   4   4UUUU 4S jjjnU$ )a`  The ConsoleLogger.v3 prints out training logs in the console and/or saves them to a jsonl file.
progress_bar (Optional[str]): Type of progress bar to show in the console. Allowed values:
    train - Tracks the number of steps from the beginning of training until the full training run is complete (training.max_steps is reached).
    eval - Tracks the number of steps between the previous and next evaluation (training.eval_frequency is reached).
console_output (bool): Whether the logger should print the logs on the console.
output_file (Optional[Union[str, Path]]): The file to save the training logs to.
FTr   )parentsnlpr   stdoutstderrr   Nc                   >^^^^^^^^^^^^^ U4S jm[        SS9mS mT(       a  T" TR                  ST S35      5        S mO,T(       a%  T" TR                  ST 35      5        [        TSSS	9mU R                   VVs/ s H-  u  p4[        US
5      (       d  M  UR                  (       d  M+  UPM/     snnmU R                  S   S   mU R                  S   S   mU R                  S   S   nUR                  5        VVs/ s H  u  pgUc  M
  UPM     snnmT Vs/ s H  nSU 3PM
     n	nT(       a  Sm[        SS/U	-   T-   S/-   SS/U	 V
s/ s H  n
SPM     sn
-   T V
s/ s H  n
SPM     sn
-   S/-   S9u  nmmT" TR                  UTTS95        T" TR                  T Vs/ s H  nSU-  PM
     snTS95        S mSnTb-  TU;  a'  [        [        R                  R                  TUS95      eS[        [         ["        [$        4      SS 4UUUUUUUUUUUUUU4S jjnS!U4S  jjnX4$ s  snnf s  snnf s  snf s  sn
f s  sn
f s  snf )"Nc                    > [        U TSS9$ )NT)fileflush)print)textr2   s    r$   <lambda>:console_logger_v3.<locals>.setup_printer.<locals>.<lambda>G   s    U4fDAr.   T)no_printz Saving logs is disabled because z already exists.zSaving results to wzutf-8)encodingis_trainabletraining	max_stepseval_frequencyscore_weightszLoss r   E#Scorer         )r   r   )r   spacing-)rI   )trainr*   )
unexpectedexpectedinfor   c           	      $  > U c  Tb  TR                  S5        g / n0 nT HE  nUR                  SR                  [        U S   U   5      5      5        [        U S   U   5      X#'   MG     / n0 nT H\  nU S   R	                  US5      n [        U5      nUS:w  a  US-  nUR                  SR                  U5      5        Xu[        U5      '   M^     U S	   U S
   /U-   U-   SR                  [        U S   5      5      /-   n	T(       aB  U S	   U S
   UU[        U S   5      S.n
TR                  [        R                  " U
5      S-   5        Tb  TR                  5         T(       ao  T" TR                  U	TTTS95        T(       aO  TS:X  a  TnSU S	    3nU S
   nOTnSU S	   S-    3nSn[         R                   " US STUS9mTR#                  U5        g g g ! [
         a4    [        R                  R                  U[        U5      S9n[        U5      S ef = f)N   z{0:.2f}lossesother_scoresg        )name
score_typespeedd   epochstepscore)rW   rX   rQ   scoresrY   
)r   alignsrI   rK   zLast Eval Epoch: zEpoch r   F)totaldisableleaver6   initial)updater   formatfloatget	TypeErrorr   E916type
ValueErrorstrwritesrsly
json_dumpscloserowtqdmset_description)rN   rQ   
log_losses	pipe_namerZ   
log_scoresr!   rY   errdatalog_datar]   descr`   r'   rB   logged_pipesrA   msgoutput_streamprogressr&   
score_colsrI   r3   table_alignstable_widthsrj   s                 r$   log_step:console_logger_v3.<locals>.setup_printer.<locals>.log_stept   sf    |'OOA&FJ)	i..uT(^I5N/OPQ(-d8nY.G(H
% * FJ!^,00c:4!%LE '>SLEi..u56',3s8$ " gV- ##E$w-$89:;   "'] L(("4=1 ##E$4$4X$>$EF# GG\,PW  
  #w. )!24=/B"&v, .!'W(9':;"##yy# $## ' H ,,T2#   9 ! 4 ++,,#$u+,NC$S/t34s   G>Hc                  6   > T (       a  T R                  5         g g )N)rm   )rz   s   r$   finalize:console_logger_v3.<locals>.setup_printer.<locals>.finalize   s    ##% r.   )r   N)r   warnrN   openpipelinehasattrr?   configitemsr%   rn   rh   r   E1048rb   r
   r   ri   r   )r1   r2   r3   rS   procrC   r!   valuepipe	loss_colsr#   table_headerr"   expected_progress_typesr   r   rB   rx   rA   ry   rz   r{   r|   rI   r}   r~   rj   
_log_existr'   r(   r&   s    ``             @@@@@@@@@@@r$   setup_printer(console_logger_v3.<locals>.setup_printerD   sr    Bt$ 6{mCST
 K#((/}=>? cGDM
 "ll
*
t^, 151B1B *

 JJz*;7	J/0@A

:.?,9,?,?,AW,AjcUc,AW
0<=uTF^	=G7B3Z)+j8G9D1vI 6IqI 66Z9PZ!Z9PPTUSVV84L, #'',|W'MN#''LAL53;LA7'ST"3#<S(S##+6M $  H	38DcN3 H	3 H	3 H	3 H	3T	& !!U
 X= !79P Bs6    H/H/.H/	H5H5H;I #I&I
)r   ensure_pathexistsr0   mkdirsysr2   r3   r   r   r   r
   r   ri   r   )r&   r'   r(   r   r   s   ``` @r$   r,   r,   0   s     J&&{3J""1%,,.."(((6 '*jjszz~"~"!#~":<~"	x$sCx.12D898BH;MM	N~" ~"@ r.   )FTN)NTN)r   pathlibr   typingr   r   r   r   r   r	   r
   r   r   rk   ro   wasabir    r   errorsr   languager   ri   intr%   boolr-   r,    r.   r$   <module>r      s    
  W W W     # =?
A#Y
A $S	
A69
A
49d3ic*+
A  .2 %T	*+$ #'.2T3-TT %T	*+Tr.   