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