import{S as Qp,i as Zp,s as eg,e as o,k as c,w as _,t as r,M as tg,c as s,d as t,m as d,a as l,x as b,h as a,b as i,G as e,g as m,y as v,q as E,o as k,B as T,v as rg,L as ag}from"../../chunks/vendor-hf-doc-builder.js";import{T as ng}from"../../chunks/Tip-hf-doc-builder.js";import{D as w}from"../../chunks/Docstring-hf-doc-builder.js";import{C as km}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Vn}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as og}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function sg(cr){let A,z,D,O,W;return O=new km({props:{code:`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)`,highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">PrinterCallback</span>(<span class="hljs-title class_ inherited__">TrainerCallback</span>):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">on_log</span>(<span class="hljs-params">self, args, state, control, logs=<span class="hljs-literal">None</span>, **kwargs</span>):
        _ = logs.pop(<span class="hljs-string">&quot;total_flos&quot;</span>, <span class="hljs-literal">None</span>)
        <span class="hljs-keyword">if</span> state.is_local_process_zero:
            <span class="hljs-built_in">print</span>(logs)`}}),{c(){A=o("p"),z=r("Example:"),D=c(),_(O.$$.fragment)},l(y){A=s(y,"P",{});var N=l(A);z=a(N,"Example:"),N.forEach(t),D=d(y),b(O.$$.fragment,y)},m(y,N){m(y,A,N),e(A,z),m(y,D,N),v(O,y,N),W=!0},p:ag,i(y){W||(E(O.$$.fragment,y),W=!0)},o(y){k(O.$$.fragment,y),W=!1},d(y){y&&t(A),y&&t(D),T(O,y)}}}function lg(cr){let A,z,D,O,W,y,N,re;return{c(){A=o("p"),z=r(`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 `),D=o("code"),O=r("gradient_accumulation_steps=n"),W=r(`, then one update
step requires going through `),y=o("em"),N=r("n"),re=r(" batches.")},l(ae){A=s(ae,"P",{});var j=l(A);z=a(j,`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 `),D=s(j,"CODE",{});var G=l(D);O=a(G,"gradient_accumulation_steps=n"),G.forEach(t),W=a(j,`, then one update
step requires going through `),y=s(j,"EM",{});var dr=l(y);N=a(dr,"n"),dr.forEach(t),re=a(j," batches."),j.forEach(t)},m(ae,j){m(ae,A,j),e(A,z),e(A,D),e(D,O),e(A,W),e(A,y),e(y,N),e(A,re)},d(ae){ae&&t(A)}}}function ig(cr){let A,z,D,O,W,y,N,re,ae,j,G,dr,fr,ss,ls,Un,B,is,mr,cs,ds,hr,fs,ms,pr,hs,ps,qn,ke,gs,gr,us,_s,Gn,x,ur,_r,bs,vs,Es,Z,br,ks,Ts,vr,$s,Cs,Er,ws,ys,As,kr,Tr,Ls,Ds,Os,Te,$r,xs,Ms,tt,Ss,Is,Ps,$e,Cr,Fs,Ws,rt,Ns,js,zs,Ce,wr,Bs,Rs,at,Vs,Us,qs,we,yr,Gs,Hs,nt,Js,Ys,Xs,ye,Ar,Ks,Qs,ot,Zs,el,Hn,S,tl,Lr,rl,al,Dr,nl,ol,Or,sl,ll,xr,il,cl,Mr,dl,fl,Jn,ne,Ae,da,st,ml,fa,hl,Yn,Le,pl,Sr,gl,ul,Xn,H,lt,_l,oe,bl,Ir,vl,El,it,kl,Tl,$l,R,ct,Cl,ma,wl,yl,L,Al,ha,Ll,Dl,pa,Ol,xl,ga,Ml,Sl,ua,Il,Pl,_a,Fl,Wl,ba,Nl,jl,va,zl,Bl,Ea,Rl,Vl,ka,Ul,ql,Gl,dt,Hl,ft,Jl,Yl,Kn,se,mt,Xl,ht,Kl,Pr,Ql,Zl,Qn,le,pt,ei,gt,ti,Fr,ri,ai,Zn,ie,ut,ni,_t,oi,Wr,si,li,eo,J,bt,ii,vt,ci,Nr,di,fi,mi,Y,hi,jr,pi,gi,Ta,ui,_i,zr,bi,vi,to,ce,Et,Ei,de,ki,Br,Ti,$i,kt,Ci,wi,ro,X,Tt,yi,fe,Ai,Rr,Li,Di,$t,Oi,xi,Mi,V,Ct,Si,wt,Ii,$a,Pi,Fi,Wi,yt,Ni,At,ji,zi,Bi,h,Ri,Ca,Vi,Ui,wa,qi,Gi,ya,Hi,Ji,Aa,Yi,Xi,La,Ki,Qi,Da,Zi,ec,Oa,tc,rc,xa,ac,nc,Ma,oc,sc,Sa,lc,ic,Ia,cc,dc,Pa,fc,mc,Fa,hc,pc,Wa,gc,uc,Na,_c,bc,ja,vc,Ec,za,kc,Tc,Ba,$c,Cc,Ra,wc,yc,ao,K,Lt,Ac,Q,Lc,Vr,Dc,Oc,Dt,xc,Mc,Va,Sc,Ic,Pc,ee,Ot,Fc,Ua,Wc,Nc,p,jc,qa,zc,Bc,Ga,Rc,Vc,Ha,Uc,qc,Ja,Gc,Hc,Ur,Jc,Yc,Ya,Xc,Kc,Xa,Qc,Zc,Ka,ed,td,Qa,rd,ad,Za,nd,od,en,sd,ld,tn,id,cd,rn,dd,fd,an,md,hd,nn,pd,gd,on,ud,_d,sn,bd,vd,ln,Ed,kd,cn,Td,$d,no,me,xt,Cd,he,wd,qr,yd,Ad,Mt,Ld,Dd,oo,pe,St,Od,It,xd,Gr,Md,Sd,so,ge,De,dn,Pt,Id,fn,Pd,lo,$,Ft,Fd,mn,Wd,Nd,Wt,jd,hn,zd,Bd,Rd,P,Vd,pn,Ud,qd,gn,Gd,Hd,un,Jd,Yd,_n,Xd,Kd,bn,Qd,Zd,ef,Oe,tf,xe,Nt,rf,vn,af,nf,Me,jt,of,En,sf,lf,Se,zt,cf,kn,df,ff,Ie,Bt,mf,Rt,hf,Hr,pf,gf,uf,Pe,Vt,_f,Tn,bf,vf,Fe,Ut,Ef,$n,kf,Tf,We,qt,$f,Cn,Cf,wf,Ne,Gt,yf,wn,Af,Lf,je,Ht,Df,yn,Of,xf,ze,Jt,Mf,An,Sf,If,Be,Yt,Pf,Ln,Ff,Wf,Re,Xt,Nf,Dn,jf,io,Ve,zf,Jr,Bf,Rf,co,Kt,fo,Ue,Vf,On,Uf,qf,mo,Qt,ho,ue,qe,xn,Zt,Gf,Mn,Hf,po,F,er,Jf,_e,Yf,Yr,Xf,Kf,Xr,Qf,Zf,em,Ge,tm,He,tr,rm,rr,am,Sn,nm,om,sm,Je,ar,lm,nr,im,In,cm,dm,go,be,Ye,Pn,or,fm,Fn,mm,uo,ve,sr,hm,Ee,pm,Kr,gm,um,Qr,_m,bm,_o;return y=new Vn({}),st=new Vn({}),lt=new w({props:{name:"class transformers.integrations.CometCallback",anchor:"transformers.integrations.CometCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L664"}}),ct=new w({props:{name:"setup",anchor:"transformers.integrations.CometCallback.setup",parameters:[{name:"args",val:""},{name:"state",val:""},{name:"model",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L675"}}),mt=new w({props:{name:"class transformers.DefaultFlowCallback",anchor:"transformers.DefaultFlowCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L406"}}),pt=new w({props:{name:"class transformers.PrinterCallback",anchor:"transformers.PrinterCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L498"}}),ut=new w({props:{name:"class transformers.ProgressCallback",anchor:"transformers.ProgressCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L456"}}),bt=new w({props:{name:"class transformers.EarlyStoppingCallback",anchor:"transformers.EarlyStoppingCallback",parameters:[{name:"early_stopping_patience",val:": int = 1"},{name:"early_stopping_threshold",val:": typing.Optional[float] = 0.0"}],parametersDescription:[{anchor:"transformers.EarlyStoppingCallback.early_stopping_patience",description:`<strong>early_stopping_patience</strong> (<code>int</code>) &#x2014;
Use with <code>metric_for_best_model</code> to stop training when the specified metric worsens for
<code>early_stopping_patience</code> evaluation calls.`,name:"early_stopping_patience"},{anchor:"transformers.EarlyStoppingCallback.early_stopping_threshold(float,",description:`<strong>early_stopping_threshold(<code>float</code>,</strong> <em>optional</em>) &#x2014;
Use with TrainingArguments <code>metric_for_best_model</code> and <code>early_stopping_patience</code> to denote how much the
specified metric must improve to satisfy early stopping conditions. \``,name:"early_stopping_threshold(float,"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L509"}}),Et=new w({props:{name:"class transformers.integrations.TensorBoardCallback",anchor:"transformers.integrations.TensorBoardCallback",parameters:[{name:"tb_writer",val:" = None"}],parametersDescription:[{anchor:"transformers.integrations.TensorBoardCallback.tb_writer",description:`<strong>tb_writer</strong> (<code>SummaryWriter</code>, <em>optional</em>) &#x2014;
The writer to use. Will instantiate one if not set.`,name:"tb_writer"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L449"}}),Tt=new w({props:{name:"class transformers.integrations.WandbCallback",anchor:"transformers.integrations.WandbCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L538"}}),Ct=new w({props:{name:"setup",anchor:"transformers.integrations.WandbCallback.setup",parameters:[{name:"args",val:""},{name:"state",val:""},{name:"model",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L555"}}),Lt=new w({props:{name:"class transformers.integrations.MLflowCallback",anchor:"transformers.integrations.MLflowCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L764"}}),Ot=new w({props:{name:"setup",anchor:"transformers.integrations.MLflowCallback.setup",parameters:[{name:"args",val:""},{name:"state",val:""},{name:"model",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L783"}}),xt=new w({props:{name:"class transformers.integrations.AzureMLCallback",anchor:"transformers.integrations.AzureMLCallback",parameters:[{name:"azureml_run",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L741"}}),St=new w({props:{name:"class transformers.integrations.CodeCarbonCallback",anchor:"transformers.integrations.CodeCarbonCallback",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/integrations.py#L963"}}),Pt=new Vn({}),Ft=new w({props:{name:"class transformers.TrainerCallback",anchor:"transformers.TrainerCallback",parameters:[],parametersDescription:[{anchor:"transformers.TrainerCallback.args",description:`<strong>args</strong> (<a href="/docs/transformers/pr_17548/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>) &#x2014;
The training arguments used to instantiate the <a href="/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer">Trainer</a>.`,name:"args"},{anchor:"transformers.TrainerCallback.state",description:`<strong>state</strong> (<a href="/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerState">TrainerState</a>) &#x2014;
The current state of the <a href="/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer">Trainer</a>.`,name:"state"},{anchor:"transformers.TrainerCallback.control",description:`<strong>control</strong> (<a href="/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerControl">TrainerControl</a>) &#x2014;
The object that is returned to the <a href="/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer">Trainer</a> and can be used to make some decisions.`,name:"control"},{anchor:"transformers.TrainerCallback.model",description:`<strong>model</strong> (<a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a> or <code>torch.nn.Module</code>) &#x2014;
The model being trained.`,name:"model"},{anchor:"transformers.TrainerCallback.tokenizer",description:`<strong>tokenizer</strong> (<a href="/docs/transformers/pr_17548/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>) &#x2014;
The tokenizer used for encoding the data.`,name:"tokenizer"},{anchor:"transformers.TrainerCallback.optimizer",description:`<strong>optimizer</strong> (<code>torch.optim.Optimizer</code>) &#x2014;
The optimizer used for the training steps.`,name:"optimizer"},{anchor:"transformers.TrainerCallback.lr_scheduler",description:`<strong>lr_scheduler</strong> (<code>torch.optim.lr_scheduler.LambdaLR</code>) &#x2014;
The scheduler used for setting the learning rate.`,name:"lr_scheduler"},{anchor:"transformers.TrainerCallback.train_dataloader",description:`<strong>train_dataloader</strong> (<code>torch.utils.data.DataLoader</code>, <em>optional</em>) &#x2014;
The current dataloader used for training.`,name:"train_dataloader"},{anchor:"transformers.TrainerCallback.eval_dataloader",description:`<strong>eval_dataloader</strong> (<code>torch.utils.data.DataLoader</code>, <em>optional</em>) &#x2014;
The current dataloader used for training.`,name:"eval_dataloader"},{anchor:"transformers.TrainerCallback.metrics",description:`<strong>metrics</strong> (<code>Dict[str, float]</code>) &#x2014;
The metrics computed by the last evaluation phase.</p>
<p>Those are only accessible in the event <code>on_evaluate</code>.`,name:"metrics"},{anchor:"transformers.TrainerCallback.logs",description:`<strong>logs</strong>  (<code>Dict[str, float]</code>) &#x2014;
The values to log.</p>
<p>Those are only accessible in the event <code>on_log</code>.`,name:"logs"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L159"}}),Oe=new og({props:{anchor:"transformers.TrainerCallback.example",$$slots:{default:[sg]},$$scope:{ctx:cr}}}),Nt=new w({props:{name:"on_epoch_begin",anchor:"transformers.TrainerCallback.on_epoch_begin",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L227"}}),jt=new w({props:{name:"on_epoch_end",anchor:"transformers.TrainerCallback.on_epoch_end",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L233"}}),zt=new w({props:{name:"on_evaluate",anchor:"transformers.TrainerCallback.on_evaluate",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L259"}}),Bt=new w({props:{name:"on_init_end",anchor:"transformers.TrainerCallback.on_init_end",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L209"}}),Vt=new w({props:{name:"on_log",anchor:"transformers.TrainerCallback.on_log",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L271"}}),Ut=new w({props:{name:"on_prediction_step",anchor:"transformers.TrainerCallback.on_prediction_step",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L277"}}),qt=new w({props:{name:"on_save",anchor:"transformers.TrainerCallback.on_save",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L265"}}),Gt=new w({props:{name:"on_step_begin",anchor:"transformers.TrainerCallback.on_step_begin",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L239"}}),Ht=new w({props:{name:"on_step_end",anchor:"transformers.TrainerCallback.on_step_end",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L252"}}),Jt=new w({props:{name:"on_substep_end",anchor:"transformers.TrainerCallback.on_substep_end",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L246"}}),Yt=new w({props:{name:"on_train_begin",anchor:"transformers.TrainerCallback.on_train_begin",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L215"}}),Xt=new w({props:{name:"on_train_end",anchor:"transformers.TrainerCallback.on_train_end",parameters:[{name:"args",val:": TrainingArguments"},{name:"state",val:": TrainerState"},{name:"control",val:": TrainerControl"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L221"}}),Kt=new km({props:{code:`class MyCallback(TrainerCallback):
    "A callback that prints a message at the beginning of training"

    def on_train_begin(self, args, state, control, **kwargs):
        print("Starting training")


trainer = Trainer(
    model,
    args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    callbacks=[MyCallback],  # We can either pass the callback class this way or an instance of it (MyCallback())
)`,highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyCallback</span>(<span class="hljs-title class_ inherited__">TrainerCallback</span>):
    <span class="hljs-string">&quot;A callback that prints a message at the beginning of training&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">on_train_begin</span>(<span class="hljs-params">self, args, state, control, **kwargs</span>):
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Starting training&quot;</span>)


trainer = Trainer(
    model,
    args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    callbacks=[MyCallback],  <span class="hljs-comment"># We can either pass the callback class this way or an instance of it (MyCallback())</span>
)`}}),Qt=new km({props:{code:`trainer = Trainer(...)
trainer.add_callback(MyCallback)
# Alternatively, we can pass an instance of the callback class
trainer.add_callback(MyCallback())`,highlighted:`trainer = Trainer(...)
trainer.add_callback(MyCallback)
<span class="hljs-comment"># Alternatively, we can pass an instance of the callback class</span>
trainer.add_callback(MyCallback())`}}),Zt=new Vn({}),er=new w({props:{name:"class transformers.TrainerState",anchor:"transformers.TrainerState",parameters:[{name:"epoch",val:": typing.Optional[float] = None"},{name:"global_step",val:": int = 0"},{name:"max_steps",val:": int = 0"},{name:"num_train_epochs",val:": int = 0"},{name:"total_flos",val:": float = 0"},{name:"log_history",val:": typing.List[typing.Dict[str, float]] = None"},{name:"best_metric",val:": typing.Optional[float] = None"},{name:"best_model_checkpoint",val:": typing.Optional[str] = None"},{name:"is_local_process_zero",val:": bool = True"},{name:"is_world_process_zero",val:": bool = True"},{name:"is_hyper_param_search",val:": bool = False"},{name:"trial_name",val:": str = None"},{name:"trial_params",val:": typing.Dict[str, typing.Union[str, float, int, bool]] = None"}],parametersDescription:[{anchor:"transformers.TrainerState.epoch",description:`<strong>epoch</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Only set during training, will represent the epoch the training is at (the decimal part being the
percentage of the current epoch completed).`,name:"epoch"},{anchor:"transformers.TrainerState.global_step",description:`<strong>global_step</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
During training, represents the number of update steps completed.`,name:"global_step"},{anchor:"transformers.TrainerState.max_steps",description:`<strong>max_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of update steps to do during the current training.`,name:"max_steps"},{anchor:"transformers.TrainerState.total_flos",description:`<strong>total_flos</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The total number of floating operations done by the model since the beginning of training (stored as floats
to avoid overflow).`,name:"total_flos"},{anchor:"transformers.TrainerState.log_history",description:`<strong>log_history</strong> (<code>List[Dict[str, float]]</code>, <em>optional</em>) &#x2014;
The list of logs done since the beginning of training.`,name:"log_history"},{anchor:"transformers.TrainerState.best_metric",description:`<strong>best_metric</strong> (<code>float</code>, <em>optional</em>) &#x2014;
When tracking the best model, the value of the best metric encountered so far.`,name:"best_metric"},{anchor:"transformers.TrainerState.best_model_checkpoint",description:`<strong>best_model_checkpoint</strong> (<code>str</code>, <em>optional</em>) &#x2014;
When tracking the best model, the value of the name of the checkpoint for the best model encountered so
far.`,name:"best_model_checkpoint"},{anchor:"transformers.TrainerState.is_local_process_zero",description:`<strong>is_local_process_zero</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not this process is the local (e.g., on one machine if training in a distributed fashion on
several machines) main process.`,name:"is_local_process_zero"},{anchor:"transformers.TrainerState.is_world_process_zero",description:`<strong>is_world_process_zero</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
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 <code>True</code> for one process).`,name:"is_world_process_zero"},{anchor:"transformers.TrainerState.is_hyper_param_search",description:`<strong>is_hyper_param_search</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
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.`,name:"is_hyper_param_search"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L35"}}),Ge=new ng({props:{$$slots:{default:[lg]},$$scope:{ctx:cr}}}),tr=new w({props:{name:"load_from_json",anchor:"transformers.TrainerState.load_from_json",parameters:[{name:"json_path",val:": str"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L101"}}),ar=new w({props:{name:"save_to_json",anchor:"transformers.TrainerState.save_to_json",parameters:[{name:"json_path",val:": str"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L95"}}),or=new Vn({}),sr=new w({props:{name:"class transformers.TrainerControl",anchor:"transformers.TrainerControl",parameters:[{name:"should_training_stop",val:": bool = False"},{name:"should_epoch_stop",val:": bool = False"},{name:"should_save",val:": bool = False"},{name:"should_evaluate",val:": bool = False"},{name:"should_log",val:": bool = False"}],parametersDescription:[{anchor:"transformers.TrainerControl.should_training_stop",description:`<strong>should_training_stop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the training should be interrupted.</p>
<p>If <code>True</code>, this variable will not be set back to <code>False</code>. The training will just stop.`,name:"should_training_stop"},{anchor:"transformers.TrainerControl.should_epoch_stop",description:`<strong>should_epoch_stop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the current epoch should be interrupted.</p>
<p>If <code>True</code>, this variable will be set back to <code>False</code> at the beginning of the next epoch.`,name:"should_epoch_stop"},{anchor:"transformers.TrainerControl.should_save",description:`<strong>should_save</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the model should be saved at this step.</p>
<p>If <code>True</code>, this variable will be set back to <code>False</code> at the beginning of the next step.`,name:"should_save"},{anchor:"transformers.TrainerControl.should_evaluate",description:`<strong>should_evaluate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the model should be evaluated at this step.</p>
<p>If <code>True</code>, this variable will be set back to <code>False</code> at the beginning of the next step.`,name:"should_evaluate"},{anchor:"transformers.TrainerControl.should_log",description:`<strong>should_log</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the logs should be reported at this step.</p>
<p>If <code>True</code>, this variable will be set back to <code>False</code> at the beginning of the next step.`,name:"should_log"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/trainer_callback.py#L110"}}),{c(){A=o("meta"),z=c(),D=o("h1"),O=o("a"),W=o("span"),_(y.$$.fragment),N=c(),re=o("span"),ae=r("Callbacks"),j=c(),G=o("p"),dr=r(`Callbacks are objects that can customize the behavior of the training loop in the PyTorch
`),fr=o("a"),ss=r("Trainer"),ls=r(` (this feature is not yet implemented in TensorFlow) that can inspect the training loop
state (for progress reporting, logging on TensorBoard or other ML platforms\u2026) and take decisions (like early
stopping).`),Un=c(),B=o("p"),is=r("Callbacks are \u201Cread only\u201D pieces of code, apart from the "),mr=o("a"),cs=r("TrainerControl"),ds=r(` object they return, they
cannot change anything in the training loop. For customizations that require changes in the training loop, you should
subclass `),hr=o("a"),fs=r("Trainer"),ms=r(" and override the methods you need (see "),pr=o("a"),hs=r("trainer"),ps=r(" for examples)."),qn=c(),ke=o("p"),gs=r("By default a "),gr=o("a"),us=r("Trainer"),_s=r(" will use the following callbacks:"),Gn=c(),x=o("ul"),ur=o("li"),_r=o("a"),bs=r("DefaultFlowCallback"),vs=r(" which handles the default behavior for logging, saving and evaluation."),Es=c(),Z=o("li"),br=o("a"),ks=r("PrinterCallback"),Ts=r(" or "),vr=o("a"),$s=r("ProgressCallback"),Cs=r(` to display progress and print the
logs (the first one is used if you deactivate tqdm through the `),Er=o("a"),ws=r("TrainingArguments"),ys=r(`, otherwise
it\u2019s the second one).`),As=c(),kr=o("li"),Tr=o("a"),Ls=r("TensorBoardCallback"),Ds=r(` if tensorboard is accessible (either through PyTorch >= 1.4
or tensorboardX).`),Os=c(),Te=o("li"),$r=o("a"),xs=r("WandbCallback"),Ms=r(" if "),tt=o("a"),Ss=r("wandb"),Is=r(" is installed."),Ps=c(),$e=o("li"),Cr=o("a"),Fs=r("CometCallback"),Ws=r(" if "),rt=o("a"),Ns=r("comet_ml"),js=r(" is installed."),zs=c(),Ce=o("li"),wr=o("a"),Bs=r("MLflowCallback"),Rs=r(" if "),at=o("a"),Vs=r("mlflow"),Us=r(" is installed."),qs=c(),we=o("li"),yr=o("a"),Gs=r("AzureMLCallback"),Hs=r(" if "),nt=o("a"),Js=r("azureml-sdk"),Ys=r(` is
installed.`),Xs=c(),ye=o("li"),Ar=o("a"),Ks=r("CodeCarbonCallback"),Qs=r(" if "),ot=o("a"),Zs=r("codecarbon"),el=r(` is
installed.`),Hn=c(),S=o("p"),tl=r("The main class that implements callbacks is "),Lr=o("a"),rl=r("TrainerCallback"),al=r(`. It gets the
`),Dr=o("a"),nl=r("TrainingArguments"),ol=r(" used to instantiate the "),Or=o("a"),sl=r("Trainer"),ll=r(`, can access that
Trainer\u2019s internal state via `),xr=o("a"),il=r("TrainerState"),cl=r(`, and can take some actions on the training loop via
`),Mr=o("a"),dl=r("TrainerControl"),fl=r("."),Jn=c(),ne=o("h2"),Ae=o("a"),da=o("span"),_(st.$$.fragment),ml=c(),fa=o("span"),hl=r("Available Callbacks"),Yn=c(),Le=o("p"),pl=r("Here is the list of the available "),Sr=o("a"),gl=r("TrainerCallback"),ul=r(" in the library:"),Xn=c(),H=o("div"),_(lt.$$.fragment),_l=c(),oe=o("p"),bl=r("A "),Ir=o("a"),vl=r("TrainerCallback"),El=r(" that sends the logs to "),it=o("a"),kl=r("Comet ML"),Tl=r("."),$l=c(),R=o("div"),_(ct.$$.fragment),Cl=c(),ma=o("p"),wl=r("Setup the optional Comet.ml integration."),yl=c(),L=o("p"),Al=r(`Environment:
COMET_MODE (`),ha=o("code"),Ll=r("str"),Dl=r(", "),pa=o("em"),Ol=r("optional"),xl=r(`):
Whether to create an online, offline experiment or disable Comet logging. Can be \u201COFFLINE\u201D, \u201CONLINE\u201D,
or \u201CDISABLED\u201D. Defaults to \u201CONLINE\u201D.
COMET_PROJECT_NAME (`),ga=o("code"),Ml=r("str"),Sl=r(", "),ua=o("em"),Il=r("optional"),Pl=r(`):
Comet project name for experiments
COMET_OFFLINE_DIRECTORY (`),_a=o("code"),Fl=r("str"),Wl=r(", "),ba=o("em"),Nl=r("optional"),jl=r(`):
Folder to use for saving offline experiments when `),va=o("code"),zl=r("COMET_MODE"),Bl=r(` is \u201COFFLINE\u201D
COMET_LOG_ASSETS (`),Ea=o("code"),Rl=r("str"),Vl=r(", "),ka=o("em"),Ul=r("optional"),ql=r(`):
Whether or not to log training assets (tf event logs, checkpoints, etc), to Comet. Can be \u201CTRUE\u201D, or
\u201CFALSE\u201D. Defaults to \u201CTRUE\u201D.`),Gl=c(),dt=o("p"),Hl=r(`For a number of configurable items in the environment, see
`),ft=o("a"),Jl=r("here"),Yl=r("."),Kn=c(),se=o("div"),_(mt.$$.fragment),Xl=c(),ht=o("p"),Kl=r("A "),Pr=o("a"),Ql=r("TrainerCallback"),Zl=r(" that handles the default flow of the training loop for logs, evaluation and checkpoints."),Qn=c(),le=o("div"),_(pt.$$.fragment),ei=c(),gt=o("p"),ti=r("A bare "),Fr=o("a"),ri=r("TrainerCallback"),ai=r(" that just prints the logs."),Zn=c(),ie=o("div"),_(ut.$$.fragment),ni=c(),_t=o("p"),oi=r("A "),Wr=o("a"),si=r("TrainerCallback"),li=r(" that displays the progress of training or evaluation."),eo=c(),J=o("div"),_(bt.$$.fragment),ii=c(),vt=o("p"),ci=r("A "),Nr=o("a"),di=r("TrainerCallback"),fi=r(" that handles early stopping."),mi=c(),Y=o("p"),hi=r("This callback depends on "),jr=o("a"),pi=r("TrainingArguments"),gi=r(" argument "),Ta=o("em"),ui=r("load_best_model_at_end"),_i=r(` functionality to set best_metric
in `),zr=o("a"),bi=r("TrainerState"),vi=r("."),to=c(),ce=o("div"),_(Et.$$.fragment),Ei=c(),de=o("p"),ki=r("A "),Br=o("a"),Ti=r("TrainerCallback"),$i=r(" that sends the logs to "),kt=o("a"),Ci=r("TensorBoard"),wi=r("."),ro=c(),X=o("div"),_(Tt.$$.fragment),yi=c(),fe=o("p"),Ai=r("A "),Rr=o("a"),Li=r("TrainerCallback"),Di=r(" that sends the logs to "),$t=o("a"),Oi=r("Weight and Biases"),xi=r("."),Mi=c(),V=o("div"),_(Ct.$$.fragment),Si=c(),wt=o("p"),Ii=r("Setup the optional Weights & Biases ("),$a=o("em"),Pi=r("wandb"),Fi=r(") integration."),Wi=c(),yt=o("p"),Ni=r(`One can subclass and override this method to customize the setup if needed. Find more information
`),At=o("a"),ji=r("here"),zi=r(`. You can also override the following environment
variables:`),Bi=c(),h=o("p"),Ri=r(`Environment:
WANDB_LOG_MODEL (`),Ca=o("code"),Vi=r("bool"),Ui=r(", "),wa=o("em"),qi=r("optional"),Gi=r(", defaults to "),ya=o("code"),Hi=r("False"),Ji=r(`):
Whether or not to log model as artifact at the end of training. Use along with
`),Aa=o("em"),Yi=r("TrainingArguments.load_best_model_at_end"),Xi=r(` to upload best model.
WANDB_WATCH (`),La=o("code"),Ki=r("str"),Qi=r(", "),Da=o("em"),Zi=r("optional"),ec=r(" defaults to "),Oa=o("code"),tc=r('"gradients"'),rc=r(`):
Can be `),xa=o("code"),ac=r('"gradients"'),nc=r(", "),Ma=o("code"),oc=r('"all"'),sc=r(" or "),Sa=o("code"),lc=r('"false"'),ic=r(". Set to "),Ia=o("code"),cc=r('"false"'),dc=r(" to disable gradient logging or "),Pa=o("code"),fc=r('"all"'),mc=r(` to
log gradients and parameters.
WANDB_PROJECT (`),Fa=o("code"),hc=r("str"),pc=r(", "),Wa=o("em"),gc=r("optional"),uc=r(", defaults to "),Na=o("code"),_c=r('"huggingface"'),bc=r(`):
Set this to a custom string to store results in a different project.
WANDB_DISABLED (`),ja=o("code"),vc=r("bool"),Ec=r(", "),za=o("em"),kc=r("optional"),Tc=r(", defaults to "),Ba=o("code"),$c=r("False"),Cc=r(`):
Whether or not to disable wandb entirely. Set `),Ra=o("em"),wc=r("WANDB_DISABLED=true"),yc=r(" to disable."),ao=c(),K=o("div"),_(Lt.$$.fragment),Ac=c(),Q=o("p"),Lc=r("A "),Vr=o("a"),Dc=r("TrainerCallback"),Oc=r(" that sends the logs to "),Dt=o("a"),xc=r("MLflow"),Mc=r(`. Can be disabled by setting
environment variable `),Va=o("code"),Sc=r("DISABLE_MLFLOW_INTEGRATION = TRUE"),Ic=r("."),Pc=c(),ee=o("div"),_(Ot.$$.fragment),Fc=c(),Ua=o("p"),Wc=r("Setup the optional MLflow integration."),Nc=c(),p=o("p"),jc=r(`Environment:
HF_MLFLOW_LOG_ARTIFACTS (`),qa=o("code"),zc=r("str"),Bc=r(", "),Ga=o("em"),Rc=r("optional"),Vc=r(`):
Whether to use MLflow .log_artifact() facility to log artifacts. This only makes sense if logging to a
remote server, e.g. s3 or GCS. If set to `),Ha=o("code"),Uc=r("True"),qc=r(" or "),Ja=o("em"),Gc=r("1"),Hc=r(`, will copy whatever is in
`),Ur=o("a"),Jc=r("TrainingArguments"),Yc=r("\u2019s "),Ya=o("code"),Xc=r("output_dir"),Kc=r(` to the local or remote artifact storage. Using it without a remote
storage will just copy the files to your artifact location.
MLFLOW_EXPERIMENT_NAME (`),Xa=o("code"),Qc=r("str"),Zc=r(", "),Ka=o("em"),ed=r("optional"),td=r(`):
Whether to use an MLflow experiment_name under which to launch the run. Default to \u201CNone\u201D which will
point to the \u201CDefault\u201D experiment in MLflow. Otherwise, it is a case sensitive name of the experiment
to be activated. If an experiment with this name does not exist, a new experiment with this name is
created.
MLFLOW_TAGS (`),Qa=o("code"),rd=r("str"),ad=r(", "),Za=o("em"),nd=r("optional"),od=r(`):
A string dump of a dictionary of key/value pair to be added to the MLflow run as tags. Example:
os.environ[\u2018MLFLOW_TAGS\u2019]=\u2019{\u201Crelease.candidate\u201D: \u201CRC1\u201D, \u201Crelease.version\u201D: \u201C2.2.0\u201D}\u2019
MLFLOW_NESTED_RUN (`),en=o("code"),sd=r("str"),ld=r(", "),tn=o("em"),id=r("optional"),cd=r(`):
Whether to use MLflow nested runs. If set to `),rn=o("code"),dd=r("True"),fd=r(" or "),an=o("em"),md=r("1"),hd=r(`, will create a nested run inside the current
run.
MLFLOW_RUN_ID (`),nn=o("code"),pd=r("str"),gd=r(", "),on=o("em"),ud=r("optional"),_d=r(`):
Allow to reattach to an existing run which can be usefull when resuming training from a checkpoint.
When MLFLOW_RUN_ID environment variable is set, start_run attempts to resume a run with the specified
run ID and other parameters are ignored.
MLFLOW_FLATTEN_PARAMS (`),sn=o("code"),bd=r("str"),vd=r(", "),ln=o("em"),Ed=r("optional"),kd=r(`):
Whether to flatten the parameters dictionary before logging. Default to `),cn=o("code"),Td=r("False"),$d=r("."),no=c(),me=o("div"),_(xt.$$.fragment),Cd=c(),he=o("p"),wd=r("A "),qr=o("a"),yd=r("TrainerCallback"),Ad=r(" that sends the logs to "),Mt=o("a"),Ld=r("AzureML"),Dd=r("."),oo=c(),pe=o("div"),_(St.$$.fragment),Od=c(),It=o("p"),xd=r("A "),Gr=o("a"),Md=r("TrainerCallback"),Sd=r(" that tracks the CO2 emission of training."),so=c(),ge=o("h2"),De=o("a"),dn=o("span"),_(Pt.$$.fragment),Id=c(),fn=o("span"),Pd=r("TrainerCallback"),lo=c(),$=o("div"),_(Ft.$$.fragment),Fd=c(),mn=o("p"),Wd=r(`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:`),Nd=c(),Wt=o("p"),jd=r("The "),hn=o("code"),zd=r("control"),Bd=r(` 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.`),Rd=c(),P=o("p"),Vd=r("The argument "),pn=o("code"),Ud=r("args"),qd=r(", "),gn=o("code"),Gd=r("state"),Hd=r(" and "),un=o("code"),Jd=r("control"),Yd=r(" are positionals for all events, all the others are grouped in "),_n=o("code"),Xd=r("kwargs"),Kd=r(`.
You can unpack the ones you need in the signature of the event using them. As an example, see the code of the
simple `),bn=o("code"),Qd=r("PrinterCallback"),Zd=r("."),ef=c(),_(Oe.$$.fragment),tf=c(),xe=o("div"),_(Nt.$$.fragment),rf=c(),vn=o("p"),af=r("Event called at the beginning of an epoch."),nf=c(),Me=o("div"),_(jt.$$.fragment),of=c(),En=o("p"),sf=r("Event called at the end of an epoch."),lf=c(),Se=o("div"),_(zt.$$.fragment),cf=c(),kn=o("p"),df=r("Event called after an evaluation phase."),ff=c(),Ie=o("div"),_(Bt.$$.fragment),mf=c(),Rt=o("p"),hf=r("Event called at the end of the initialization of the "),Hr=o("a"),pf=r("Trainer"),gf=r("."),uf=c(),Pe=o("div"),_(Vt.$$.fragment),_f=c(),Tn=o("p"),bf=r("Event called after logging the last logs."),vf=c(),Fe=o("div"),_(Ut.$$.fragment),Ef=c(),$n=o("p"),kf=r("Event called after a prediction step."),Tf=c(),We=o("div"),_(qt.$$.fragment),$f=c(),Cn=o("p"),Cf=r("Event called after a checkpoint save."),wf=c(),Ne=o("div"),_(Gt.$$.fragment),yf=c(),wn=o("p"),Af=r(`Event called at the beginning of a training step. If using gradient accumulation, one training step might take
several inputs.`),Lf=c(),je=o("div"),_(Ht.$$.fragment),Df=c(),yn=o("p"),Of=r(`Event called at the end of a training step. If using gradient accumulation, one training step might take
several inputs.`),xf=c(),ze=o("div"),_(Jt.$$.fragment),Mf=c(),An=o("p"),Sf=r("Event called at the end of an substep during gradient accumulation."),If=c(),Be=o("div"),_(Yt.$$.fragment),Pf=c(),Ln=o("p"),Ff=r("Event called at the beginning of training."),Wf=c(),Re=o("div"),_(Xt.$$.fragment),Nf=c(),Dn=o("p"),jf=r("Event called at the end of training."),io=c(),Ve=o("p"),zf=r("Here is an example of how to register a custom callback with the PyTorch "),Jr=o("a"),Bf=r("Trainer"),Rf=r(":"),co=c(),_(Kt.$$.fragment),fo=c(),Ue=o("p"),Vf=r("Another way to register a callback is to call "),On=o("code"),Uf=r("trainer.add_callback()"),qf=r(" as follows:"),mo=c(),_(Qt.$$.fragment),ho=c(),ue=o("h2"),qe=o("a"),xn=o("span"),_(Zt.$$.fragment),Gf=c(),Mn=o("span"),Hf=r("TrainerState"),po=c(),F=o("div"),_(er.$$.fragment),Jf=c(),_e=o("p"),Yf=r("A class containing the "),Yr=o("a"),Xf=r("Trainer"),Kf=r(` inner state that will be saved along the model and optimizer when checkpointing
and passed to the `),Xr=o("a"),Qf=r("TrainerCallback"),Zf=r("."),em=c(),_(Ge.$$.fragment),tm=c(),He=o("div"),_(tr.$$.fragment),rm=c(),rr=o("p"),am=r("Create an instance from the content of "),Sn=o("code"),nm=r("json_path"),om=r("."),sm=c(),Je=o("div"),_(ar.$$.fragment),lm=c(),nr=o("p"),im=r("Save the content of this instance in JSON format inside "),In=o("code"),cm=r("json_path"),dm=r("."),go=c(),be=o("h2"),Ye=o("a"),Pn=o("span"),_(or.$$.fragment),fm=c(),Fn=o("span"),mm=r("TrainerControl"),uo=c(),ve=o("div"),_(sr.$$.fragment),hm=c(),Ee=o("p"),pm=r("A class that handles the "),Kr=o("a"),gm=r("Trainer"),um=r(" control flow. This class is used by the "),Qr=o("a"),_m=r("TrainerCallback"),bm=r(` to activate some
switches in the training loop.`),this.h()},l(n){const f=tg('[data-svelte="svelte-1phssyn"]',document.head);A=s(f,"META",{name:!0,content:!0}),f.forEach(t),z=d(n),D=s(n,"H1",{class:!0});var lr=l(D);O=s(lr,"A",{id:!0,class:!0,href:!0});var Wn=l(O);W=s(Wn,"SPAN",{});var Tm=l(W);b(y.$$.fragment,Tm),Tm.forEach(t),Wn.forEach(t),N=d(lr),re=s(lr,"SPAN",{});var $m=l(re);ae=a($m,"Callbacks"),$m.forEach(t),lr.forEach(t),j=d(n),G=s(n,"P",{});var bo=l(G);dr=a(bo,`Callbacks are objects that can customize the behavior of the training loop in the PyTorch
`),fr=s(bo,"A",{href:!0});var Cm=l(fr);ss=a(Cm,"Trainer"),Cm.forEach(t),ls=a(bo,` (this feature is not yet implemented in TensorFlow) that can inspect the training loop
state (for progress reporting, logging on TensorBoard or other ML platforms\u2026) and take decisions (like early
stopping).`),bo.forEach(t),Un=d(n),B=s(n,"P",{});var Xe=l(B);is=a(Xe,"Callbacks are \u201Cread only\u201D pieces of code, apart from the "),mr=s(Xe,"A",{href:!0});var wm=l(mr);cs=a(wm,"TrainerControl"),wm.forEach(t),ds=a(Xe,` object they return, they
cannot change anything in the training loop. For customizations that require changes in the training loop, you should
subclass `),hr=s(Xe,"A",{href:!0});var ym=l(hr);fs=a(ym,"Trainer"),ym.forEach(t),ms=a(Xe," and override the methods you need (see "),pr=s(Xe,"A",{href:!0});var Am=l(pr);hs=a(Am,"trainer"),Am.forEach(t),ps=a(Xe," for examples)."),Xe.forEach(t),qn=d(n),ke=s(n,"P",{});var vo=l(ke);gs=a(vo,"By default a "),gr=s(vo,"A",{href:!0});var Lm=l(gr);us=a(Lm,"Trainer"),Lm.forEach(t),_s=a(vo," will use the following callbacks:"),vo.forEach(t),Gn=d(n),x=s(n,"UL",{});var I=l(x);ur=s(I,"LI",{});var vm=l(ur);_r=s(vm,"A",{href:!0});var Dm=l(_r);bs=a(Dm,"DefaultFlowCallback"),Dm.forEach(t),vs=a(vm," which handles the default behavior for logging, saving and evaluation."),vm.forEach(t),Es=d(I),Z=s(I,"LI",{});var ir=l(Z);br=s(ir,"A",{href:!0});var Om=l(br);ks=a(Om,"PrinterCallback"),Om.forEach(t),Ts=a(ir," or "),vr=s(ir,"A",{href:!0});var xm=l(vr);$s=a(xm,"ProgressCallback"),xm.forEach(t),Cs=a(ir,` to display progress and print the
logs (the first one is used if you deactivate tqdm through the `),Er=s(ir,"A",{href:!0});var Mm=l(Er);ws=a(Mm,"TrainingArguments"),Mm.forEach(t),ys=a(ir,`, otherwise
it\u2019s the second one).`),ir.forEach(t),As=d(I),kr=s(I,"LI",{});var Em=l(kr);Tr=s(Em,"A",{href:!0});var Sm=l(Tr);Ls=a(Sm,"TensorBoardCallback"),Sm.forEach(t),Ds=a(Em,` if tensorboard is accessible (either through PyTorch >= 1.4
or tensorboardX).`),Em.forEach(t),Os=d(I),Te=s(I,"LI",{});var Nn=l(Te);$r=s(Nn,"A",{href:!0});var Im=l($r);xs=a(Im,"WandbCallback"),Im.forEach(t),Ms=a(Nn," if "),tt=s(Nn,"A",{href:!0,rel:!0});var Pm=l(tt);Ss=a(Pm,"wandb"),Pm.forEach(t),Is=a(Nn," is installed."),Nn.forEach(t),Ps=d(I),$e=s(I,"LI",{});var jn=l($e);Cr=s(jn,"A",{href:!0});var Fm=l(Cr);Fs=a(Fm,"CometCallback"),Fm.forEach(t),Ws=a(jn," if "),rt=s(jn,"A",{href:!0,rel:!0});var Wm=l(rt);Ns=a(Wm,"comet_ml"),Wm.forEach(t),js=a(jn," is installed."),jn.forEach(t),zs=d(I),Ce=s(I,"LI",{});var zn=l(Ce);wr=s(zn,"A",{href:!0});var Nm=l(wr);Bs=a(Nm,"MLflowCallback"),Nm.forEach(t),Rs=a(zn," if "),at=s(zn,"A",{href:!0,rel:!0});var jm=l(at);Vs=a(jm,"mlflow"),jm.forEach(t),Us=a(zn," is installed."),zn.forEach(t),qs=d(I),we=s(I,"LI",{});var Bn=l(we);yr=s(Bn,"A",{href:!0});var zm=l(yr);Gs=a(zm,"AzureMLCallback"),zm.forEach(t),Hs=a(Bn," if "),nt=s(Bn,"A",{href:!0,rel:!0});var Bm=l(nt);Js=a(Bm,"azureml-sdk"),Bm.forEach(t),Ys=a(Bn,` is
installed.`),Bn.forEach(t),Xs=d(I),ye=s(I,"LI",{});var Rn=l(ye);Ar=s(Rn,"A",{href:!0});var Rm=l(Ar);Ks=a(Rm,"CodeCarbonCallback"),Rm.forEach(t),Qs=a(Rn," if "),ot=s(Rn,"A",{href:!0,rel:!0});var Vm=l(ot);Zs=a(Vm,"codecarbon"),Vm.forEach(t),el=a(Rn,` is
installed.`),Rn.forEach(t),I.forEach(t),Hn=d(n),S=s(n,"P",{});var U=l(S);tl=a(U,"The main class that implements callbacks is "),Lr=s(U,"A",{href:!0});var Um=l(Lr);rl=a(Um,"TrainerCallback"),Um.forEach(t),al=a(U,`. It gets the
`),Dr=s(U,"A",{href:!0});var qm=l(Dr);nl=a(qm,"TrainingArguments"),qm.forEach(t),ol=a(U," used to instantiate the "),Or=s(U,"A",{href:!0});var Gm=l(Or);sl=a(Gm,"Trainer"),Gm.forEach(t),ll=a(U,`, can access that
Trainer\u2019s internal state via `),xr=s(U,"A",{href:!0});var Hm=l(xr);il=a(Hm,"TrainerState"),Hm.forEach(t),cl=a(U,`, and can take some actions on the training loop via
`),Mr=s(U,"A",{href:!0});var Jm=l(Mr);dl=a(Jm,"TrainerControl"),Jm.forEach(t),fl=a(U,"."),U.forEach(t),Jn=d(n),ne=s(n,"H2",{class:!0});var Eo=l(ne);Ae=s(Eo,"A",{id:!0,class:!0,href:!0});var Ym=l(Ae);da=s(Ym,"SPAN",{});var Xm=l(da);b(st.$$.fragment,Xm),Xm.forEach(t),Ym.forEach(t),ml=d(Eo),fa=s(Eo,"SPAN",{});var Km=l(fa);hl=a(Km,"Available Callbacks"),Km.forEach(t),Eo.forEach(t),Yn=d(n),Le=s(n,"P",{});var ko=l(Le);pl=a(ko,"Here is the list of the available "),Sr=s(ko,"A",{href:!0});var Qm=l(Sr);gl=a(Qm,"TrainerCallback"),Qm.forEach(t),ul=a(ko," in the library:"),ko.forEach(t),Xn=d(n),H=s(n,"DIV",{class:!0});var Zr=l(H);b(lt.$$.fragment,Zr),_l=d(Zr),oe=s(Zr,"P",{});var ea=l(oe);bl=a(ea,"A "),Ir=s(ea,"A",{href:!0});var Zm=l(Ir);vl=a(Zm,"TrainerCallback"),Zm.forEach(t),El=a(ea," that sends the logs to "),it=s(ea,"A",{href:!0,rel:!0});var eh=l(it);kl=a(eh,"Comet ML"),eh.forEach(t),Tl=a(ea,"."),ea.forEach(t),$l=d(Zr),R=s(Zr,"DIV",{class:!0});var Ke=l(R);b(ct.$$.fragment,Ke),Cl=d(Ke),ma=s(Ke,"P",{});var th=l(ma);wl=a(th,"Setup the optional Comet.ml integration."),th.forEach(t),yl=d(Ke),L=s(Ke,"P",{});var M=l(L);Al=a(M,`Environment:
COMET_MODE (`),ha=s(M,"CODE",{});var rh=l(ha);Ll=a(rh,"str"),rh.forEach(t),Dl=a(M,", "),pa=s(M,"EM",{});var ah=l(pa);Ol=a(ah,"optional"),ah.forEach(t),xl=a(M,`):
Whether to create an online, offline experiment or disable Comet logging. Can be \u201COFFLINE\u201D, \u201CONLINE\u201D,
or \u201CDISABLED\u201D. Defaults to \u201CONLINE\u201D.
COMET_PROJECT_NAME (`),ga=s(M,"CODE",{});var nh=l(ga);Ml=a(nh,"str"),nh.forEach(t),Sl=a(M,", "),ua=s(M,"EM",{});var oh=l(ua);Il=a(oh,"optional"),oh.forEach(t),Pl=a(M,`):
Comet project name for experiments
COMET_OFFLINE_DIRECTORY (`),_a=s(M,"CODE",{});var sh=l(_a);Fl=a(sh,"str"),sh.forEach(t),Wl=a(M,", "),ba=s(M,"EM",{});var lh=l(ba);Nl=a(lh,"optional"),lh.forEach(t),jl=a(M,`):
Folder to use for saving offline experiments when `),va=s(M,"CODE",{});var ih=l(va);zl=a(ih,"COMET_MODE"),ih.forEach(t),Bl=a(M,` is \u201COFFLINE\u201D
COMET_LOG_ASSETS (`),Ea=s(M,"CODE",{});var ch=l(Ea);Rl=a(ch,"str"),ch.forEach(t),Vl=a(M,", "),ka=s(M,"EM",{});var dh=l(ka);Ul=a(dh,"optional"),dh.forEach(t),ql=a(M,`):
Whether or not to log training assets (tf event logs, checkpoints, etc), to Comet. Can be \u201CTRUE\u201D, or
\u201CFALSE\u201D. Defaults to \u201CTRUE\u201D.`),M.forEach(t),Gl=d(Ke),dt=s(Ke,"P",{});var To=l(dt);Hl=a(To,`For a number of configurable items in the environment, see
`),ft=s(To,"A",{href:!0,rel:!0});var fh=l(ft);Jl=a(fh,"here"),fh.forEach(t),Yl=a(To,"."),To.forEach(t),Ke.forEach(t),Zr.forEach(t),Kn=d(n),se=s(n,"DIV",{class:!0});var $o=l(se);b(mt.$$.fragment,$o),Xl=d($o),ht=s($o,"P",{});var Co=l(ht);Kl=a(Co,"A "),Pr=s(Co,"A",{href:!0});var mh=l(Pr);Ql=a(mh,"TrainerCallback"),mh.forEach(t),Zl=a(Co," that handles the default flow of the training loop for logs, evaluation and checkpoints."),Co.forEach(t),$o.forEach(t),Qn=d(n),le=s(n,"DIV",{class:!0});var wo=l(le);b(pt.$$.fragment,wo),ei=d(wo),gt=s(wo,"P",{});var yo=l(gt);ti=a(yo,"A bare "),Fr=s(yo,"A",{href:!0});var hh=l(Fr);ri=a(hh,"TrainerCallback"),hh.forEach(t),ai=a(yo," that just prints the logs."),yo.forEach(t),wo.forEach(t),Zn=d(n),ie=s(n,"DIV",{class:!0});var Ao=l(ie);b(ut.$$.fragment,Ao),ni=d(Ao),_t=s(Ao,"P",{});var Lo=l(_t);oi=a(Lo,"A "),Wr=s(Lo,"A",{href:!0});var ph=l(Wr);si=a(ph,"TrainerCallback"),ph.forEach(t),li=a(Lo," that displays the progress of training or evaluation."),Lo.forEach(t),Ao.forEach(t),eo=d(n),J=s(n,"DIV",{class:!0});var ta=l(J);b(bt.$$.fragment,ta),ii=d(ta),vt=s(ta,"P",{});var Do=l(vt);ci=a(Do,"A "),Nr=s(Do,"A",{href:!0});var gh=l(Nr);di=a(gh,"TrainerCallback"),gh.forEach(t),fi=a(Do," that handles early stopping."),Do.forEach(t),mi=d(ta),Y=s(ta,"P",{});var Qe=l(Y);hi=a(Qe,"This callback depends on "),jr=s(Qe,"A",{href:!0});var uh=l(jr);pi=a(uh,"TrainingArguments"),uh.forEach(t),gi=a(Qe," argument "),Ta=s(Qe,"EM",{});var _h=l(Ta);ui=a(_h,"load_best_model_at_end"),_h.forEach(t),_i=a(Qe,` functionality to set best_metric
in `),zr=s(Qe,"A",{href:!0});var bh=l(zr);bi=a(bh,"TrainerState"),bh.forEach(t),vi=a(Qe,"."),Qe.forEach(t),ta.forEach(t),to=d(n),ce=s(n,"DIV",{class:!0});var Oo=l(ce);b(Et.$$.fragment,Oo),Ei=d(Oo),de=s(Oo,"P",{});var ra=l(de);ki=a(ra,"A "),Br=s(ra,"A",{href:!0});var vh=l(Br);Ti=a(vh,"TrainerCallback"),vh.forEach(t),$i=a(ra," that sends the logs to "),kt=s(ra,"A",{href:!0,rel:!0});var Eh=l(kt);Ci=a(Eh,"TensorBoard"),Eh.forEach(t),wi=a(ra,"."),ra.forEach(t),Oo.forEach(t),ro=d(n),X=s(n,"DIV",{class:!0});var aa=l(X);b(Tt.$$.fragment,aa),yi=d(aa),fe=s(aa,"P",{});var na=l(fe);Ai=a(na,"A "),Rr=s(na,"A",{href:!0});var kh=l(Rr);Li=a(kh,"TrainerCallback"),kh.forEach(t),Di=a(na," that sends the logs to "),$t=s(na,"A",{href:!0,rel:!0});var Th=l($t);Oi=a(Th,"Weight and Biases"),Th.forEach(t),xi=a(na,"."),na.forEach(t),Mi=d(aa),V=s(aa,"DIV",{class:!0});var Ze=l(V);b(Ct.$$.fragment,Ze),Si=d(Ze),wt=s(Ze,"P",{});var xo=l(wt);Ii=a(xo,"Setup the optional Weights & Biases ("),$a=s(xo,"EM",{});var $h=l($a);Pi=a($h,"wandb"),$h.forEach(t),Fi=a(xo,") integration."),xo.forEach(t),Wi=d(Ze),yt=s(Ze,"P",{});var Mo=l(yt);Ni=a(Mo,`One can subclass and override this method to customize the setup if needed. Find more information
`),At=s(Mo,"A",{href:!0,rel:!0});var Ch=l(At);ji=a(Ch,"here"),Ch.forEach(t),zi=a(Mo,`. You can also override the following environment
variables:`),Mo.forEach(t),Bi=d(Ze),h=s(Ze,"P",{});var g=l(h);Ri=a(g,`Environment:
WANDB_LOG_MODEL (`),Ca=s(g,"CODE",{});var wh=l(Ca);Vi=a(wh,"bool"),wh.forEach(t),Ui=a(g,", "),wa=s(g,"EM",{});var yh=l(wa);qi=a(yh,"optional"),yh.forEach(t),Gi=a(g,", defaults to "),ya=s(g,"CODE",{});var Ah=l(ya);Hi=a(Ah,"False"),Ah.forEach(t),Ji=a(g,`):
Whether or not to log model as artifact at the end of training. Use along with
`),Aa=s(g,"EM",{});var Lh=l(Aa);Yi=a(Lh,"TrainingArguments.load_best_model_at_end"),Lh.forEach(t),Xi=a(g,` to upload best model.
WANDB_WATCH (`),La=s(g,"CODE",{});var Dh=l(La);Ki=a(Dh,"str"),Dh.forEach(t),Qi=a(g,", "),Da=s(g,"EM",{});var Oh=l(Da);Zi=a(Oh,"optional"),Oh.forEach(t),ec=a(g," defaults to "),Oa=s(g,"CODE",{});var xh=l(Oa);tc=a(xh,'"gradients"'),xh.forEach(t),rc=a(g,`):
Can be `),xa=s(g,"CODE",{});var Mh=l(xa);ac=a(Mh,'"gradients"'),Mh.forEach(t),nc=a(g,", "),Ma=s(g,"CODE",{});var Sh=l(Ma);oc=a(Sh,'"all"'),Sh.forEach(t),sc=a(g," or "),Sa=s(g,"CODE",{});var Ih=l(Sa);lc=a(Ih,'"false"'),Ih.forEach(t),ic=a(g,". Set to "),Ia=s(g,"CODE",{});var Ph=l(Ia);cc=a(Ph,'"false"'),Ph.forEach(t),dc=a(g," to disable gradient logging or "),Pa=s(g,"CODE",{});var Fh=l(Pa);fc=a(Fh,'"all"'),Fh.forEach(t),mc=a(g,` to
log gradients and parameters.
WANDB_PROJECT (`),Fa=s(g,"CODE",{});var Wh=l(Fa);hc=a(Wh,"str"),Wh.forEach(t),pc=a(g,", "),Wa=s(g,"EM",{});var Nh=l(Wa);gc=a(Nh,"optional"),Nh.forEach(t),uc=a(g,", defaults to "),Na=s(g,"CODE",{});var jh=l(Na);_c=a(jh,'"huggingface"'),jh.forEach(t),bc=a(g,`):
Set this to a custom string to store results in a different project.
WANDB_DISABLED (`),ja=s(g,"CODE",{});var zh=l(ja);vc=a(zh,"bool"),zh.forEach(t),Ec=a(g,", "),za=s(g,"EM",{});var Bh=l(za);kc=a(Bh,"optional"),Bh.forEach(t),Tc=a(g,", defaults to "),Ba=s(g,"CODE",{});var Rh=l(Ba);$c=a(Rh,"False"),Rh.forEach(t),Cc=a(g,`):
Whether or not to disable wandb entirely. Set `),Ra=s(g,"EM",{});var Vh=l(Ra);wc=a(Vh,"WANDB_DISABLED=true"),Vh.forEach(t),yc=a(g," to disable."),g.forEach(t),Ze.forEach(t),aa.forEach(t),ao=d(n),K=s(n,"DIV",{class:!0});var oa=l(K);b(Lt.$$.fragment,oa),Ac=d(oa),Q=s(oa,"P",{});var et=l(Q);Lc=a(et,"A "),Vr=s(et,"A",{href:!0});var Uh=l(Vr);Dc=a(Uh,"TrainerCallback"),Uh.forEach(t),Oc=a(et," that sends the logs to "),Dt=s(et,"A",{href:!0,rel:!0});var qh=l(Dt);xc=a(qh,"MLflow"),qh.forEach(t),Mc=a(et,`. Can be disabled by setting
environment variable `),Va=s(et,"CODE",{});var Gh=l(Va);Sc=a(Gh,"DISABLE_MLFLOW_INTEGRATION = TRUE"),Gh.forEach(t),Ic=a(et,"."),et.forEach(t),Pc=d(oa),ee=s(oa,"DIV",{class:!0});var sa=l(ee);b(Ot.$$.fragment,sa),Fc=d(sa),Ua=s(sa,"P",{});var Hh=l(Ua);Wc=a(Hh,"Setup the optional MLflow integration."),Hh.forEach(t),Nc=d(sa),p=s(sa,"P",{});var u=l(p);jc=a(u,`Environment:
HF_MLFLOW_LOG_ARTIFACTS (`),qa=s(u,"CODE",{});var Jh=l(qa);zc=a(Jh,"str"),Jh.forEach(t),Bc=a(u,", "),Ga=s(u,"EM",{});var Yh=l(Ga);Rc=a(Yh,"optional"),Yh.forEach(t),Vc=a(u,`):
Whether to use MLflow .log_artifact() facility to log artifacts. This only makes sense if logging to a
remote server, e.g. s3 or GCS. If set to `),Ha=s(u,"CODE",{});var Xh=l(Ha);Uc=a(Xh,"True"),Xh.forEach(t),qc=a(u," or "),Ja=s(u,"EM",{});var Kh=l(Ja);Gc=a(Kh,"1"),Kh.forEach(t),Hc=a(u,`, will copy whatever is in
`),Ur=s(u,"A",{href:!0});var Qh=l(Ur);Jc=a(Qh,"TrainingArguments"),Qh.forEach(t),Yc=a(u,"\u2019s "),Ya=s(u,"CODE",{});var Zh=l(Ya);Xc=a(Zh,"output_dir"),Zh.forEach(t),Kc=a(u,` to the local or remote artifact storage. Using it without a remote
storage will just copy the files to your artifact location.
MLFLOW_EXPERIMENT_NAME (`),Xa=s(u,"CODE",{});var ep=l(Xa);Qc=a(ep,"str"),ep.forEach(t),Zc=a(u,", "),Ka=s(u,"EM",{});var tp=l(Ka);ed=a(tp,"optional"),tp.forEach(t),td=a(u,`):
Whether to use an MLflow experiment_name under which to launch the run. Default to \u201CNone\u201D which will
point to the \u201CDefault\u201D experiment in MLflow. Otherwise, it is a case sensitive name of the experiment
to be activated. If an experiment with this name does not exist, a new experiment with this name is
created.
MLFLOW_TAGS (`),Qa=s(u,"CODE",{});var rp=l(Qa);rd=a(rp,"str"),rp.forEach(t),ad=a(u,", "),Za=s(u,"EM",{});var ap=l(Za);nd=a(ap,"optional"),ap.forEach(t),od=a(u,`):
A string dump of a dictionary of key/value pair to be added to the MLflow run as tags. Example:
os.environ[\u2018MLFLOW_TAGS\u2019]=\u2019{\u201Crelease.candidate\u201D: \u201CRC1\u201D, \u201Crelease.version\u201D: \u201C2.2.0\u201D}\u2019
MLFLOW_NESTED_RUN (`),en=s(u,"CODE",{});var np=l(en);sd=a(np,"str"),np.forEach(t),ld=a(u,", "),tn=s(u,"EM",{});var op=l(tn);id=a(op,"optional"),op.forEach(t),cd=a(u,`):
Whether to use MLflow nested runs. If set to `),rn=s(u,"CODE",{});var sp=l(rn);dd=a(sp,"True"),sp.forEach(t),fd=a(u," or "),an=s(u,"EM",{});var lp=l(an);md=a(lp,"1"),lp.forEach(t),hd=a(u,`, will create a nested run inside the current
run.
MLFLOW_RUN_ID (`),nn=s(u,"CODE",{});var ip=l(nn);pd=a(ip,"str"),ip.forEach(t),gd=a(u,", "),on=s(u,"EM",{});var cp=l(on);ud=a(cp,"optional"),cp.forEach(t),_d=a(u,`):
Allow to reattach to an existing run which can be usefull when resuming training from a checkpoint.
When MLFLOW_RUN_ID environment variable is set, start_run attempts to resume a run with the specified
run ID and other parameters are ignored.
MLFLOW_FLATTEN_PARAMS (`),sn=s(u,"CODE",{});var dp=l(sn);bd=a(dp,"str"),dp.forEach(t),vd=a(u,", "),ln=s(u,"EM",{});var fp=l(ln);Ed=a(fp,"optional"),fp.forEach(t),kd=a(u,`):
Whether to flatten the parameters dictionary before logging. Default to `),cn=s(u,"CODE",{});var mp=l(cn);Td=a(mp,"False"),mp.forEach(t),$d=a(u,"."),u.forEach(t),sa.forEach(t),oa.forEach(t),no=d(n),me=s(n,"DIV",{class:!0});var So=l(me);b(xt.$$.fragment,So),Cd=d(So),he=s(So,"P",{});var la=l(he);wd=a(la,"A "),qr=s(la,"A",{href:!0});var hp=l(qr);yd=a(hp,"TrainerCallback"),hp.forEach(t),Ad=a(la," that sends the logs to "),Mt=s(la,"A",{href:!0,rel:!0});var pp=l(Mt);Ld=a(pp,"AzureML"),pp.forEach(t),Dd=a(la,"."),la.forEach(t),So.forEach(t),oo=d(n),pe=s(n,"DIV",{class:!0});var Io=l(pe);b(St.$$.fragment,Io),Od=d(Io),It=s(Io,"P",{});var Po=l(It);xd=a(Po,"A "),Gr=s(Po,"A",{href:!0});var gp=l(Gr);Md=a(gp,"TrainerCallback"),gp.forEach(t),Sd=a(Po," that tracks the CO2 emission of training."),Po.forEach(t),Io.forEach(t),so=d(n),ge=s(n,"H2",{class:!0});var Fo=l(ge);De=s(Fo,"A",{id:!0,class:!0,href:!0});var up=l(De);dn=s(up,"SPAN",{});var _p=l(dn);b(Pt.$$.fragment,_p),_p.forEach(t),up.forEach(t),Id=d(Fo),fn=s(Fo,"SPAN",{});var bp=l(fn);Pd=a(bp,"TrainerCallback"),bp.forEach(t),Fo.forEach(t),lo=d(n),$=s(n,"DIV",{class:!0});var C=l($);b(Ft.$$.fragment,C),Fd=d(C),mn=s(C,"P",{});var vp=l(mn);Wd=a(vp,`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:`),vp.forEach(t),Nd=d(C),Wt=s(C,"P",{});var Wo=l(Wt);jd=a(Wo,"The "),hn=s(Wo,"CODE",{});var Ep=l(hn);zd=a(Ep,"control"),Ep.forEach(t),Bd=a(Wo,` 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.`),Wo.forEach(t),Rd=d(C),P=s(C,"P",{});var q=l(P);Vd=a(q,"The argument "),pn=s(q,"CODE",{});var kp=l(pn);Ud=a(kp,"args"),kp.forEach(t),qd=a(q,", "),gn=s(q,"CODE",{});var Tp=l(gn);Gd=a(Tp,"state"),Tp.forEach(t),Hd=a(q," and "),un=s(q,"CODE",{});var $p=l(un);Jd=a($p,"control"),$p.forEach(t),Yd=a(q," are positionals for all events, all the others are grouped in "),_n=s(q,"CODE",{});var Cp=l(_n);Xd=a(Cp,"kwargs"),Cp.forEach(t),Kd=a(q,`.
You can unpack the ones you need in the signature of the event using them. As an example, see the code of the
simple `),bn=s(q,"CODE",{});var wp=l(bn);Qd=a(wp,"PrinterCallback"),wp.forEach(t),Zd=a(q,"."),q.forEach(t),ef=d(C),b(Oe.$$.fragment,C),tf=d(C),xe=s(C,"DIV",{class:!0});var No=l(xe);b(Nt.$$.fragment,No),rf=d(No),vn=s(No,"P",{});var yp=l(vn);af=a(yp,"Event called at the beginning of an epoch."),yp.forEach(t),No.forEach(t),nf=d(C),Me=s(C,"DIV",{class:!0});var jo=l(Me);b(jt.$$.fragment,jo),of=d(jo),En=s(jo,"P",{});var Ap=l(En);sf=a(Ap,"Event called at the end of an epoch."),Ap.forEach(t),jo.forEach(t),lf=d(C),Se=s(C,"DIV",{class:!0});var zo=l(Se);b(zt.$$.fragment,zo),cf=d(zo),kn=s(zo,"P",{});var Lp=l(kn);df=a(Lp,"Event called after an evaluation phase."),Lp.forEach(t),zo.forEach(t),ff=d(C),Ie=s(C,"DIV",{class:!0});var Bo=l(Ie);b(Bt.$$.fragment,Bo),mf=d(Bo),Rt=s(Bo,"P",{});var Ro=l(Rt);hf=a(Ro,"Event called at the end of the initialization of the "),Hr=s(Ro,"A",{href:!0});var Dp=l(Hr);pf=a(Dp,"Trainer"),Dp.forEach(t),gf=a(Ro,"."),Ro.forEach(t),Bo.forEach(t),uf=d(C),Pe=s(C,"DIV",{class:!0});var Vo=l(Pe);b(Vt.$$.fragment,Vo),_f=d(Vo),Tn=s(Vo,"P",{});var Op=l(Tn);bf=a(Op,"Event called after logging the last logs."),Op.forEach(t),Vo.forEach(t),vf=d(C),Fe=s(C,"DIV",{class:!0});var Uo=l(Fe);b(Ut.$$.fragment,Uo),Ef=d(Uo),$n=s(Uo,"P",{});var xp=l($n);kf=a(xp,"Event called after a prediction step."),xp.forEach(t),Uo.forEach(t),Tf=d(C),We=s(C,"DIV",{class:!0});var qo=l(We);b(qt.$$.fragment,qo),$f=d(qo),Cn=s(qo,"P",{});var Mp=l(Cn);Cf=a(Mp,"Event called after a checkpoint save."),Mp.forEach(t),qo.forEach(t),wf=d(C),Ne=s(C,"DIV",{class:!0});var Go=l(Ne);b(Gt.$$.fragment,Go),yf=d(Go),wn=s(Go,"P",{});var Sp=l(wn);Af=a(Sp,`Event called at the beginning of a training step. If using gradient accumulation, one training step might take
several inputs.`),Sp.forEach(t),Go.forEach(t),Lf=d(C),je=s(C,"DIV",{class:!0});var Ho=l(je);b(Ht.$$.fragment,Ho),Df=d(Ho),yn=s(Ho,"P",{});var Ip=l(yn);Of=a(Ip,`Event called at the end of a training step. If using gradient accumulation, one training step might take
several inputs.`),Ip.forEach(t),Ho.forEach(t),xf=d(C),ze=s(C,"DIV",{class:!0});var Jo=l(ze);b(Jt.$$.fragment,Jo),Mf=d(Jo),An=s(Jo,"P",{});var Pp=l(An);Sf=a(Pp,"Event called at the end of an substep during gradient accumulation."),Pp.forEach(t),Jo.forEach(t),If=d(C),Be=s(C,"DIV",{class:!0});var Yo=l(Be);b(Yt.$$.fragment,Yo),Pf=d(Yo),Ln=s(Yo,"P",{});var Fp=l(Ln);Ff=a(Fp,"Event called at the beginning of training."),Fp.forEach(t),Yo.forEach(t),Wf=d(C),Re=s(C,"DIV",{class:!0});var Xo=l(Re);b(Xt.$$.fragment,Xo),Nf=d(Xo),Dn=s(Xo,"P",{});var Wp=l(Dn);jf=a(Wp,"Event called at the end of training."),Wp.forEach(t),Xo.forEach(t),C.forEach(t),io=d(n),Ve=s(n,"P",{});var Ko=l(Ve);zf=a(Ko,"Here is an example of how to register a custom callback with the PyTorch "),Jr=s(Ko,"A",{href:!0});var Np=l(Jr);Bf=a(Np,"Trainer"),Np.forEach(t),Rf=a(Ko,":"),Ko.forEach(t),co=d(n),b(Kt.$$.fragment,n),fo=d(n),Ue=s(n,"P",{});var Qo=l(Ue);Vf=a(Qo,"Another way to register a callback is to call "),On=s(Qo,"CODE",{});var jp=l(On);Uf=a(jp,"trainer.add_callback()"),jp.forEach(t),qf=a(Qo," as follows:"),Qo.forEach(t),mo=d(n),b(Qt.$$.fragment,n),ho=d(n),ue=s(n,"H2",{class:!0});var Zo=l(ue);qe=s(Zo,"A",{id:!0,class:!0,href:!0});var zp=l(qe);xn=s(zp,"SPAN",{});var Bp=l(xn);b(Zt.$$.fragment,Bp),Bp.forEach(t),zp.forEach(t),Gf=d(Zo),Mn=s(Zo,"SPAN",{});var Rp=l(Mn);Hf=a(Rp,"TrainerState"),Rp.forEach(t),Zo.forEach(t),po=d(n),F=s(n,"DIV",{class:!0});var te=l(F);b(er.$$.fragment,te),Jf=d(te),_e=s(te,"P",{});var ia=l(_e);Yf=a(ia,"A class containing the "),Yr=s(ia,"A",{href:!0});var Vp=l(Yr);Xf=a(Vp,"Trainer"),Vp.forEach(t),Kf=a(ia,` inner state that will be saved along the model and optimizer when checkpointing
and passed to the `),Xr=s(ia,"A",{href:!0});var Up=l(Xr);Qf=a(Up,"TrainerCallback"),Up.forEach(t),Zf=a(ia,"."),ia.forEach(t),em=d(te),b(Ge.$$.fragment,te),tm=d(te),He=s(te,"DIV",{class:!0});var es=l(He);b(tr.$$.fragment,es),rm=d(es),rr=s(es,"P",{});var ts=l(rr);am=a(ts,"Create an instance from the content of "),Sn=s(ts,"CODE",{});var qp=l(Sn);nm=a(qp,"json_path"),qp.forEach(t),om=a(ts,"."),ts.forEach(t),es.forEach(t),sm=d(te),Je=s(te,"DIV",{class:!0});var rs=l(Je);b(ar.$$.fragment,rs),lm=d(rs),nr=s(rs,"P",{});var as=l(nr);im=a(as,"Save the content of this instance in JSON format inside "),In=s(as,"CODE",{});var Gp=l(In);cm=a(Gp,"json_path"),Gp.forEach(t),dm=a(as,"."),as.forEach(t),rs.forEach(t),te.forEach(t),go=d(n),be=s(n,"H2",{class:!0});var ns=l(be);Ye=s(ns,"A",{id:!0,class:!0,href:!0});var Hp=l(Ye);Pn=s(Hp,"SPAN",{});var Jp=l(Pn);b(or.$$.fragment,Jp),Jp.forEach(t),Hp.forEach(t),fm=d(ns),Fn=s(ns,"SPAN",{});var Yp=l(Fn);mm=a(Yp,"TrainerControl"),Yp.forEach(t),ns.forEach(t),uo=d(n),ve=s(n,"DIV",{class:!0});var os=l(ve);b(sr.$$.fragment,os),hm=d(os),Ee=s(os,"P",{});var ca=l(Ee);pm=a(ca,"A class that handles the "),Kr=s(ca,"A",{href:!0});var Xp=l(Kr);gm=a(Xp,"Trainer"),Xp.forEach(t),um=a(ca," control flow. This class is used by the "),Qr=s(ca,"A",{href:!0});var Kp=l(Qr);_m=a(Kp,"TrainerCallback"),Kp.forEach(t),bm=a(ca,` to activate some
switches in the training loop.`),ca.forEach(t),os.forEach(t),this.h()},h(){i(A,"name","hf:doc:metadata"),i(A,"content",JSON.stringify(cg)),i(O,"id","callbacks"),i(O,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(O,"href","#callbacks"),i(D,"class","relative group"),i(fr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(mr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerControl"),i(hr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(pr,"href","trainer"),i(gr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(_r,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.DefaultFlowCallback"),i(br,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.PrinterCallback"),i(vr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.ProgressCallback"),i(Er,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.TrainingArguments"),i(Tr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.integrations.TensorBoardCallback"),i($r,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.integrations.WandbCallback"),i(tt,"href","https://www.wandb.com/"),i(tt,"rel","nofollow"),i(Cr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.integrations.CometCallback"),i(rt,"href","https://www.comet.ml/site/"),i(rt,"rel","nofollow"),i(wr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.integrations.MLflowCallback"),i(at,"href","https://www.mlflow.org/"),i(at,"rel","nofollow"),i(yr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.integrations.AzureMLCallback"),i(nt,"href","https://pypi.org/project/azureml-sdk/"),i(nt,"rel","nofollow"),i(Ar,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.integrations.CodeCarbonCallback"),i(ot,"href","https://pypi.org/project/codecarbon/"),i(ot,"rel","nofollow"),i(Lr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(Dr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.TrainingArguments"),i(Or,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(xr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerState"),i(Mr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerControl"),i(Ae,"id","transformers.integrations.CometCallback"),i(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Ae,"href","#transformers.integrations.CometCallback"),i(ne,"class","relative group"),i(Sr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(Ir,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(it,"href","https://www.comet.ml/site/"),i(it,"rel","nofollow"),i(ft,"href","https://www.comet.ml/docs/python-sdk/advanced/#comet-configuration-variables"),i(ft,"rel","nofollow"),i(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Pr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Fr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Wr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Nr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(jr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.TrainingArguments"),i(zr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerState"),i(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Br,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(kt,"href","https://www.tensorflow.org/tensorboard"),i(kt,"rel","nofollow"),i(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Rr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i($t,"href","https://www.wandb.com/"),i($t,"rel","nofollow"),i(At,"href","https://docs.wandb.ai/integrations/huggingface"),i(At,"rel","nofollow"),i(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Vr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(Dt,"href","https://www.mlflow.org/"),i(Dt,"rel","nofollow"),i(Ur,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.TrainingArguments"),i(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(qr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(Mt,"href","https://pypi.org/project/azureml-sdk/"),i(Mt,"rel","nofollow"),i(me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Gr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(De,"id","transformers.TrainerCallback"),i(De,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(De,"href","#transformers.TrainerCallback"),i(ge,"class","relative group"),i(xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Hr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(Ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(We,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(je,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ze,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Jr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(qe,"id","transformers.TrainerState"),i(qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(qe,"href","#transformers.TrainerState"),i(ue,"class","relative group"),i(Yr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(Xr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(He,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Je,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Ye,"id","transformers.TrainerControl"),i(Ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Ye,"href","#transformers.TrainerControl"),i(be,"class","relative group"),i(Kr,"href","/docs/transformers/pr_17548/en/main_classes/trainer#transformers.Trainer"),i(Qr,"href","/docs/transformers/pr_17548/en/main_classes/callback#transformers.TrainerCallback"),i(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(n,f){e(document.head,A),m(n,z,f),m(n,D,f),e(D,O),e(O,W),v(y,W,null),e(D,N),e(D,re),e(re,ae),m(n,j,f),m(n,G,f),e(G,dr),e(G,fr),e(fr,ss),e(G,ls),m(n,Un,f),m(n,B,f),e(B,is),e(B,mr),e(mr,cs),e(B,ds),e(B,hr),e(hr,fs),e(B,ms),e(B,pr),e(pr,hs),e(B,ps),m(n,qn,f),m(n,ke,f),e(ke,gs),e(ke,gr),e(gr,us),e(ke,_s),m(n,Gn,f),m(n,x,f),e(x,ur),e(ur,_r),e(_r,bs),e(ur,vs),e(x,Es),e(x,Z),e(Z,br),e(br,ks),e(Z,Ts),e(Z,vr),e(vr,$s),e(Z,Cs),e(Z,Er),e(Er,ws),e(Z,ys),e(x,As),e(x,kr),e(kr,Tr),e(Tr,Ls),e(kr,Ds),e(x,Os),e(x,Te),e(Te,$r),e($r,xs),e(Te,Ms),e(Te,tt),e(tt,Ss),e(Te,Is),e(x,Ps),e(x,$e),e($e,Cr),e(Cr,Fs),e($e,Ws),e($e,rt),e(rt,Ns),e($e,js),e(x,zs),e(x,Ce),e(Ce,wr),e(wr,Bs),e(Ce,Rs),e(Ce,at),e(at,Vs),e(Ce,Us),e(x,qs),e(x,we),e(we,yr),e(yr,Gs),e(we,Hs),e(we,nt),e(nt,Js),e(we,Ys),e(x,Xs),e(x,ye),e(ye,Ar),e(Ar,Ks),e(ye,Qs),e(ye,ot),e(ot,Zs),e(ye,el),m(n,Hn,f),m(n,S,f),e(S,tl),e(S,Lr),e(Lr,rl),e(S,al),e(S,Dr),e(Dr,nl),e(S,ol),e(S,Or),e(Or,sl),e(S,ll),e(S,xr),e(xr,il),e(S,cl),e(S,Mr),e(Mr,dl),e(S,fl),m(n,Jn,f),m(n,ne,f),e(ne,Ae),e(Ae,da),v(st,da,null),e(ne,ml),e(ne,fa),e(fa,hl),m(n,Yn,f),m(n,Le,f),e(Le,pl),e(Le,Sr),e(Sr,gl),e(Le,ul),m(n,Xn,f),m(n,H,f),v(lt,H,null),e(H,_l),e(H,oe),e(oe,bl),e(oe,Ir),e(Ir,vl),e(oe,El),e(oe,it),e(it,kl),e(oe,Tl),e(H,$l),e(H,R),v(ct,R,null),e(R,Cl),e(R,ma),e(ma,wl),e(R,yl),e(R,L),e(L,Al),e(L,ha),e(ha,Ll),e(L,Dl),e(L,pa),e(pa,Ol),e(L,xl),e(L,ga),e(ga,Ml),e(L,Sl),e(L,ua),e(ua,Il),e(L,Pl),e(L,_a),e(_a,Fl),e(L,Wl),e(L,ba),e(ba,Nl),e(L,jl),e(L,va),e(va,zl),e(L,Bl),e(L,Ea),e(Ea,Rl),e(L,Vl),e(L,ka),e(ka,Ul),e(L,ql),e(R,Gl),e(R,dt),e(dt,Hl),e(dt,ft),e(ft,Jl),e(dt,Yl),m(n,Kn,f),m(n,se,f),v(mt,se,null),e(se,Xl),e(se,ht),e(ht,Kl),e(ht,Pr),e(Pr,Ql),e(ht,Zl),m(n,Qn,f),m(n,le,f),v(pt,le,null),e(le,ei),e(le,gt),e(gt,ti),e(gt,Fr),e(Fr,ri),e(gt,ai),m(n,Zn,f),m(n,ie,f),v(ut,ie,null),e(ie,ni),e(ie,_t),e(_t,oi),e(_t,Wr),e(Wr,si),e(_t,li),m(n,eo,f),m(n,J,f),v(bt,J,null),e(J,ii),e(J,vt),e(vt,ci),e(vt,Nr),e(Nr,di),e(vt,fi),e(J,mi),e(J,Y),e(Y,hi),e(Y,jr),e(jr,pi),e(Y,gi),e(Y,Ta),e(Ta,ui),e(Y,_i),e(Y,zr),e(zr,bi),e(Y,vi),m(n,to,f),m(n,ce,f),v(Et,ce,null),e(ce,Ei),e(ce,de),e(de,ki),e(de,Br),e(Br,Ti),e(de,$i),e(de,kt),e(kt,Ci),e(de,wi),m(n,ro,f),m(n,X,f),v(Tt,X,null),e(X,yi),e(X,fe),e(fe,Ai),e(fe,Rr),e(Rr,Li),e(fe,Di),e(fe,$t),e($t,Oi),e(fe,xi),e(X,Mi),e(X,V),v(Ct,V,null),e(V,Si),e(V,wt),e(wt,Ii),e(wt,$a),e($a,Pi),e(wt,Fi),e(V,Wi),e(V,yt),e(yt,Ni),e(yt,At),e(At,ji),e(yt,zi),e(V,Bi),e(V,h),e(h,Ri),e(h,Ca),e(Ca,Vi),e(h,Ui),e(h,wa),e(wa,qi),e(h,Gi),e(h,ya),e(ya,Hi),e(h,Ji),e(h,Aa),e(Aa,Yi),e(h,Xi),e(h,La),e(La,Ki),e(h,Qi),e(h,Da),e(Da,Zi),e(h,ec),e(h,Oa),e(Oa,tc),e(h,rc),e(h,xa),e(xa,ac),e(h,nc),e(h,Ma),e(Ma,oc),e(h,sc),e(h,Sa),e(Sa,lc),e(h,ic),e(h,Ia),e(Ia,cc),e(h,dc),e(h,Pa),e(Pa,fc),e(h,mc),e(h,Fa),e(Fa,hc),e(h,pc),e(h,Wa),e(Wa,gc),e(h,uc),e(h,Na),e(Na,_c),e(h,bc),e(h,ja),e(ja,vc),e(h,Ec),e(h,za),e(za,kc),e(h,Tc),e(h,Ba),e(Ba,$c),e(h,Cc),e(h,Ra),e(Ra,wc),e(h,yc),m(n,ao,f),m(n,K,f),v(Lt,K,null),e(K,Ac),e(K,Q),e(Q,Lc),e(Q,Vr),e(Vr,Dc),e(Q,Oc),e(Q,Dt),e(Dt,xc),e(Q,Mc),e(Q,Va),e(Va,Sc),e(Q,Ic),e(K,Pc),e(K,ee),v(Ot,ee,null),e(ee,Fc),e(ee,Ua),e(Ua,Wc),e(ee,Nc),e(ee,p),e(p,jc),e(p,qa),e(qa,zc),e(p,Bc),e(p,Ga),e(Ga,Rc),e(p,Vc),e(p,Ha),e(Ha,Uc),e(p,qc),e(p,Ja),e(Ja,Gc),e(p,Hc),e(p,Ur),e(Ur,Jc),e(p,Yc),e(p,Ya),e(Ya,Xc),e(p,Kc),e(p,Xa),e(Xa,Qc),e(p,Zc),e(p,Ka),e(Ka,ed),e(p,td),e(p,Qa),e(Qa,rd),e(p,ad),e(p,Za),e(Za,nd),e(p,od),e(p,en),e(en,sd),e(p,ld),e(p,tn),e(tn,id),e(p,cd),e(p,rn),e(rn,dd),e(p,fd),e(p,an),e(an,md),e(p,hd),e(p,nn),e(nn,pd),e(p,gd),e(p,on),e(on,ud),e(p,_d),e(p,sn),e(sn,bd),e(p,vd),e(p,ln),e(ln,Ed),e(p,kd),e(p,cn),e(cn,Td),e(p,$d),m(n,no,f),m(n,me,f),v(xt,me,null),e(me,Cd),e(me,he),e(he,wd),e(he,qr),e(qr,yd),e(he,Ad),e(he,Mt),e(Mt,Ld),e(he,Dd),m(n,oo,f),m(n,pe,f),v(St,pe,null),e(pe,Od),e(pe,It),e(It,xd),e(It,Gr),e(Gr,Md),e(It,Sd),m(n,so,f),m(n,ge,f),e(ge,De),e(De,dn),v(Pt,dn,null),e(ge,Id),e(ge,fn),e(fn,Pd),m(n,lo,f),m(n,$,f),v(Ft,$,null),e($,Fd),e($,mn),e(mn,Wd),e($,Nd),e($,Wt),e(Wt,jd),e(Wt,hn),e(hn,zd),e(Wt,Bd),e($,Rd),e($,P),e(P,Vd),e(P,pn),e(pn,Ud),e(P,qd),e(P,gn),e(gn,Gd),e(P,Hd),e(P,un),e(un,Jd),e(P,Yd),e(P,_n),e(_n,Xd),e(P,Kd),e(P,bn),e(bn,Qd),e(P,Zd),e($,ef),v(Oe,$,null),e($,tf),e($,xe),v(Nt,xe,null),e(xe,rf),e(xe,vn),e(vn,af),e($,nf),e($,Me),v(jt,Me,null),e(Me,of),e(Me,En),e(En,sf),e($,lf),e($,Se),v(zt,Se,null),e(Se,cf),e(Se,kn),e(kn,df),e($,ff),e($,Ie),v(Bt,Ie,null),e(Ie,mf),e(Ie,Rt),e(Rt,hf),e(Rt,Hr),e(Hr,pf),e(Rt,gf),e($,uf),e($,Pe),v(Vt,Pe,null),e(Pe,_f),e(Pe,Tn),e(Tn,bf),e($,vf),e($,Fe),v(Ut,Fe,null),e(Fe,Ef),e(Fe,$n),e($n,kf),e($,Tf),e($,We),v(qt,We,null),e(We,$f),e(We,Cn),e(Cn,Cf),e($,wf),e($,Ne),v(Gt,Ne,null),e(Ne,yf),e(Ne,wn),e(wn,Af),e($,Lf),e($,je),v(Ht,je,null),e(je,Df),e(je,yn),e(yn,Of),e($,xf),e($,ze),v(Jt,ze,null),e(ze,Mf),e(ze,An),e(An,Sf),e($,If),e($,Be),v(Yt,Be,null),e(Be,Pf),e(Be,Ln),e(Ln,Ff),e($,Wf),e($,Re),v(Xt,Re,null),e(Re,Nf),e(Re,Dn),e(Dn,jf),m(n,io,f),m(n,Ve,f),e(Ve,zf),e(Ve,Jr),e(Jr,Bf),e(Ve,Rf),m(n,co,f),v(Kt,n,f),m(n,fo,f),m(n,Ue,f),e(Ue,Vf),e(Ue,On),e(On,Uf),e(Ue,qf),m(n,mo,f),v(Qt,n,f),m(n,ho,f),m(n,ue,f),e(ue,qe),e(qe,xn),v(Zt,xn,null),e(ue,Gf),e(ue,Mn),e(Mn,Hf),m(n,po,f),m(n,F,f),v(er,F,null),e(F,Jf),e(F,_e),e(_e,Yf),e(_e,Yr),e(Yr,Xf),e(_e,Kf),e(_e,Xr),e(Xr,Qf),e(_e,Zf),e(F,em),v(Ge,F,null),e(F,tm),e(F,He),v(tr,He,null),e(He,rm),e(He,rr),e(rr,am),e(rr,Sn),e(Sn,nm),e(rr,om),e(F,sm),e(F,Je),v(ar,Je,null),e(Je,lm),e(Je,nr),e(nr,im),e(nr,In),e(In,cm),e(nr,dm),m(n,go,f),m(n,be,f),e(be,Ye),e(Ye,Pn),v(or,Pn,null),e(be,fm),e(be,Fn),e(Fn,mm),m(n,uo,f),m(n,ve,f),v(sr,ve,null),e(ve,hm),e(ve,Ee),e(Ee,pm),e(Ee,Kr),e(Kr,gm),e(Ee,um),e(Ee,Qr),e(Qr,_m),e(Ee,bm),_o=!0},p(n,[f]){const lr={};f&2&&(lr.$$scope={dirty:f,ctx:n}),Oe.$set(lr);const Wn={};f&2&&(Wn.$$scope={dirty:f,ctx:n}),Ge.$set(Wn)},i(n){_o||(E(y.$$.fragment,n),E(st.$$.fragment,n),E(lt.$$.fragment,n),E(ct.$$.fragment,n),E(mt.$$.fragment,n),E(pt.$$.fragment,n),E(ut.$$.fragment,n),E(bt.$$.fragment,n),E(Et.$$.fragment,n),E(Tt.$$.fragment,n),E(Ct.$$.fragment,n),E(Lt.$$.fragment,n),E(Ot.$$.fragment,n),E(xt.$$.fragment,n),E(St.$$.fragment,n),E(Pt.$$.fragment,n),E(Ft.$$.fragment,n),E(Oe.$$.fragment,n),E(Nt.$$.fragment,n),E(jt.$$.fragment,n),E(zt.$$.fragment,n),E(Bt.$$.fragment,n),E(Vt.$$.fragment,n),E(Ut.$$.fragment,n),E(qt.$$.fragment,n),E(Gt.$$.fragment,n),E(Ht.$$.fragment,n),E(Jt.$$.fragment,n),E(Yt.$$.fragment,n),E(Xt.$$.fragment,n),E(Kt.$$.fragment,n),E(Qt.$$.fragment,n),E(Zt.$$.fragment,n),E(er.$$.fragment,n),E(Ge.$$.fragment,n),E(tr.$$.fragment,n),E(ar.$$.fragment,n),E(or.$$.fragment,n),E(sr.$$.fragment,n),_o=!0)},o(n){k(y.$$.fragment,n),k(st.$$.fragment,n),k(lt.$$.fragment,n),k(ct.$$.fragment,n),k(mt.$$.fragment,n),k(pt.$$.fragment,n),k(ut.$$.fragment,n),k(bt.$$.fragment,n),k(Et.$$.fragment,n),k(Tt.$$.fragment,n),k(Ct.$$.fragment,n),k(Lt.$$.fragment,n),k(Ot.$$.fragment,n),k(xt.$$.fragment,n),k(St.$$.fragment,n),k(Pt.$$.fragment,n),k(Ft.$$.fragment,n),k(Oe.$$.fragment,n),k(Nt.$$.fragment,n),k(jt.$$.fragment,n),k(zt.$$.fragment,n),k(Bt.$$.fragment,n),k(Vt.$$.fragment,n),k(Ut.$$.fragment,n),k(qt.$$.fragment,n),k(Gt.$$.fragment,n),k(Ht.$$.fragment,n),k(Jt.$$.fragment,n),k(Yt.$$.fragment,n),k(Xt.$$.fragment,n),k(Kt.$$.fragment,n),k(Qt.$$.fragment,n),k(Zt.$$.fragment,n),k(er.$$.fragment,n),k(Ge.$$.fragment,n),k(tr.$$.fragment,n),k(ar.$$.fragment,n),k(or.$$.fragment,n),k(sr.$$.fragment,n),_o=!1},d(n){t(A),n&&t(z),n&&t(D),T(y),n&&t(j),n&&t(G),n&&t(Un),n&&t(B),n&&t(qn),n&&t(ke),n&&t(Gn),n&&t(x),n&&t(Hn),n&&t(S),n&&t(Jn),n&&t(ne),T(st),n&&t(Yn),n&&t(Le),n&&t(Xn),n&&t(H),T(lt),T(ct),n&&t(Kn),n&&t(se),T(mt),n&&t(Qn),n&&t(le),T(pt),n&&t(Zn),n&&t(ie),T(ut),n&&t(eo),n&&t(J),T(bt),n&&t(to),n&&t(ce),T(Et),n&&t(ro),n&&t(X),T(Tt),T(Ct),n&&t(ao),n&&t(K),T(Lt),T(Ot),n&&t(no),n&&t(me),T(xt),n&&t(oo),n&&t(pe),T(St),n&&t(so),n&&t(ge),T(Pt),n&&t(lo),n&&t($),T(Ft),T(Oe),T(Nt),T(jt),T(zt),T(Bt),T(Vt),T(Ut),T(qt),T(Gt),T(Ht),T(Jt),T(Yt),T(Xt),n&&t(io),n&&t(Ve),n&&t(co),T(Kt,n),n&&t(fo),n&&t(Ue),n&&t(mo),T(Qt,n),n&&t(ho),n&&t(ue),T(Zt),n&&t(po),n&&t(F),T(er),T(Ge),T(tr),T(ar),n&&t(go),n&&t(be),T(or),n&&t(uo),n&&t(ve),T(sr)}}}const cg={local:"callbacks",sections:[{local:"transformers.integrations.CometCallback",title:"Available Callbacks"},{local:"transformers.TrainerCallback",title:"TrainerCallback"},{local:"transformers.TrainerState",title:"TrainerState"},{local:"transformers.TrainerControl",title:"TrainerControl"}],title:"Callbacks"};function dg(cr){return rg(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _g extends Qp{constructor(A){super();Zp(this,A,dg,ig,eg,{})}}export{_g as default,cg as metadata};
