+
    QV-j;†  ã                   óh  € R t ^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIHt ^RI	H
t
HtHt ^RIHt ^RIHt ]P"                  ! ]4      t] ! R R4      4       t ! R	 R
4      t] ! R R]4      4       t ! R R4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]]4      tR# )zJ
Callbacks to use with the Trainer class and customize the training loop.
N)Ú	dataclass)Útqdm)ÚIntervalStrategyÚSaveStrategyÚ
has_length)ÚTrainingArguments)Úloggingc                   óÀ   a € ] tR t^"t o Rt^ t^ t^ tRtRt	Rt
Rt^ t^ t^ tRtRtRtRtRtRtRtRtRtRtR tV 3R lR lt]V 3R	 lR
 l4       tR tR tV 3R ltRt V t!R# )ÚTrainerStateaË  
A class containing the [`Trainer`] inner state that will be saved along the model and optimizer when checkpointing
and passed to the [`TrainerCallback`].

<Tip>

In all this class, one step is to be understood as one update step. When using gradient accumulation, one update
step may require several forward and backward passes: if you use `gradient_accumulation_steps=n`, then one update
step requires going through *n* batches.

</Tip>

Args:
    epoch (`float`, *optional*):
        Only set during training, will represent the epoch the training is at (the decimal part being the
        percentage of the current epoch completed).
    global_step (`int`, *optional*, defaults to 0):
        During training, represents the number of update steps completed.
    max_steps (`int`, *optional*, defaults to 0):
        The number of update steps to do during the current training.
    logging_steps (`int`, *optional*, defaults to 500):
        Log every X updates steps
    eval_steps (`int`, *optional*):
        Run an evaluation every X steps.
    save_steps (`int`, *optional*, defaults to 500):
        Save checkpoint every X updates steps.
    train_batch_size (`int`, *optional*):
        The batch size for the training dataloader. Only needed when
        `auto_find_batch_size` has been used.
    num_input_tokens_seen (`int`, *optional*, defaults to 0):
        When tracking the inputs tokens, the number of tokens seen during training (number of input tokens, not the
        number of prediction tokens).
    total_flos (`float`, *optional*, defaults to 0):
        The total number of floating operations done by the model since the beginning of training (stored as floats
        to avoid overflow).
    log_history (`list[dict[str, float]]`, *optional*):
        The list of logs done since the beginning of training.
    best_metric (`float`, *optional*):
        When tracking the best model, the value of the best metric encountered so far.
    best_global_step (`int`, *optional*):
        When tracking the best model, the step at which the best metric was encountered.
        Used for setting `best_model_checkpoint`.
    best_model_checkpoint (`str`, *optional*):
        When tracking the best model, the value of the name of the checkpoint for the best model encountered so
        far.
    is_local_process_zero (`bool`, *optional*, defaults to `True`):
        Whether or not this process is the local (e.g., on one machine if training in a distributed fashion on
        several machines) main process.
    is_world_process_zero (`bool`, *optional*, defaults to `True`):
        Whether or not this process is the global main process (when training in a distributed fashion on several
        machines, this is only going to be `True` for one process).
    is_hyper_param_search (`bool`, *optional*, defaults to `False`):
        Whether we are in the process of a hyper parameter search using Trainer.hyperparameter_search. This will
        impact the way data will be logged in TensorBoard.
    stateful_callbacks (`list[StatefulTrainerCallback]`, *optional*):
        Callbacks attached to the `Trainer` that should have their states be saved or restored.
        Relevant callbacks should implement a `state` and `from_state` function.
iô  NTFc                ó*  € V P                   f   . V n         V P                  f
   / V n        R # \        V P                  \        4      '       d   R # / pV P                   F¬  p\        V\        4      '       g   \        R\        V4       24      hVP                  P                  pW19   dO   \        W,          \        4      '       g   W,          .W&   W,          P                  VP                  4       4       Kš  VP                  4       W&   K®  	  Wn        R # )NzNAll callbacks passed to be saved must inherit `ExportableState`, but received )Úlog_historyÚstateful_callbacksÚ
isinstanceÚdictÚExportableStateÚ	TypeErrorÚtypeÚ	__class__Ú__name__ÚlistÚappendÚstate)Úselfr   ÚcallbackÚnames   &   Ún/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/trainer_callback.pyÚ__post_init__ÚTrainerState.__post_init__t   sï   € Ø×ÑÒ#Ø!ˆDÔØ×"Ñ"Ò*Ø&(ˆDÖ#Ü˜×/Ñ/´×6Ò6áð "$ÐØ ×3Ô3�Ü! (¬_×>Ò>Ü#ØhÔimÐnvÓiwÐhxÐyóð ð  ×)Ñ)×2Ñ2�ØÔ-ô &Ð&8Õ&>Ä×EÒEØ4FÕ4LÐ3MÐ*Ñ0Ø&Õ,×3Ñ3°H·N±NÓ4DÖEà/7¯~©~Ó/?Ð&Ó,ñ 4ð '9Ö#ó    c                ó    <€ V ^8„  d   QhRS[ /# ©é   Ú	json_path©Ústr)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚTrainerState.__annotate__�   s   ø€ ÷ !ñ !¡cñ !r   c                óö   € \         P                  ! \        P                  ! V 4      ^RR7      R,           p\	        VRRR7      ;_uu_ 4       pVP                  V4       RRR4       R#   + '       g   i     R# ; i)zDSave the content of this instance in JSON format inside `json_path`.T)ÚindentÚ	sort_keysÚ
Úwúutf-8©ÚencodingN)ÚjsonÚdumpsÚdataclassesÚasdictÚopenÚwrite)r   r"   Újson_stringÚfs   &&  r   Úsave_to_jsonÚTrainerState.save_to_json�   sQ   € ä—j’j¤×!3Ò!3°DÓ!9À!ÈtÔTÐW[Õ[ˆÜ�)˜S¨7×3Õ3°qØ�G‰G�KÔ ÷ 4×3×3Ò3ús   ÁA'Á'A8	c                ó    <€ V ^8„  d   QhRS[ /# r    r#   )r%   r&   s   "€r   r'   r(   –   s   ø€ ÷ 'ñ '¡sñ 'r   c                ó¼   € \        VRR7      ;_uu_ 4       pVP                  4       pRRR4       V ! R/ \        P                  ! X4      B #   + '       g   i     L,; i)z3Create an instance from the content of `json_path`.r.   r/   N© )r5   Úreadr1   Úloads)Úclsr"   r8   Útexts   &&  r   Úload_from_jsonÚTrainerState.load_from_json•   sC   € ô �) g×.Õ.°!Ø—6‘6“8ˆD÷ /áÑ&”T—Z’Z Ó%Ñ&Ð&÷ /×.ús   –AÁA	c                ó¤   € R FI  p\        W R24      pVf   K  V^8  d   \        P                  ! W$,          4      p\        W R2V4       KK  	  R# )zt
Calculates and stores the absolute value for logging,
eval, and save steps based on if it was a proportion
or not.
Ú_stepsN)r   ÚevalÚsave)ÚgetattrÚmathÚceilÚsetattr)r   ÚargsÚ	max_stepsÚ	step_kindÚ	num_stepss   &&&  r   Úcompute_stepsÚTrainerState.compute_stepsœ   sN   € ó 5ˆIÜ ¨°6Ð&:Ó;ˆIØÔ$Ø˜q”=Ü $§	¢	¨)Õ*?Ó @�IÜ˜ ¨6Ð2°IÖ>ó 5r   c                ó&  € VP                   e/   VP                  e!   VP                  VP                  4      V n        RV n        Ve   ^ RIHp V! V4      V n        W n        W0n        VP                  4       V n        VP                  4       V n	        R# )z9
Stores the initial training references needed in `self`
N)Ú	hp_params)
Úhp_nameÚ_trialÚ
trial_nameÚtrial_paramsÚtransformers.integrationsrS   rM   Únum_train_epochsÚis_local_process_zeroÚis_world_process_zero)r   ÚtrainerrM   rY   ÚtrialrS   s   &&&&& r   Úinit_training_referencesÚ%TrainerState.init_training_references©   sx   € ð �?‰?Ò&¨7¯>©>Ò+Eð &Ÿo™o¨g¯n©nÓ=ˆDŒOØ ˆÔØÒÝ;á )¨%Ó 0ˆDÔà"ŒØ 0ÔØ%,×%BÑ%BÓ%DˆÔ"Ø%,×%BÑ%BÓ%DˆÖ"r   c                óæ  <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[R,          ;R&   S[;R	&   S[;R
&   S[ ;R&   S[S[S[S[ 3,          ,          ;R&   S[ R,          ;R&   S[R,          ;R&   S[R,          ;R&   S[;R&   S[;R&   S[;R&   S[R,          ;R&   S[S[S[S[ ,          S[,          S[,          3,          R,          ;R&   S[R,          R,          ;R&   # )r!   ÚepochÚglobal_steprM   Úlogging_stepsÚ
eval_stepsÚ
save_stepsNÚtrain_batch_sizerY   Únum_input_tokens_seenÚ
total_flosr   Úbest_metricÚbest_global_stepÚbest_model_checkpointrZ   r[   Úis_hyper_param_searchrV   rW   ÚTrainerCallbackr   )ÚfloatÚintr   r   r$   Úbool)r%   r&   s   "€r   r'   r(   "   s{  ø‡ ‚ ñz Ññ{ ñ| Ññ} ñ~ Ññ ñ@ ÑñA ñB ÑñC ñD ÑñE ñF ˜D•jÑ'ñG ñH ÑñI ñJ Ñ"ñK ñL ÑñM ñN ‘d™3¡˜:Õ&Õ'Ñ.ñO ñP ˜•Ñ$ñQ ñR ˜D•jÑ'ñS ñT  �:Ñ,ñU ñV  Ñ&ñW ñX  Ñ&ñY ñZ  Ñ'ñ[ ñ\ �d•
Ñ!ñ] ñ^ ‘s™C¡%�K©#Õ-±Õ4Ð4Õ5¸Õ<ÑCñ_ ñ` Ð.Õ/°$Õ6Ñ=òa r   )rZ   r[   r   rM   rY   r   rV   rW   )"r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ra   rb   rM   rc   rd   re   rf   rY   rg   rh   r   ri   rj   rk   rZ   r[   rl   rV   rW   r   r   r9   ÚclassmethodrB   rP   r^   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r&   s   @r   r
   r
   "   s°   ø‡ € ñ9ðv €EØ€KØ€IØ€MØ€JØ€JØ#'ÐØÐØ!"ÐØ€JØ*.€KØ $€KØ#'ÐØ(,ÐØ"&ÐØ"&ÐØ"'ÐØ!€JØ?C€LØ9=Ðò9÷6!ð !ð ÷'ó ð'ò?òE÷O ƒ r   r
   c                   óF   a € ] tR t^½t o RtV 3R lR lt]R 4       tRtV t	R# )r   a  
A class for objects that include the ability to have its state
be saved during `Trainer._save_checkpoint` and loaded back in during
`Trainer._load_from_checkpoint`.

These must implement a `state` function that gets called during the respective
Trainer function call. It should only include parameters and attributes needed to
recreate the state at a particular time, to avoid utilizing pickle/maintain standard
file IO writing.

Example:

```python
class EarlyStoppingCallback(TrainerCallback, ExportableState):
    def __init__(self, early_stopping_patience: int = 1, early_stopping_threshold: Optional[float] = 0.0):
        self.early_stopping_patience = early_stopping_patience
        self.early_stopping_threshold = early_stopping_threshold
        # early_stopping_patience_counter denotes the number of times validation metrics failed to improve.
        self.early_stopping_patience_counter = 0

    def state(self) -> dict:
        return {
            "args": {
                "early_stopping_patience": self.early_stopping_patience,
                "early_stopping_threshold": self.early_stopping_threshold,
            },
            "attributes": {
                "early_stopping_patience_counter": self.early_stopping_patience_counter,
            }
        }
```c                ó    <€ V ^8„  d   QhRS[ /# ©r!   Úreturn©r   )r%   r&   s   "€r   r'   ÚExportableState.__annotate__Þ   s   ø€ ÷ bñ b‘tñ br   c                ó   € \        R 4      h)z<You must implement a `state` function to utilize this class.)ÚNotImplementedError©r   s   &r   r   ÚExportableState.stateÞ   s   € Ü!Ð"`ÓaÐar   c                ó|   € V ! R/ VR ,          B pVR,          P                  4        F  w  r4\        W#V4       K  	  V# )rL   Ú
attributesr=   )ÚitemsrK   )r@   r   ÚinstanceÚkÚvs   &&   r   Ú
from_stateÚExportableState.from_stateá   s<   € áÑ'˜˜v�Ñ'ˆØ˜,Õ'×-Ñ-Ö/‰DˆAÜ�H Ö#ñ 0àˆr   r=   N)
r   rq   rr   rs   rt   r   ru   rŠ   rw   rx   ry   s   @r   r   r   ½   s+   ø‡ € ñ÷@bð bð ñó ör   r   c                   óh   a € ] tR t^ét o RtRtRtRtRtRt	R t
R tR tV 3R lR ltV 3R ltR	tV tR
# )ÚTrainerControlaõ  
A class that handles the [`Trainer`] control flow. This class is used by the [`TrainerCallback`] to activate some
switches in the training loop.

Args:
    should_training_stop (`bool`, *optional*, defaults to `False`):
        Whether or not the training should be interrupted.

        If `True`, this variable will not be set back to `False`. The training will just stop.
    should_epoch_stop (`bool`, *optional*, defaults to `False`):
        Whether or not the current epoch should be interrupted.

        If `True`, this variable will be set back to `False` at the beginning of the next epoch.
    should_save (`bool`, *optional*, defaults to `False`):
        Whether or not the model should be saved at this step.

        If `True`, this variable will be set back to `False` at the beginning of the next step.
    should_evaluate (`bool`, *optional*, defaults to `False`):
        Whether or not the model should be evaluated at this step.

        If `True`, this variable will be set back to `False` at the beginning of the next step.
    should_log (`bool`, *optional*, defaults to `False`):
        Whether or not the logs should be reported at this step.

        If `True`, this variable will be set back to `False` at the beginning of the next step.
Fc                ó   € RV n         R# )z<Internal method that resets the variable for a new training.FN)Úshould_training_stopr‚   s   &r   Ú_new_trainingÚTrainerControl._new_training  s
   € à$)ˆÖ!r   c                ó   € RV n         R# )z9Internal method that resets the variable for a new epoch.FN)Úshould_epoch_stopr‚   s   &r   Ú
_new_epochÚTrainerControl._new_epoch  s
   € à!&ˆÖr   c                ó0   € RV n         RV n        RV n        R# )z8Internal method that resets the variable for a new step.FN)Úshould_saveÚshould_evaluateÚ
should_logr‚   s   &r   Ú	_new_stepÚTrainerControl._new_step  s   € à ˆÔØ$ˆÔØˆŽr   c                ó    <€ V ^8„  d   QhRS[ /# r|   r~   )r%   r&   s   "€r   r'   ÚTrainerControl.__annotate__  s   ø€ ÷ 

ñ 

‘tñ 

r   c                ó†   € R RV P                   RV P                  RV P                  RV P                  RV P                  /R/ /# )rL   r�   r“   r—   r˜   r™   r…   )r�   r“   r—   r˜   r™   r‚   s   &r   r   ÚTrainerControl.state  sP   € àØ&¨×(AÑ(AØ# T×%;Ñ%;Ø˜t×/Ñ/Ø! 4×#7Ñ#7Ø˜dŸo™oðð ˜"ð	
ð 		
r   c                óV   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   # )r!   r�   r“   r—   r˜   r™   )rp   )r%   r&   s   "€r   r'   r�   é   sJ   ø‡ ‚ ñ: Ñ&ñ; ñ< Ñ#ñ= ñ> Ññ? ñ@ Ñ!ñA ñB ÑòC r   )r“   r˜   r™   r—   r�   N)r   rq   rr   rs   rt   r�   r“   r—   r˜   r™   r�   r”   rš   r   rv   rw   rx   ry   s   @r   r�   r�   é   sH   ø‡ € ñð6 "'ÐØ#ÐØ€KØ!€OØ€Jò*ò'ò ÷

ð 

÷c ƒ r   r�   c                   óD  a € ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR  ltV 3R! lR" ltR#tV tR$# )%rm   i'  a�  
A class for objects that will inspect the state of the training loop at some events and take some decisions. At
each of those events the following arguments are available:

Args:
    args ([`TrainingArguments`]):
        The training arguments used to instantiate the [`Trainer`].
    state ([`TrainerState`]):
        The current state of the [`Trainer`].
    control ([`TrainerControl`]):
        The object that is returned to the [`Trainer`] and can be used to make some decisions.
    model ([`PreTrainedModel`] or `torch.nn.Module`):
        The model being trained.
    processing_class ([`PreTrainedTokenizer` or `BaseImageProcessor` or `ProcessorMixin` or `FeatureExtractionMixin`]):
        The processing class used for encoding the data. Can be a tokenizer, a processor, an image processor or a feature extractor.
    optimizer (`torch.optim.Optimizer`):
        The optimizer used for the training steps.
    lr_scheduler (`torch.optim.lr_scheduler.LambdaLR`):
        The scheduler used for setting the learning rate.
    train_dataloader (`torch.utils.data.DataLoader`, *optional*):
        The current dataloader used for training.
    eval_dataloader (`torch.utils.data.DataLoader`, *optional*):
        The current dataloader used for evaluation.
    metrics (`dict[str, float]`):
        The metrics computed by the last evaluation phase.

        Those are only accessible in the event `on_evaluate`.
    logs  (`dict[str, float]`):
        The values to log.

        Those are only accessible in the event `on_log`.

The `control` object is the only one that can be changed by the callback, in which case the event that changes it
should return the modified version.

The argument `args`, `state` and `control` are positionals for all events, all the others are grouped in `kwargs`.
You can unpack the ones you need in the signature of the event using them. As an example, see the code of the
simple [`~transformers.PrinterCallback`].

Example:

```python
class PrinterCallback(TrainerCallback):
    def on_log(self, args, state, control, logs=None, **kwargs):
        _ = logs.pop("total_flos", None)
        if state.is_local_process_zero:
            print(logs)
```c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# ©r!   rL   r   Úcontrol©r   r
   r�   )r%   r&   s   "€r   r'   ÚTrainerCallback.__annotate__Z  ó$   ø€ ÷ ñ Ñ 1ð ¹,ð ÑQ_ñ r   c                ó   € R# )zC
Event called at the end of the initialization of the [`Trainer`].
Nr=   ©r   rL   r   r¤   Úkwargss   &&&&,r   Úon_init_endÚTrainerCallback.on_init_endZ  ó   ‚ r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   _  ó$   ø€ ÷ ñ Ñ#4ð ¹\ð ÑTbñ r   c                ó   € R# )z,
Event called at the beginning of training.
Nr=   r©   s   &&&&,r   Úon_train_beginÚTrainerCallback.on_train_begin_  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   d  ó$   ø€ ÷ ñ Ñ!2ð ¹<ð ÑR`ñ r   c                ó   € R# )z&
Event called at the end of training.
Nr=   r©   s   &&&&,r   Úon_train_endÚTrainerCallback.on_train_endd  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   i  r¯   r   c                ó   € R# )z,
Event called at the beginning of an epoch.
Nr=   r©   s   &&&&,r   Úon_epoch_beginÚTrainerCallback.on_epoch_begini  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   n  r´   r   c                ó   € R# )z&
Event called at the end of an epoch.
Nr=   r©   s   &&&&,r   Úon_epoch_endÚTrainerCallback.on_epoch_endn  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   s  s$   ø€ ÷ ñ Ñ"3ð ¹Lð ÑSañ r   c                ó   € R# )z€
Event called at the beginning of a training step. If using gradient accumulation, one training step might take
several inputs.
Nr=   r©   s   &&&&,r   Úon_step_beginÚTrainerCallback.on_step_begins  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   y  s$   ø€ ÷ ñ Ñ*;ð ÁLð Ñ[iñ r   c                ó   € R# )zf
Event called before the optimizer step but after gradient clipping. Useful for monitoring gradients.
Nr=   r©   s   &&&&,r   Úon_pre_optimizer_stepÚ%TrainerCallback.on_pre_optimizer_stepy  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   ~  s$   ø€ ÷ ñ Ñ&7ð Áð ÑWeñ r   c                ó   € R# )zm
Event called after the optimizer step but before gradients are zeroed out. Useful for monitoring gradients.
Nr=   r©   s   &&&&,r   Úon_optimizer_stepÚ!TrainerCallback.on_optimizer_step~  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   ƒ  r¯   r   c                ó   € R# )zE
Event called at the end of an substep during gradient accumulation.
Nr=   r©   s   &&&&,r   Úon_substep_endÚTrainerCallback.on_substep_endƒ  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   ˆ  s$   ø€ ÷ ñ Ñ 1ð ¹,ð ÑQ_ñ r   c                ó   € R# )zz
Event called at the end of a training step. If using gradient accumulation, one training step might take
several inputs.
Nr=   r©   s   &&&&,r   Úon_step_endÚTrainerCallback.on_step_endˆ  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   Ž  r§   r   c                ó   € R# )z)
Event called after an evaluation phase.
Nr=   r©   s   &&&&,r   Úon_evaluateÚTrainerCallback.on_evaluateŽ  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   “  s$   ø€ ÷ ñ Ñ0ð ¹ð ÑP^ñ r   c                ó   € R# )z-
Event called after a successful prediction.
Nr=   ©r   rL   r   r¤   Úmetricsrª   s   &&&&&,r   Ú
on_predictÚTrainerCallback.on_predict“  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   ˜  s#   ø€ ÷ ñ Ñ-ð ±lð É^ñ r   c                ó   € R# )z'
Event called after a checkpoint save.
Nr=   r©   s   &&&&,r   Úon_saveÚTrainerCallback.on_save˜  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   �  s#   ø€ ÷ ñ Ñ,ð ±\ð ÉNñ r   c                ó   € R# )z+
Event called after logging the last logs.
Nr=   r©   s   &&&&,r   Úon_logÚTrainerCallback.on_log�  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   ¢  s$   ø€ ÷ ñ Ñ'8ð Áð ÑXfñ r   c                ó   € R# )z'
Event called after a prediction step.
Nr=   r©   s   &&&&,r   Úon_prediction_stepÚ"TrainerCallback.on_prediction_step¢  r­   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r¦   §  s$   ø€ ÷ ñ Ñ"3ð ¹Lð ÑSañ r   c                ó   € R# )z~
Event called before pushing the model to the hub, at the beginning of Trainer.push_to_hub and Trainer._push_from_checkpoint.
Nr=   r©   s   &&&&,r   Úon_push_beginÚTrainerCallback.on_push_begin§  r­   r   r=   N)r   rq   rr   rs   rt   r«   r±   r¶   rº   r¾   rÂ   rÆ   rÊ   rÎ   rÒ   rÖ   rÜ   rà   rä   rè   rì   rw   rx   ry   s   @r   rm   rm   '  s«   ø‡ € ñ/÷bð ÷
ð ÷
ð ÷
ð ÷
ð ÷
ð ÷ð ÷
ð ÷
ð ÷
ð ÷ð ÷
ð ÷
ð ÷
ð ÷
ð ÷
ö r   rm   c                   ór  a € ] tR tRt o RtR tR tR tR t]	R 4       t
V 3R lR	 ltV 3R
 lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R  lR! ltV 3R" lR# ltV 3R$ lR% ltV 3R& lR' ltR( tR)tV tR*# )+ÚCallbackHandleri­  z>Internal class that just calls the list of callbacks in order.c                ó€  € . V n         V F  pV P                  V4       K  	  W n        W0n        W@n        WPn        R V n        R V n        \        ;QJ d&    R V P                    4       F  '       g   K   RM	  RM! R V P                    4       4      '       g)   \        P                  RV P                  ,           4       R # R # )Nc              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5i©N)r   ÚDefaultFlowCallback©Ú.0Úcbs   & r   Ú	<genexpr>Ú+CallbackHandler.__init__.<locals>.<genexpr>»  s   é € ÐPÁ¸2”:˜bÔ"5×6Ð6Ãùs   ‚TFzÔThe Trainer will not work properly if you don't have a `DefaultFlowCallback` in its callbacks. You
should add one before training with `trainer.add_callback(DefaultFlowCallback). The current list ofcallbacks is
:)Ú	callbacksÚadd_callbackÚmodelÚprocessing_classÚ	optimizerÚlr_schedulerÚtrain_dataloaderÚeval_dataloaderÚanyÚloggerÚwarningÚcallback_list)r   rù   rû   rü   rý   rþ   rö   s   &&&&&& r   Ú__init__ÚCallbackHandler.__init__°  s—   € ØˆŒÛˆBØ×Ñ˜bÖ!ñ àŒ
Ø 0ÔØ"ŒØ(ÔØ $ˆÔØ#ˆÔç‹sÑPÀÇÂÓP�s�sŠsÑPÀÇÂÓP×PÒPÜ�N‰Nð$ð ×$Ñ$õ%öñ Qr   c                ó€  € \        V\        4      '       d   V! 4       MTp\        V\        4      '       d   TMVP                  pY0P                   Uu. uF  qDP                  NK  	  up9   d2   \        P                  R V R2R,           V P                  ,           4       V P                  P                  V4       R# u upi )zYou are adding a zH to the callbacks of this Trainer, but there is already one. The currentzlist of callbacks is
:N)r   r   r   rù   r  r  r  r   )r   r   rö   Úcb_classÚcs   &&   r   rú   ÚCallbackHandler.add_callbackÃ  s“   € Ü% h´×5Ò5‰XŒZ¸8ˆÜ)¨(´D×9Ò9‘8¸x×?QÑ?QˆØ¯^ª^Ó<©^¨Ÿœ©^Ñ<Ô<Ü�N‰NØ# H :Ð-uÐvØ+õ,à×$Ñ$õ%ôð
 	�‰×Ñ˜bÖ!ùò =s   ÁB;c                ó,  € \        V\        4      '       dF   V P                   F3  p\        W!4      '       g   K  V P                  P                  V4       Vu # 	  R # V P                   F(  pW!8X  g   K  V P                  P                  V4       Vu # 	  R # rò   ©r   r   rù   Úremove©r   r   rö   s   && r   Úpop_callbackÚCallbackHandler.pop_callbackÎ  sk   € Ü�h¤×%Ò%Ø—n”n�Ü˜b×+Ô+Ø—N‘N×)Ñ)¨"Ô-Ø’Ió %ð
 —n”n�Ø–>Ø—N‘N×)Ñ)¨"Ô-Ø’Ió %r   c                óð   € \        V\        4      '       dE   V P                   F2  p\        W!4      '       g   K  V P                  P                  V4        R # 	  R # V P                  P                  V4       R # rò   r  r  s   && r   Úremove_callbackÚCallbackHandler.remove_callbackÚ  sQ   € Ü�h¤×%Ò%Ø—n”n�Ü˜b×+Ô+Ø—N‘N×)Ñ)¨"Ô-Úó %ð
 �N‰N×!Ñ! (Ö+r   c                óF   € R P                  R V P                   4       4      # )r,   c              3   óL   "  € T F  qP                   P                  x € K  	  R # 5irò   )r   r   rô   s   & r   r÷   Ú0CallbackHandler.callback_list.<locals>.<genexpr>å  s   é € ÐH¹°2Ÿ™×.Ö.»ùs   ‚"$)Újoinrù   r‚   s   &r   r  ÚCallbackHandler.callback_listã  s   € à�y‰yÑH¸¿ºÓHÓHÐHr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   ÚCallbackHandler.__annotate__ç  ó)   ø€ ÷ Nñ NÑ 1ð N¹,ð NÑQ_ñ Nr   c                ó,   € V P                   ! R WV3/ VB # )r«   ©Ú
call_eventr©   s   &&&&,r   r«   ÚCallbackHandler.on_init_endç  ó   € Ø�Š˜}¨d¸7ÑMÀfÑMÐMr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  ê  ó)   ø€ ÷ Qñ QÑ#4ð Q¹\ð QÑTbñ Qr   c                ó:   € R Vn         V P                  ! RWV3/ VB # )Fr±   )r�   r  r©   s   &&&&,r   r±   ÚCallbackHandler.on_train_beginê  s#   € Ø',ˆÔ$Ø�ŠÐ/°¸gÑPÈÑPÐPr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  î  ó)   ø€ ÷ Oñ OÑ!2ð O¹<ð OÑR`ñ Or   c                ó,   € V P                   ! R WV3/ VB # )r¶   r  r©   s   &&&&,r   r¶   ÚCallbackHandler.on_train_endî  ó   € Ø�Š˜~¨t¸GÑNÀvÑNÐNr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  ñ  r"  r   c                ó:   € R Vn         V P                  ! RWV3/ VB # )Frº   )r“   r  r©   s   &&&&,r   rº   ÚCallbackHandler.on_epoch_beginñ  s#   € Ø$)ˆÔ!Ø�ŠÐ/°¸gÑPÈÑPÐPr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  õ  r&  r   c                ó,   € V P                   ! R WV3/ VB # )r¾   r  r©   s   &&&&,r   r¾   ÚCallbackHandler.on_epoch_endõ  r)  r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  ø  s)   ø€ ÷ Pñ PÑ"3ð P¹Lð PÑSañ Pr   c                óV   € R Vn         R Vn        R Vn        V P                  ! RWV3/ VB # )FrÂ   )r™   r˜   r—   r  r©   s   &&&&,r   rÂ   ÚCallbackHandler.on_step_beginø  s2   € Ø"ˆÔØ"'ˆÔØ#ˆÔØ�Š˜°¸WÑOÈÑOÐOr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  þ  s)   ø€ ÷ Xñ XÑ*;ð XÁLð XÑ[iñ Xr   c                ó,   € V P                   ! R WV3/ VB # )rÆ   r  r©   s   &&&&,r   rÆ   Ú%CallbackHandler.on_pre_optimizer_stepþ  s   € Ø�ŠÐ6¸ÀWÑWÐPVÑWÐWr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s)   ø€ ÷ Tñ TÑ&7ð TÁð TÑWeñ Tr   c                ó,   € V P                   ! R WV3/ VB # )rÊ   r  r©   s   &&&&,r   rÊ   Ú!CallbackHandler.on_optimizer_step  s   € Ø�ŠÐ2°DÀÑSÈFÑSÐSr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s)   ø€ ÷ Qñ QÑ#4ð Q¹\ð QÑTbñ Qr   c                ó,   € V P                   ! R WV3/ VB # )rÎ   r  r©   s   &&&&,r   rÎ   ÚCallbackHandler.on_substep_end  s   € Ø�ŠÐ/°¸gÑPÈÑPÐPr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    r  r   c                ó,   € V P                   ! R WV3/ VB # )rÒ   r  r©   s   &&&&,r   rÒ   ÚCallbackHandler.on_step_end  r   r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r  
  s)   ø€ ÷ _ñ _Ñ 1ð _¹,ð _ÑQ_ñ _r   c                ó>   € R Vn         V P                  ! RWV3RV/VB # )FrÖ   rÛ   )r˜   r  rÚ   s   &&&&&,r   rÖ   ÚCallbackHandler.on_evaluate
  s(   € Ø"'ˆÔØ�Š˜}¨d¸7Ñ^ÈGÐ^ÐW]Ñ^Ð^r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s)   ø€ ÷ ^ñ ^Ñ0ð ^¹ð ^ÑP^ñ ^r   c                ó0   € V P                   ! R WV3RV/VB # )rÜ   rÛ   r  rÚ   s   &&&&&,r   rÜ   ÚCallbackHandler.on_predict  s    € Ø�Š˜|¨T¸'Ñ]È7Ð]ÐV\Ñ]Ð]r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s(   ø€ ÷ Jñ JÑ-ð J±lð JÉ^ñ Jr   c                ó:   € R Vn         V P                  ! RWV3/ VB # )Frà   )r—   r  r©   s   &&&&,r   rà   ÚCallbackHandler.on_save  s"   € Ø#ˆÔØ�Š˜y¨$°wÑIÀ&ÑIÐIr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s(   ø€ ÷ Tñ TÑ,ð T±\ð TÉNñ Tr   c                ó>   € R Vn         V P                  ! RWV3RV/VB # )Frä   Úlogs)r™   r  )r   rL   r   r¤   rJ  rª   s   &&&&&,r   rä   ÚCallbackHandler.on_log  s'   € Ø"ˆÔØ�Š˜x¨°gÑSÀDÐSÈFÑSÐSr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s)   ø€ ÷ Uñ UÑ'8ð UÁð UÑXfñ Ur   c                ó,   € V P                   ! R WV3/ VB # )rè   r  r©   s   &&&&,r   rè   Ú"CallbackHandler.on_prediction_step  s   € Ø�ŠÐ3°TÀ'ÑTÈVÑTÐTr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   r    s)   ø€ ÷ Pñ PÑ"3ð P¹Lð PÑSañ Pr   c                ó,   € V P                   ! R WV3/ VB # )rì   r  r©   s   &&&&,r   rì   ÚCallbackHandler.on_push_begin  s   € Ø�Š˜°¸WÑOÈÑOÐOr   c                óô   € V P                    Fg  p\        Wa4      ! VVV3R V P                  RV P                  RV P                  RV P
                  RV P                  RV P                  /VB pVf   Ke  TpKi  	  V# )rû   rü   rý   rþ   rÿ   r   )rù   rH   rû   rü   rý   rþ   rÿ   r   )r   ÚeventrL   r   r¤   rª   r   Úresults   &&&&&,  r   r  ÚCallbackHandler.call_event  s¢   € ØŸœˆHÜ˜XÔ-ØØØñð —j‘jð	ð
 "&×!6Ñ!6ðð Ÿ.™.ðð "×.Ñ.ðð "&×!6Ñ!6ðð !%× 4Ñ 4ðð ñˆFð Ô!Ø ’ñ 'ð  ˆr   )rù   r   rþ   rû   rý   rü   rÿ   N)r   rq   rr   rs   rt   r  rú   r  r  Úpropertyr  r«   r±   r¶   rº   r¾   rÂ   rÆ   rÊ   rÎ   rÒ   rÖ   rÜ   rà   rä   rè   rì   r  rw   rx   ry   s   @r   rï   rï   ­  sü   ø‡ € ÙHòò&	"ò
ò,ð ñIó ðI÷Nð N÷Qð Q÷Oð O÷Qð Q÷Oð O÷Pð P÷Xð X÷Tð T÷Qð Q÷Nð N÷_ð _÷^ð ^÷Jð J÷Tð T÷Uð U÷Pð P÷ð r   rï   c                   óH   a € ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )	ró   i3  zp
A [`TrainerCallback`] that handles the default flow of the training loop for logs, evaluation and checkpoints.
c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   Ú DefaultFlowCallback.__annotate__8  s$   ø€ ÷ &ñ &Ñ 1ð &¹,ð &ÑQ_ñ &r   c                ó¸  € VP                   ^8X  d   VP                  '       d   RVn        VP                  \        P
                  8X  d*   VP                   VP                  ,          ^ 8X  d   RVn        VP                  \        P
                  8X  dE   VP                   VP                  ,          ^ 8X  d#   VP                  VP                   8:  d   RVn
        VP                  \        P
                  8X  d;   VP                  ^ 8”  d*   VP                   VP                  ,          ^ 8X  d   RVn        VP                   VP                  8¼  d‘   RVn        VP                  \        P
                  8X  dE   VP                   VP                  ,          ^ 8w  d#   VP                  VP                   8:  d   RVn
        VP                  \        P
                  8X  d   RVn        V# )é   T)rb   Úlogging_first_stepr™   Úlogging_strategyr   ÚSTEPSrc   Úeval_strategyrd   Ú
eval_delayr˜   Úsave_strategyr   re   r—   rM   r�   r©   s   &&&&,r   rÒ   ÚDefaultFlowCallback.on_step_end8  sp  € à×Ñ Ô! d×&=×&=Ð&=Ø!%ˆGÔØ× Ñ Ô$4×$:Ñ$:Ô:¸u×?PÑ?PÐSX×SfÑSfÕ?fÐjkÔ?kØ!%ˆGÔð ×ÑÔ"2×"8Ñ"8Ô8Ø×!Ñ! E×$4Ñ$4Õ4¸Ô9Ø—‘ 5×#4Ñ#4Ô4à&*ˆGÔ#ð ×Ñ¤,×"4Ñ"4Ô4Ø× Ñ  1Ô$Ø×!Ñ! E×$4Ñ$4Õ4¸Ô9à"&ˆGÔð ×Ñ §¡Ô/Ø+/ˆGÔ(ð ×"Ñ"Ô&6×&<Ñ&<Ô<Ø×%Ñ%¨×(8Ñ(8Õ8¸AÔ=Ø—O‘O u×'8Ñ'8Ô8à*.�Ô'à×!Ñ!¤\×%7Ñ%7Ô7Ø&*�Ô#àˆr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# r£   r¥   )r%   r&   s   "€r   r'   rY  `  s$   ø€ ÷ ñ Ñ!2ð ¹<ð ÑR`ñ r   c                ó   € VP                   \        P                  8X  d   R Vn        VP                  \        P                  8X  d#   VP
                  VP                  8:  d   R Vn        VP                  \        P                  8X  d   R Vn
        V# )T)r]  r   ÚEPOCHr™   r_  r`  ra   r˜   ra  r   r—   r©   s   &&&&,r   r¾   Ú DefaultFlowCallback.on_epoch_end`  sp   € à× Ñ Ô$4×$:Ñ$:Ô:Ø!%ˆGÔð ×ÑÔ!1×!7Ñ!7Ô7¸D¿O¹OÈuÏ{É{Ô<ZØ&*ˆGÔ#ð ×Ñ¤×!3Ñ!3Ô3Ø"&ˆGÔàˆr   r=   N)	r   rq   rr   rs   rt   rÒ   r¾   rw   rx   ry   s   @r   ró   ró   3  s   ø‡ € ñ÷&ð &÷Pö r   ró   c                   ól   a € ] tR tRt o RtRV 3R lR lltR tR tRR ltR	 t	R
 t
RR ltR tRtV tR# )ÚProgressCallbackip  z¢
A [`TrainerCallback`] that displays the progress of training or evaluation.
You can modify `max_str_len` to control how long strings are truncated when logging.
c                ó    <€ V ^8„  d   QhRS[ /# )r!   Úmax_str_len)ro   )r%   r&   s   "€r   r'   ÚProgressCallback.__annotate__v  s   ø€ ÷ 'ñ '¡Cñ 'r   c                ó.   € RV n         RV n        Wn        R# )zñ
Initialize the callback with optional max_str_len parameter to control string truncation length.

Args:
    max_str_len (`int`):
        Maximum length of strings to display in logs.
        Longer strings will be truncated with a message.
N)Útraining_barÚprediction_barrj  )r   rj  s   &&r   r  ÚProgressCallback.__init__v  s   € ð !ˆÔØ"ˆÔØ&Ör   c                óp   € VP                   '       d   \        VP                  R R7      V n        ^ V n        R# )T)ÚtotalÚdynamic_ncolsN)r[   r   rM   rm  Úcurrent_stepr©   s   &&&&,r   r±   ÚProgressCallback.on_train_beginƒ  s)   € Ø×&×&Ð&Ü $¨5¯?©?È$Ô OˆDÔØˆÖr   c                ó¼   € VP                   '       dJ   V P                  P                  VP                  V P                  ,
          4       VP                  V n        R # R # rò   )r[   rm  Úupdaterb   rs  r©   s   &&&&,r   rÒ   ÚProgressCallback.on_step_endˆ  sF   € Ø×&×&Ð&Ø×Ñ×$Ñ$ U×%6Ñ%6¸×9JÑ9JÕ%JÔKØ %× 1Ñ 1ˆDÖñ 'r   Nc                óö   € VP                   '       dg   \        V4      '       dT   V P                  f)   \        \	        V4      V P
                  R J RR7      V n        V P                  P                  ^4       R # R # R # )NT)rq  Úleaverr  )r[   r   rn  r   Úlenrm  rv  )r   rL   r   r¤   r   rª   s   &&&&&,r   rè   Ú#ProgressCallback.on_prediction_step�  sh   € Ø×&×&Ð&¬:°o×+FÒ+FØ×"Ñ"Ò*Ü&*Ü˜oÓ.°d×6GÑ6GÈ4Ð6OÐ_cô'�Ô#ð ×Ñ×&Ñ& qÖ)ñ ,GÑ&r   c                óŒ   € VP                   '       d2   V P                  e   V P                  P                  4        R V n        R # R # rò   ©r[   rn  Úcloser©   s   &&&&,r   rÖ   ÚProgressCallback.on_evaluate•  ó9   € Ø×&×&Ð&Ø×"Ñ"Ò.Ø×#Ñ#×)Ñ)Ô+Ø"&ˆDÖñ 'r   c                óŒ   € VP                   '       d2   V P                  e   V P                  P                  4        R V n        R # R # rò   r}  r©   s   &&&&,r   rÜ   ÚProgressCallback.on_predict›  r€  r   c                óÔ  € VP                   '       dÖ   V P                  eÆ   / pVP                  4        Fw  w  rx\        V\        4      '       d;   \        V4      V P                  8”  d!   R\        V4       RV P                   R2Wg&   KU  \        V\        4      '       d	   VR Wg&   Ks  W†V&   Ky  	  VP                  RR 4      p	V P                  P                  \	        V4      4       R # R # R # )Nz%[String too long to display, length: z > z/. Consider increasing `max_str_len` if needed.]ú.4grh   )
r[   rm  r†   r   r$   rz  rj  rn   Úpopr6   )
r   rL   r   r¤   rJ  rª   Úshallow_logsrˆ   r‰   Ú_s
   &&&&&,    r   rä   ÚProgressCallback.on_log¡  sÓ   € Ø×&×&Ð&¨4×+<Ñ+<Ò+Hð ˆLØŸ
™
ž‘�Ü˜a¤×%Ò%¬#¨a«&°4×3CÑ3CÔ*Cà?ÄÀAÃ¸xÀsÈ4×K[ÑK[ÐJ\ð ]Hð Hð !“Oô   ¤5×)Ò)à)*¨3¨�L“Oà&' “Oñ %ð × Ñ  ¨tÓ4ˆAØ×Ñ×#Ñ#¤C¨Ó$5Ö6ñ! ,IÑ&r   c                óp   € VP                   '       d$   V P                  P                  4        R V n        R # R # rò   )r[   rm  r~  r©   s   &&&&,r   r¶   ÚProgressCallback.on_train_end´  s-   € Ø×&×&Ð&Ø×Ñ×#Ñ#Ô%Ø $ˆDÖñ 'r   )rs  rj  rn  rm  )éd   rò   )r   rq   rr   rs   rt   r  r±   rÒ   rè   rÖ   rÜ   rä   r¶   rw   rx   ry   s   @r   rh  rh  p  s<   ø‡ € ñ÷
'ò 'òò
2ô
*ò'ò'ô7÷&%ð %r   rh  c                   ó.   a € ] tR tRt o RtRR ltRtV tR# )ÚPrinterCallbackiº  z7
A bare [`TrainerCallback`] that just prints the logs.
Nc           	     óø   € VP                  R R4      pVP                  '       dP   Ve?   VP                  4        UUu/ uF"  w  rxT\        V\        4      '       d   VR MTbK$  	  ppp\        V4       R# R# u uppi )rh   Nr„  )r…  rZ   r†   r   rn   Úprint)	r   rL   r   r¤   rJ  rª   r‡  rˆ   r‰   s	   &&&&&,   r   rä   ÚPrinterCallback.on_log¿  sk   € Ø�H‰H�\ 4Ó(ˆØ×&×&Ð&ØÒØSW×S]ÑS]ÔS_Ô`ÑS_É4È1˜¬*°Q¼×*>Ò*>˜q ™gÀAÒEÑS_�Ñ`Ü�$ŽKñ 'ùã`s   ¼(A6r=   rò   )r   rq   rr   rs   rt   rä   rw   rx   ry   s   @r   r�  r�  º  s   ø‡ € ñ÷ò r   r�  c                   ó^   a € ] tR tRt o RtRV 3R lR lltR tR tR tV 3R lR	 lt	R
t
V tR# )ÚEarlyStoppingCallbackiÇ  a  
A [`TrainerCallback`] that handles early stopping.

Args:
    early_stopping_patience (`int`):
        Use with `metric_for_best_model` to stop training when the specified metric worsens for
        `early_stopping_patience` evaluation calls.
    early_stopping_threshold(`float`, *optional*):
        Use with TrainingArguments `metric_for_best_model` and `early_stopping_patience` to denote how much the
        specified metric must improve to satisfy early stopping conditions. `

This callback depends on [`TrainingArguments`] argument *load_best_model_at_end* functionality to set best_metric
in [`TrainerState`]. Note that if the [`TrainingArguments`] argument *save_steps* differs from *eval_steps*, the
early stopping will not occur until the next save step.
c                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# )r!   Úearly_stopping_patienceÚearly_stopping_thresholdN)ro   rn   )r%   r&   s   "€r   r'   Ú"EarlyStoppingCallback.__annotate__Ø  s"   ø€ ÷ 1ñ 1±ð 1ÑSXÐ[_ÕS_ñ 1r   c                ó,   € Wn         W n        ^ V n        R# )é    N©r”  r•  Úearly_stopping_patience_counter)r   r”  r•  s   &&&r   r  ÚEarlyStoppingCallback.__init__Ø  s   € Ø'>Ô$Ø(@Ô%à/0ˆÖ,r   c                óN  € VP                   '       d   \        P                  M\        P                  pVP                  eC   V! WBP                  4      '       d4   \        WBP                  ,
          4      V P                  8”  d
   ^ V n        R # V ;P                  ^,          un        R # rò   )Úgreater_is_betterÚnpÚgreaterÚlessri   Úabsr•  rš  )r   rL   r   r¤   Úmetric_valueÚoperators   &&&&& r   Úcheck_metric_valueÚ(EarlyStoppingCallback.check_metric_valueÞ  sn   € à!%×!7×!7Ð!7”2—:’:¼R¿W¹WˆØ×ÑÒ$Ù�\×#4Ñ#4×5Ò5Ü�L×#4Ñ#4Õ4Ó5¸×8UÑ8UÔUà34ˆDÖ0à×0Ò0°AÕ5×0r   c                óÊ   € VP                   '       g   \        P                  R 4       VP                  f   Q R4       hVP                  \
        P                  8w  g   Q R4       hR# )zŒUsing EarlyStoppingCallback without load_best_model_at_end=True. Once training is finished, the best model will not be loaded automatically.NzBEarlyStoppingCallback requires metric_for_best_model to be definedzAEarlyStoppingCallback requires IntervalStrategy of steps or epoch)Úload_best_model_at_endr  r  Úmetric_for_best_modelr_  r   ÚNOr©   s   &&&&,r   r±   Ú$EarlyStoppingCallback.on_train_beginé  se   € Ø×*×*Ð*Ü�N‰Nð^ôð ×)Ñ)Ò5ð 	
ØPó	
Ð5ð ×!Ñ!Ô%5×%8Ñ%8Ô8ð 	
ØOó	
Ò8r   c                ó"  € VP                   pVP                  R 4      '       g   R V 2pVP                  V4      pVf   \        P	                  RV R24       R# V P                  WW74       V P                  V P                  8¼  d
   RVn        R# R# )Úeval_Nz@early stopping required metric_for_best_model, but did not find z so early stopping is disabledT)	r¨  Ú
startswithÚgetr  r  r¤  rš  r”  r�   )r   rL   r   r¤   rÛ   rª   Úmetric_to_checkr¢  s   &&&&&,  r   rÖ   Ú!EarlyStoppingCallback.on_evaluateö  s–   € Ø×4Ñ4ˆØ×)Ñ)¨'×2Ò2Ø % oÐ%6Ð7ˆOØ—{‘{ ?Ó3ˆàÒÜ�N‰NØRÐSbÐRcð dð ôñ à×Ñ ¨WÔCØ×/Ñ/°4×3OÑ3OÔOØ+/ˆGÖ(ñ Pr   c                ó    <€ V ^8„  d   QhRS[ /# r|   r~   )r%   r&   s   "€r   r'   r–    s   ø€ ÷ 	
ñ 	
‘tñ 	
r   c                óV   € R RV P                   RV P                  /RRV P                  //# )rL   r”  r•  r…   rš  r™  r‚   s   &r   r   ÚEarlyStoppingCallback.state  s?   € àØ)¨4×+GÑ+GØ*¨D×,IÑ,Iðð Ø1°4×3WÑ3Wðð
ð 	
r   )r”  rš  r•  N)r[  g        )r   rq   rr   rs   rt   r  r¤  r±   rÖ   r   rw   rx   ry   s   @r   r’  r’  Ç  s-   ø‡ € ñ÷ 1ò 1ò	6ò
ò0÷"	
ö 	
r   r’  )rt   r3   r1   rI   r   Únumpyrž  Ú	tqdm.autor   Útrainer_utilsr   r   r   Útraining_argsr   Úutilsr   Ú
get_loggerr   r  r
   r   r�   rm   rï   ró   rh  r�  r’  r=   r   r   Ú<module>rº     s×   ðñó Û Û Ý !ã Ý ç EÑ EÝ ,Ý ð 
×	Ò	˜HÓ	%€ð ÷WEð WEó ðWE÷t)ñ )ðX ô:
�_ó :
ó ð:
÷zCñ CôLC�oô CôL:˜/ô :ôzG%�ô G%ôT
�oô 
ôI
˜O¨_ö I
r   