import{S as Si,i as Fi,s as Ai,e as r,k as l,w as h,t as a,M as Oi,c as n,d as o,m as d,a as s,x as g,h as i,b as f,G as t,g as p,y as _,q as b,o as v,B as y,v as Ii,L as Ni}from"../../chunks/vendor-hf-doc-builder.js";import{T as rr}from"../../chunks/Tip-hf-doc-builder.js";import{D as k}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Hi}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Jt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Mi}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Vi(S){let m,x,u,$,q,w,D,O,P,Q,F,C,B,A,z,G,L;return{c(){m=r("p"),x=a("One of "),u=r("code"),$=a("start_states"),q=a(" or "),w=r("code"),D=a("start_positions"),O=a(" should be not "),P=r("code"),Q=a("None"),F=a(". If both are set, "),C=r("code"),B=a("start_positions"),A=a(` overrides
`),z=r("code"),G=a("start_states"),L=a(".")},l(E){m=n(E,"P",{});var T=s(m);x=i(T,"One of "),u=n(T,"CODE",{});var I=s(u);$=i(I,"start_states"),I.forEach(o),q=i(T," or "),w=n(T,"CODE",{});var ce=s(w);D=i(ce,"start_positions"),ce.forEach(o),O=i(T," should be not "),P=n(T,"CODE",{});var U=s(P);Q=i(U,"None"),U.forEach(o),F=i(T,". If both are set, "),C=n(T,"CODE",{});var me=s(C);B=i(me,"start_positions"),me.forEach(o),A=i(T,` overrides
`),z=n(T,"CODE",{});var ae=s(z);G=i(ae,"start_states"),ae.forEach(o),L=i(T,"."),T.forEach(o)},m(E,T){p(E,m,T),t(m,x),t(m,u),t(u,$),t(m,q),t(m,w),t(w,D),t(m,O),t(m,P),t(P,Q),t(m,F),t(m,C),t(C,B),t(m,A),t(m,z),t(z,G),t(m,L)},d(E){E&&o(m)}}}function ji(S){let m,x,u,$,q,w,D,O,P,Q,F,C,B,A,z,G,L;return{c(){m=r("p"),x=a("One of "),u=r("code"),$=a("start_states"),q=a(" or "),w=r("code"),D=a("start_positions"),O=a(" should be not "),P=r("code"),Q=a("None"),F=a(". If both are set, "),C=r("code"),B=a("start_positions"),A=a(` overrides
`),z=r("code"),G=a("start_states"),L=a(".")},l(E){m=n(E,"P",{});var T=s(m);x=i(T,"One of "),u=n(T,"CODE",{});var I=s(u);$=i(I,"start_states"),I.forEach(o),q=i(T," or "),w=n(T,"CODE",{});var ce=s(w);D=i(ce,"start_positions"),ce.forEach(o),O=i(T," should be not "),P=n(T,"CODE",{});var U=s(P);Q=i(U,"None"),U.forEach(o),F=i(T,". If both are set, "),C=n(T,"CODE",{});var me=s(C);B=i(me,"start_positions"),me.forEach(o),A=i(T,` overrides
`),z=n(T,"CODE",{});var ae=s(z);G=i(ae,"start_states"),ae.forEach(o),L=i(T,"."),T.forEach(o)},m(E,T){p(E,m,T),t(m,x),t(m,u),t(u,$),t(m,q),t(m,w),t(w,D),t(m,O),t(m,P),t(P,Q),t(m,F),t(m,C),t(C,B),t(m,A),t(m,z),t(z,G),t(m,L)},d(E){E&&o(m)}}}function Qi(S){let m,x,u,$,q;return $=new Hi({props:{code:`# rename the usual forward() fn to forward_chunk()
def forward_chunk(self, hidden_states):
    hidden_states = self.decoder(hidden_states)
    return hidden_states


# implement a chunked forward function
def forward(self, hidden_states):
    return apply_chunking_to_forward(self.forward_chunk, self.chunk_size_lm_head, self.seq_len_dim, hidden_states)`,highlighted:`<span class="hljs-comment"># rename the usual forward() fn to forward_chunk()</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">forward_chunk</span>(<span class="hljs-params">self, hidden_states</span>):
    hidden_states = self.decoder(hidden_states)
    <span class="hljs-keyword">return</span> hidden_states


<span class="hljs-comment"># implement a chunked forward function</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, hidden_states</span>):
    <span class="hljs-keyword">return</span> apply_chunking_to_forward(self.forward_chunk, self.chunk_size_lm_head, self.seq_len_dim, hidden_states)`}}),{c(){m=r("p"),x=a("Examples:"),u=l(),h($.$$.fragment)},l(w){m=n(w,"P",{});var D=s(m);x=i(D,"Examples:"),D.forEach(o),u=d(w),g($.$$.fragment,w)},m(w,D){p(w,m,D),t(m,x),p(w,u,D),_($,w,D),q=!0},p:Ni,i(w){q||(b($.$$.fragment,w),q=!0)},o(w){v($.$$.fragment,w),q=!1},d(w){w&&o(m),w&&o(u),y($,w)}}}function Bi(S){let m,x;return{c(){m=r("p"),x=a("Any label of -100 will be ignored (along with the corresponding logits) in the loss computation.")},l(u){m=n(u,"P",{});var $=s(m);x=i($,"Any label of -100 will be ignored (along with the corresponding logits) in the loss computation."),$.forEach(o)},m(u,$){p(u,m,$),t(m,x)},d(u){u&&o(m)}}}function Gi(S){let m,x;return{c(){m=r("p"),x=a("Any label of -100 will be ignored (along with the corresponding logits) in the loss computation.")},l(u){m=n(u,"P",{});var $=s(m);x=i($,"Any label of -100 will be ignored (along with the corresponding logits) in the loss computation."),$.forEach(o)},m(u,$){p(u,m,$),t(m,x)},d(u){u&&o(m)}}}function Ui(S){let m,x;return{c(){m=r("p"),x=a("Any label of -100 will be ignored (along with the corresponding logits) in the loss computation.")},l(u){m=n(u,"P",{});var $=s(m);x=i($,"Any label of -100 will be ignored (along with the corresponding logits) in the loss computation."),$.forEach(o)},m(u,$){p(u,m,$),t(m,x)},d(u){u&&o(m)}}}function Ki(S){let m,x,u,$,q,w,D,O,P,Q,F,C,B,A,z,G,L,E,T,I,ce,U,me,ae,K,Be,Yr,Yt,Zr,en,Zt,tn,nr,R,Ge,on,eo,rn,nn,Pt,Ue,sr,W,Ke,sn,to,an,ln,De,Re,dn,Le,ar,X,We,cn,oo,mn,pn,Pe,Xe,fn,Ce,ir,pe,Je,un,Ye,hn,Ct,gn,_n,lr,J,Ze,bn,ro,vn,yn,zt,et,dr,Y,tt,$n,no,wn,Tn,ze,ot,kn,so,xn,cr,fe,Se,ao,rt,En,io,qn,mr,N,nt,Dn,H,Ln,lo,Pn,Cn,co,zn,Sn,mo,Fn,An,po,On,In,Nn,M,Hn,fo,Mn,Vn,uo,jn,Qn,ho,Bn,Gn,go,Un,Kn,Rn,Fe,pr,ue,st,Wn,at,Xn,_o,Jn,Yn,fr,Z,it,Zn,bo,es,ts,vo,os,ur,ee,lt,rs,yo,ns,ss,$o,as,hr,te,dt,is,wo,ls,ds,To,cs,gr,he,Ae,ko,ct,ms,xo,ps,_r,oe,mt,fs,Eo,us,hs,qo,gs,br,V,pt,_s,Do,bs,vs,Lo,ys,$s,ie,ft,ws,Po,Ts,ks,ut,xs,ht,Es,qs,vr,ge,gt,Ds,Co,Ls,yr,_e,Oe,zo,_t,Ps,So,Cs,$r,re,bt,zs,Fo,Ss,Fs,Ie,wr,ne,vt,As,Ao,Os,Is,Ne,Tr,be,yt,Ns,Oo,Hs,kr,ve,$t,Ms,Io,Vs,xr,ye,wt,js,No,Qs,Er,se,Tt,Bs,Ho,Gs,Us,He,qr,$e,Me,Mo,kt,Ks,Vo,Rs,Dr,we,xt,Ws,Et,Xs,jo,Js,Ys,Lr,j,qt,Zs,Qo,ea,ta,Bo,oa,ra,Te,ke,na,Go,sa,aa,Uo,ia,la,da,xe,ca,Ko,ma,pa,Ro,fa,ua,ha,Ee,ga,Wo,_a,ba,Xo,va,ya,Pr,qe,Dt,$a,Jo,wa,Cr;return w=new Jt({}),I=new Jt({}),Be=new k({props:{name:"class transformers.Conv1D",anchor:"transformers.Conv1D",parameters:[{name:"nf",val:""},{name:"nx",val:""}],parametersDescription:[{anchor:"transformers.Conv1D.nf",description:"<strong>nf</strong> (<code>int</code>) &#x2014; The number of output features.",name:"nf"},{anchor:"transformers.Conv1D.nx",description:"<strong>nx</strong> (<code>int</code>) &#x2014; The number of input features.",name:"nx"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/pytorch_utils.py#L94"}}),Ge=new k({props:{name:"class transformers.modeling_utils.PoolerStartLogits",anchor:"transformers.modeling_utils.PoolerStartLogits",parameters:[{name:"config",val:": PretrainedConfig"}],parametersDescription:[{anchor:"transformers.modeling_utils.PoolerStartLogits.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>) &#x2014;
The config used by the model, will be used to grab the <code>hidden_size</code> of the model.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L2972"}}),Ue=new k({props:{name:"forward",anchor:"transformers.modeling_utils.PoolerStartLogits.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"p_mask",val:": typing.Optional[torch.FloatTensor] = None"}],parametersDescription:[{anchor:"transformers.modeling_utils.PoolerStartLogits.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len, hidden_size)</code>) &#x2014;
The final hidden states of the model.`,name:"hidden_states"},{anchor:"transformers.modeling_utils.PoolerStartLogits.forward.p_mask",description:`<strong>p_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len)</code>, <em>optional</em>) &#x2014;
Mask for tokens at invalid position, such as query and special symbols (PAD, SEP, CLS). 1.0 means token
should be masked.`,name:"p_mask"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L2985",returnDescription:`
<p>The start logits for SQuAD.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Ke=new k({props:{name:"class transformers.modeling_utils.PoolerEndLogits",anchor:"transformers.modeling_utils.PoolerEndLogits",parameters:[{name:"config",val:": PretrainedConfig"}],parametersDescription:[{anchor:"transformers.modeling_utils.PoolerEndLogits.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>) &#x2014;
The config used by the model, will be used to grab the <code>hidden_size</code> of the model and the <code>layer_norm_eps</code>
to use.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3010"}}),Re=new k({props:{name:"forward",anchor:"transformers.modeling_utils.PoolerEndLogits.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"start_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"p_mask",val:": typing.Optional[torch.FloatTensor] = None"}],parametersDescription:[{anchor:"transformers.modeling_utils.PoolerEndLogits.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len, hidden_size)</code>) &#x2014;
The final hidden states of the model.`,name:"hidden_states"},{anchor:"transformers.modeling_utils.PoolerEndLogits.forward.start_states",description:`<strong>start_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len, hidden_size)</code>, <em>optional</em>) &#x2014;
The hidden states of the first tokens for the labeled span.`,name:"start_states"},{anchor:"transformers.modeling_utils.PoolerEndLogits.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
The position of the first token for the labeled span.`,name:"start_positions"},{anchor:"transformers.modeling_utils.PoolerEndLogits.forward.p_mask",description:`<strong>p_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len)</code>, <em>optional</em>) &#x2014;
Mask for tokens at invalid position, such as query and special symbols (PAD, SEP, CLS). 1.0 means token
should be masked.`,name:"p_mask"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3027",returnDescription:`
<p>The end logits for SQuAD.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Le=new rr({props:{$$slots:{default:[Vi]},$$scope:{ctx:S}}}),We=new k({props:{name:"class transformers.modeling_utils.PoolerAnswerClass",anchor:"transformers.modeling_utils.PoolerAnswerClass",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.modeling_utils.PoolerAnswerClass.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>) &#x2014;
The config used by the model, will be used to grab the <code>hidden_size</code> of the model.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3079"}}),Xe=new k({props:{name:"forward",anchor:"transformers.modeling_utils.PoolerAnswerClass.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"start_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"cls_index",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.modeling_utils.PoolerAnswerClass.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len, hidden_size)</code>) &#x2014;
The final hidden states of the model.`,name:"hidden_states"},{anchor:"transformers.modeling_utils.PoolerAnswerClass.forward.start_states",description:`<strong>start_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len, hidden_size)</code>, <em>optional</em>) &#x2014;
The hidden states of the first tokens for the labeled span.`,name:"start_states"},{anchor:"transformers.modeling_utils.PoolerAnswerClass.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
The position of the first token for the labeled span.`,name:"start_positions"},{anchor:"transformers.modeling_utils.PoolerAnswerClass.forward.cls_index",description:`<strong>cls_index</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Position of the CLS token for each sentence in the batch. If <code>None</code>, takes the last token.`,name:"cls_index"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3094",returnDescription:`
<p>The SQuAD 2.0 answer class.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Ce=new rr({props:{$$slots:{default:[ji]},$$scope:{ctx:S}}}),Je=new k({props:{name:"class transformers.modeling_utils.SquadHeadOutput",anchor:"transformers.modeling_utils.SquadHeadOutput",parameters:[{name:"loss",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_top_log_probs",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_top_index",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_top_log_probs",val:": typing.Optional[torch.FloatTensor] = None"},{name:"end_top_index",val:": typing.Optional[torch.LongTensor] = None"},{name:"cls_logits",val:": typing.Optional[torch.FloatTensor] = None"}],parametersDescription:[{anchor:"transformers.modeling_utils.SquadHeadOutput.loss",description:`<strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned if both <code>start_positions</code> and <code>end_positions</code> are provided) &#x2014;
Classification loss as the sum of start token, end token (and is_impossible if provided) classification
losses.`,name:"loss"},{anchor:"transformers.modeling_utils.SquadHeadOutput.start_top_log_probs",description:`<strong>start_top_log_probs</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.start_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) &#x2014;
Log probabilities for the top config.start_n_top start token possibilities (beam-search).`,name:"start_top_log_probs"},{anchor:"transformers.modeling_utils.SquadHeadOutput.start_top_index",description:`<strong>start_top_index</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.start_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) &#x2014;
Indices for the top config.start_n_top start token possibilities (beam-search).`,name:"start_top_index"},{anchor:"transformers.modeling_utils.SquadHeadOutput.end_top_log_probs",description:`<strong>end_top_log_probs</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.start_n_top * config.end_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) &#x2014;
Log probabilities for the top <code>config.start_n_top * config.end_n_top</code> end token possibilities
(beam-search).`,name:"end_top_log_probs"},{anchor:"transformers.modeling_utils.SquadHeadOutput.end_top_index",description:`<strong>end_top_index</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.start_n_top * config.end_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) &#x2014;
Indices for the top <code>config.start_n_top * config.end_n_top</code> end token possibilities (beam-search).`,name:"end_top_index"},{anchor:"transformers.modeling_utils.SquadHeadOutput.cls_logits",description:`<strong>cls_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) &#x2014;
Log probabilities for the <code>is_impossible</code> label of the answers.`,name:"cls_logits"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3145"}}),Ze=new k({props:{name:"class transformers.modeling_utils.SQuADHead",anchor:"transformers.modeling_utils.SQuADHead",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.modeling_utils.SQuADHead.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>) &#x2014;
The config used by the model, will be used to grab the <code>hidden_size</code> of the model and the <code>layer_norm_eps</code>
to use.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3175"}}),et=new k({props:{name:"forward",anchor:"transformers.modeling_utils.SQuADHead.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"cls_index",val:": typing.Optional[torch.LongTensor] = None"},{name:"is_impossible",val:": typing.Optional[torch.LongTensor] = None"},{name:"p_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"return_dict",val:": bool = False"}],parametersDescription:[{anchor:"transformers.modeling_utils.SQuADHead.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len, hidden_size)</code>) &#x2014;
Final hidden states of the model on the sequence tokens.`,name:"hidden_states"},{anchor:"transformers.modeling_utils.SQuADHead.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Positions of the first token for the labeled span.`,name:"start_positions"},{anchor:"transformers.modeling_utils.SQuADHead.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Positions of the last token for the labeled span.`,name:"end_positions"},{anchor:"transformers.modeling_utils.SQuADHead.forward.cls_index",description:`<strong>cls_index</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Position of the CLS token for each sentence in the batch. If <code>None</code>, takes the last token.`,name:"cls_index"},{anchor:"transformers.modeling_utils.SQuADHead.forward.is_impossible",description:`<strong>is_impossible</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Whether the question has a possible answer in the paragraph or not.`,name:"is_impossible"},{anchor:"transformers.modeling_utils.SQuADHead.forward.p_mask",description:`<strong>p_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_len)</code>, <em>optional</em>) &#x2014;
Mask for tokens at invalid position, such as query and special symbols (PAD, SEP, CLS). 1.0 means token
should be masked.`,name:"p_mask"},{anchor:"transformers.modeling_utils.SQuADHead.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3194",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/internal/modeling_utils#transformers.modeling_utils.SquadHeadOutput"
>transformers.modeling_utils.SquadHeadOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<code>&lt;class 'transformers.configuration_utils.PretrainedConfig'&gt;</code>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned if both <code>start_positions</code> and <code>end_positions</code> are provided) \u2014 Classification loss as the sum of start token, end token (and is_impossible if provided) classification
losses.</li>
<li><strong>start_top_log_probs</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.start_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) \u2014 Log probabilities for the top config.start_n_top start token possibilities (beam-search).</li>
<li><strong>start_top_index</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.start_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) \u2014 Indices for the top config.start_n_top start token possibilities (beam-search).</li>
<li><strong>end_top_log_probs</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.start_n_top * config.end_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) \u2014 Log probabilities for the top <code>config.start_n_top * config.end_n_top</code> end token possibilities
(beam-search).</li>
<li><strong>end_top_index</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, config.start_n_top * config.end_n_top)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) \u2014 Indices for the top <code>config.start_n_top * config.end_n_top</code> end token possibilities (beam-search).</li>
<li><strong>cls_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>, returned if <code>start_positions</code> or <code>end_positions</code> is not provided) \u2014 Log probabilities for the <code>is_impossible</code> label of the answers.</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/internal/modeling_utils#transformers.modeling_utils.SquadHeadOutput"
>transformers.modeling_utils.SquadHeadOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),tt=new k({props:{name:"class transformers.modeling_utils.SequenceSummary",anchor:"transformers.modeling_utils.SequenceSummary",parameters:[{name:"config",val:": PretrainedConfig"}],parametersDescription:[{anchor:"transformers.modeling_utils.SequenceSummary.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>) &#x2014;
The config used by the model. Relevant arguments in the config class of the model are (refer to the actual
config class of your model for the default values it uses):</p>
<ul>
<li>
<p><strong>summary_type</strong> (<code>str</code>) &#x2014; The method to use to make this summary. Accepted values are:</p>
<ul>
<li><code>&quot;last&quot;</code> &#x2014; Take the last token hidden state (like XLNet)</li>
<li><code>&quot;first&quot;</code> &#x2014; Take the first token hidden state (like Bert)</li>
<li><code>&quot;mean&quot;</code> &#x2014; Take the mean of all tokens hidden states</li>
<li><code>&quot;cls_index&quot;</code> &#x2014; Supply a Tensor of classification token position (GPT/GPT-2)</li>
<li><code>&quot;attn&quot;</code> &#x2014; Not implemented now, use multi-head attention</li>
</ul>
</li>
<li>
<p><strong>summary_use_proj</strong> (<code>bool</code>) &#x2014; Add a projection after the vector extraction.</p>
</li>
<li>
<p><strong>summary_proj_to_labels</strong> (<code>bool</code>) &#x2014; If <code>True</code>, the projection outputs to <code>config.num_labels</code> classes
(otherwise to <code>config.hidden_size</code>).</p>
</li>
<li>
<p><strong>summary_activation</strong> (<code>Optional[str]</code>) &#x2014; Set to <code>&quot;tanh&quot;</code> to add a tanh activation to the output,
another string or <code>None</code> will add no activation.</p>
</li>
<li>
<p><strong>summary_first_dropout</strong> (<code>float</code>) &#x2014; Optional dropout probability before the projection and activation.</p>
</li>
<li>
<p><strong>summary_last_dropout</strong> (<code>float</code>)&#x2014; Optional dropout probability after the projection and activation.</p>
</li>
</ul>`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3292"}}),ot=new k({props:{name:"forward",anchor:"transformers.modeling_utils.SequenceSummary.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"cls_index",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.modeling_utils.SequenceSummary.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>[batch_size, seq_len, hidden_size]</code>) &#x2014;
The hidden states of the last layer.`,name:"hidden_states"},{anchor:"transformers.modeling_utils.SequenceSummary.forward.cls_index",description:`<strong>cls_index</strong> (<code>torch.LongTensor</code> of shape <code>[batch_size]</code> or <code>[batch_size, ...]</code> where &#x2026; are optional leading dimensions of <code>hidden_states</code>, <em>optional</em>) &#x2014;
Used if <code>summary_type == &quot;cls_index&quot;</code> and takes the last token of the sequence as classification token.`,name:"cls_index"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3347",returnDescription:`
<p>The summary of the sequence hidden states.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),rt=new Jt({}),nt=new k({props:{name:"transformers.apply_chunking_to_forward",anchor:"transformers.apply_chunking_to_forward",parameters:[{name:"forward_fn",val:": typing.Callable[..., torch.Tensor]"},{name:"chunk_size",val:": int"},{name:"chunk_dim",val:": int"},{name:"*input_tensors",val:""}],parametersDescription:[{anchor:"transformers.apply_chunking_to_forward.forward_fn",description:`<strong>forward_fn</strong> (<code>Callable[..., torch.Tensor]</code>) &#x2014;
The forward function of the model.`,name:"forward_fn"},{anchor:"transformers.apply_chunking_to_forward.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>) &#x2014;
The chunk size of a chunked tensor: <code>num_chunks = len(input_tensors[0]) / chunk_size</code>.`,name:"chunk_size"},{anchor:"transformers.apply_chunking_to_forward.chunk_dim",description:`<strong>chunk_dim</strong> (<code>int</code>) &#x2014;
The dimension over which the <code>input_tensors</code> should be chunked.`,name:"chunk_dim"},{anchor:"transformers.apply_chunking_to_forward.input_tensors",description:`<strong>input_tensors</strong> (<code>Tuple[torch.Tensor]</code>) &#x2014;
The input tensors of <code>forward_fn</code> which will be chunked`,name:"input_tensors"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/pytorch_utils.py#L177",returnDescription:`
<p>A tensor with the same shape as the <code>forward_fn</code> would have given if applied\`.</p>
`,returnType:`
<p><code>torch.Tensor</code></p>
`}}),Fe=new Mi({props:{anchor:"transformers.apply_chunking_to_forward.example",$$slots:{default:[Qi]},$$scope:{ctx:S}}}),st=new k({props:{name:"transformers.pytorch_utils.find_pruneable_heads_and_indices",anchor:"transformers.pytorch_utils.find_pruneable_heads_and_indices",parameters:[{name:"heads",val:": typing.List[int]"},{name:"n_heads",val:": int"},{name:"head_size",val:": int"},{name:"already_pruned_heads",val:": typing.Set[int]"}],parametersDescription:[{anchor:"transformers.pytorch_utils.find_pruneable_heads_and_indices.heads",description:"<strong>heads</strong> (<code>List[int]</code>) &#x2014; List of the indices of heads to prune.",name:"heads"},{anchor:"transformers.pytorch_utils.find_pruneable_heads_and_indices.n_heads",description:"<strong>n_heads</strong> (<code>int</code>) &#x2014; The number of heads in the model.",name:"n_heads"},{anchor:"transformers.pytorch_utils.find_pruneable_heads_and_indices.head_size",description:"<strong>head_size</strong> (<code>int</code>) &#x2014; The size of each head.",name:"head_size"},{anchor:"transformers.pytorch_utils.find_pruneable_heads_and_indices.already_pruned_heads",description:"<strong>already_pruned_heads</strong> (<code>Set[int]</code>) &#x2014; A set of already pruned heads.",name:"already_pruned_heads"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/pytorch_utils.py#L252",returnDescription:`
<p>A tuple with the remaining heads and their corresponding indices.</p>
`,returnType:`
<p><code>Tuple[Set[int], torch.LongTensor]</code></p>
`}}),it=new k({props:{name:"transformers.prune_layer",anchor:"transformers.prune_layer",parameters:[{name:"layer",val:": typing.Union[torch.nn.modules.linear.Linear, transformers.pytorch_utils.Conv1D]"},{name:"index",val:": LongTensor"},{name:"dim",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"transformers.prune_layer.layer",description:"<strong>layer</strong> (<code>Union[torch.nn.Linear, Conv1D]</code>) &#x2014; The layer to prune.",name:"layer"},{anchor:"transformers.prune_layer.index",description:"<strong>index</strong> (<code>torch.LongTensor</code>) &#x2014; The indices to keep in the layer.",name:"index"},{anchor:"transformers.prune_layer.dim",description:"<strong>dim</strong> (<code>int</code>, <em>optional</em>) &#x2014; The dimension on which to keep the indices.",name:"dim"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/pytorch_utils.py#L153",returnDescription:`
<p>The pruned layer as a new layer with <code>requires_grad=True</code>.</p>
`,returnType:`
<p><code>torch.nn.Linear</code> or <a
  href="/docs/transformers/main/en/internal/modeling_utils#transformers.Conv1D"
>Conv1D</a></p>
`}}),lt=new k({props:{name:"transformers.pytorch_utils.prune_conv1d_layer",anchor:"transformers.pytorch_utils.prune_conv1d_layer",parameters:[{name:"layer",val:": Conv1D"},{name:"index",val:": LongTensor"},{name:"dim",val:": int = 1"}],parametersDescription:[{anchor:"transformers.pytorch_utils.prune_conv1d_layer.layer",description:'<strong>layer</strong> (<a href="/docs/transformers/main/en/internal/modeling_utils#transformers.Conv1D">Conv1D</a>) &#x2014; The layer to prune.',name:"layer"},{anchor:"transformers.pytorch_utils.prune_conv1d_layer.index",description:"<strong>index</strong> (<code>torch.LongTensor</code>) &#x2014; The indices to keep in the layer.",name:"index"},{anchor:"transformers.pytorch_utils.prune_conv1d_layer.dim",description:"<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014; The dimension on which to keep the indices.",name:"dim"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/pytorch_utils.py#L120",returnDescription:`
<p>The pruned layer as a new layer with <code>requires_grad=True</code>.</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/internal/modeling_utils#transformers.Conv1D"
>Conv1D</a></p>
`}}),dt=new k({props:{name:"transformers.pytorch_utils.prune_linear_layer",anchor:"transformers.pytorch_utils.prune_linear_layer",parameters:[{name:"layer",val:": Linear"},{name:"index",val:": LongTensor"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"transformers.pytorch_utils.prune_linear_layer.layer",description:"<strong>layer</strong> (<code>torch.nn.Linear</code>) &#x2014; The layer to prune.",name:"layer"},{anchor:"transformers.pytorch_utils.prune_linear_layer.index",description:"<strong>index</strong> (<code>torch.LongTensor</code>) &#x2014; The indices to keep in the layer.",name:"index"},{anchor:"transformers.pytorch_utils.prune_linear_layer.dim",description:"<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014; The dimension on which to keep the indices.",name:"dim"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/pytorch_utils.py#L60",returnDescription:`
<p>The pruned layer as a new layer with <code>requires_grad=True</code>.</p>
`,returnType:`
<p><code>torch.nn.Linear</code></p>
`}}),ct=new Jt({}),mt=new k({props:{name:"class transformers.modeling_tf_utils.TFConv1D",anchor:"transformers.modeling_tf_utils.TFConv1D",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.modeling_tf_utils.TFConv1D.nf",description:`<strong>nf</strong> (<code>int</code>) &#x2014;
The number of output features.`,name:"nf"},{anchor:"transformers.modeling_tf_utils.TFConv1D.nx",description:`<strong>nx</strong> (<code>int</code>) &#x2014;
The number of input features.`,name:"nx"},{anchor:"transformers.modeling_tf_utils.TFConv1D.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation to use to initialize the weights.
kwargs &#x2014;
Additional keyword arguments passed along to the <code>__init__</code> of <code>tf.keras.layers.Layer</code>.`,name:"initializer_range"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L3005"}}),pt=new k({props:{name:"class transformers.TFSharedEmbeddings",anchor:"transformers.TFSharedEmbeddings",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFSharedEmbeddings.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>) &#x2014;
The size of the vocabulary, e.g., the number of unique tokens.`,name:"vocab_size"},{anchor:"transformers.TFSharedEmbeddings.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>) &#x2014;
The size of the embedding vectors.`,name:"hidden_size"},{anchor:"transformers.TFSharedEmbeddings.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The standard deviation to use when initializing the weights. If no value is provided, it will default to
{@html &quot;<span class="\\&quot;katex\\&quot;"><span class="\\&quot;katex-mathml\\&quot;"><math xmlns="\\&quot;http://www.w3.org/1998/Math/MathML\\&quot;"><semantics><mrow><mn>1</mn><mi mathvariant="\\&quot;normal\\&quot;">/</mi><msqrt><mrow><mi>h</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>e</mi><mi>n</mi><mi mathvariant="\\&quot;normal\\&quot;">_</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mrow></msqrt></mrow><annotation encoding="\\&quot;application/x-tex\\&quot;">1/\\\\sqrt{hidden\\\\_size}</annotation></semantics></math></span><span class="\\&quot;katex-html\\&quot;" aria-hidden="\\&quot;true\\&quot;"><span class="\\&quot;base\\&quot;"><span class="\\&quot;strut\\&quot;" style="\\&quot;height:1.24em;vertical-align:-0.3628em;\\&quot;"></span><span class="\\&quot;mord\\&quot;">1/</span><span class="\\&quot;mord" sqrt\\"><span class="\\&quot;vlist-t" vlist-t2\\"><span class="\\&quot;vlist-r\\&quot;"><span class="\\&quot;vlist\\&quot;" style="\\&quot;height:0.8772em;\\&quot;"><span class="\\&quot;svg-align\\&quot;" style="\\&quot;top:-3.2em;\\&quot;"><span class="\\&quot;pstrut\\&quot;" style="\\&quot;height:3.2em;\\&quot;"></span><span class="\\&quot;mord\\&quot;" style="\\&quot;padding-left:1em;\\&quot;"><span class="\\&quot;mord" mathnormal\\">hi</span><span class="\\&quot;mord" mathnormal\\">dd</span><span class="\\&quot;mord" mathnormal\\">e</span><span class="\\&quot;mord" mathnormal\\">n</span><span class="\\&quot;mord\\&quot;" style="\\&quot;margin-right:0.02778em;\\&quot;">_</span><span class="\\&quot;mord" mathnormal\\">s</span><span class="\\&quot;mord" mathnormal\\">i</span><span class="\\&quot;mord" mathnormal\\">ze</span></span></span><span style="\\&quot;top:-2.8372em;\\&quot;"><span class="\\&quot;pstrut\\&quot;" style="\\&quot;height:3.2em;\\&quot;"></span><span class="\\&quot;hide-tail\\&quot;" style="\\&quot;min-width:1.02em;height:1.28em;\\&quot;"><svg xmlns="\\&quot;http://www.w3.org/2000/svg\\&quot;" width="400em" height="1.28em" viewBox="0 0 400000 1296" preserveAspectRatio="xMinYMin slice"><path d="M263,681c0.7,0,18,39.7,52,119\\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\\nc340,-704.7,510.7,-1060.3,512,-1067\\nl0 -0\\nc4.7,-7.3,11,-11,19,-11\\nH40000v40H1012.3\\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\\nM1001 80h400000v40h-400000z"/></svg></span></span></span><span class="\\&quot;vlist-s\\&quot;">&#x200B;</span></span><span class="\\&quot;vlist-r\\&quot;"><span class="\\&quot;vlist\\&quot;" style="\\&quot;height:0.3628em;\\&quot;"><span></span></span></span></span></span></span></span></span>&quot;}.
kwargs &#x2014;
Additional keyword arguments passed along to the <code>__init__</code> of <code>tf.keras.layers.Layer</code>.`,name:"initializer_range"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L3045"}}),ft=new k({props:{name:"call",anchor:"transformers.TFSharedEmbeddings.call",parameters:[{name:"inputs",val:": Tensor"},{name:"mode",val:": str = 'embedding'"}],parametersDescription:[{anchor:"transformers.TFSharedEmbeddings.call.inputs",description:`<strong>inputs</strong> (<code>tf.Tensor</code>) &#x2014;
In embedding mode, should be an int64 tensor with shape <code>[batch_size, length]</code>.</p>
<p>In linear mode, should be a float tensor with shape <code>[batch_size, length, hidden_size]</code>.`,name:"inputs"},{anchor:"transformers.TFSharedEmbeddings.call.mode",description:`<strong>mode</strong> (<code>str</code>, defaults to <code>&quot;embedding&quot;</code>) &#x2014;
A valid value is either <code>&quot;embedding&quot;</code> or <code>&quot;linear&quot;</code>, the first one indicates that the layer should be
used as an embedding layer, the second one that the layer should be used as a linear decoder.`,name:"mode"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L3091",returnDescription:`
<p>In embedding mode, the output is a float32 embedding tensor, with shape <code>[batch_size, length, embedding_size]</code>.</p>
<p>In linear mode, the output is a float32 with shape <code>[batch_size, length, vocab_size]</code>.</p>
`,returnType:`
<p><code>tf.Tensor</code></p>
`,raiseDescription:`
<ul>
<li><code>ValueError</code> \u2014 if <code>mode</code> is not valid.</li>
</ul>
`,raiseType:`
<p><code>ValueError</code></p>
`}}),gt=new k({props:{name:"class transformers.TFSequenceSummary",anchor:"transformers.TFSequenceSummary",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFSequenceSummary.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>) &#x2014;
The config used by the model. Relevant arguments in the config class of the model are (refer to the actual
config class of your model for the default values it uses):</p>
<ul>
<li>
<p><strong>summary_type</strong> (<code>str</code>) &#x2014; The method to use to make this summary. Accepted values are:</p>
<ul>
<li><code>&quot;last&quot;</code> &#x2014; Take the last token hidden state (like XLNet)</li>
<li><code>&quot;first&quot;</code> &#x2014; Take the first token hidden state (like Bert)</li>
<li><code>&quot;mean&quot;</code> &#x2014; Take the mean of all tokens hidden states</li>
<li><code>&quot;cls_index&quot;</code> &#x2014; Supply a Tensor of classification token position (GPT/GPT-2)</li>
<li><code>&quot;attn&quot;</code> &#x2014; Not implemented now, use multi-head attention</li>
</ul>
</li>
<li>
<p><strong>summary_use_proj</strong> (<code>bool</code>) &#x2014; Add a projection after the vector extraction.</p>
</li>
<li>
<p><strong>summary_proj_to_labels</strong> (<code>bool</code>) &#x2014; If <code>True</code>, the projection outputs to <code>config.num_labels</code> classes
(otherwise to <code>config.hidden_size</code>).</p>
</li>
<li>
<p><strong>summary_activation</strong> (<code>Optional[str]</code>) &#x2014; Set to <code>&quot;tanh&quot;</code> to add a tanh activation to the output,
another string or <code>None</code> will add no activation.</p>
</li>
<li>
<p><strong>summary_first_dropout</strong> (<code>float</code>) &#x2014; Optional dropout probability before the projection and activation.</p>
</li>
<li>
<p><strong>summary_last_dropout</strong> (<code>float</code>)&#x2014; Optional dropout probability after the projection and activation.</p>
</li>
</ul>`,name:"config"},{anchor:"transformers.TFSequenceSummary.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, defaults to 0.02) &#x2014; The standard deviation to use to initialize the weights.
kwargs &#x2014;
Additional keyword arguments passed along to the <code>__init__</code> of <code>tf.keras.layers.Layer</code>.`,name:"initializer_range"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L3144"}}),_t=new Jt({}),bt=new k({props:{name:"class transformers.modeling_tf_utils.TFCausalLanguageModelingLoss",anchor:"transformers.modeling_tf_utils.TFCausalLanguageModelingLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L200"}}),Ie=new rr({props:{$$slots:{default:[Bi]},$$scope:{ctx:S}}}),vt=new k({props:{name:"class transformers.modeling_tf_utils.TFMaskedLanguageModelingLoss",anchor:"transformers.modeling_tf_utils.TFMaskedLanguageModelingLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L319"}}),Ne=new rr({props:{$$slots:{default:[Gi]},$$scope:{ctx:S}}}),yt=new k({props:{name:"class transformers.modeling_tf_utils.TFMultipleChoiceLoss",anchor:"transformers.modeling_tf_utils.TFMultipleChoiceLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L309"}}),$t=new k({props:{name:"class transformers.modeling_tf_utils.TFQuestionAnsweringLoss",anchor:"transformers.modeling_tf_utils.TFQuestionAnsweringLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L231"}}),wt=new k({props:{name:"class transformers.modeling_tf_utils.TFSequenceClassificationLoss",anchor:"transformers.modeling_tf_utils.TFSequenceClassificationLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L290"}}),Tt=new k({props:{name:"class transformers.modeling_tf_utils.TFTokenClassificationLoss",anchor:"transformers.modeling_tf_utils.TFTokenClassificationLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L246"}}),He=new rr({props:{$$slots:{default:[Ui]},$$scope:{ctx:S}}}),kt=new Jt({}),xt=new k({props:{name:"transformers.modeling_tf_utils.get_initializer",anchor:"transformers.modeling_tf_utils.get_initializer",parameters:[{name:"initializer_range",val:": float = 0.02"}],parametersDescription:[{anchor:"transformers.modeling_tf_utils.get_initializer.initializer_range",description:"<strong>initializer_range</strong> (<em>float</em>, defaults to 0.02) &#x2014; Standard deviation of the initializer range.",name:"initializer_range"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L3260",returnDescription:`
<p>The truncated normal initializer.</p>
`,returnType:`
<p><code>tf.initializers.TruncatedNormal</code></p>
`}}),qt=new k({props:{name:"transformers.modeling_tf_utils.keras_serializable",anchor:"transformers.modeling_tf_utils.keras_serializable",parameters:[],parametersDescription:[{anchor:"transformers.modeling_tf_utils.keras_serializable.cls",description:`<strong>cls</strong> (a <code>tf.keras.layers.Layers subclass</code>) &#x2014;
Typically a <code>TF.MainLayer</code> class in this project, in general must accept a <code>config</code> argument to its
initializer.`,name:"cls"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_utils.py#L135",returnDescription:`
<p>The same class object, with modifications for Keras deserialization.</p>
`}}),Dt=new k({props:{name:"transformers.shape_list",anchor:"transformers.shape_list",parameters:[{name:"tensor",val:": typing.Union[tensorflow.python.framework.ops.Tensor, numpy.ndarray]"}],parametersDescription:[{anchor:"transformers.shape_list.tensor",description:"<strong>tensor</strong> (<code>tf.Tensor</code> or <code>np.ndarray</code>) &#x2014; The tensor we want the shape of.",name:"tensor"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/tf_utils.py#L26",returnDescription:`
<p>The shape of the tensor as a list.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),{c(){m=r("meta"),x=l(),u=r("h1"),$=r("a"),q=r("span"),h(w.$$.fragment),D=l(),O=r("span"),P=a("Custom Layers and Utilities"),Q=l(),F=r("p"),C=a("This page lists all the custom layers used by the library, as well as the utility functions it provides for modeling."),B=l(),A=r("p"),z=a("Most of those are only useful if you are studying the code of the models in the library."),G=l(),L=r("h2"),E=r("a"),T=r("span"),h(I.$$.fragment),ce=l(),U=r("span"),me=a("Pytorch custom modules"),ae=l(),K=r("div"),h(Be.$$.fragment),Yr=l(),Yt=r("p"),Zr=a("1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),en=l(),Zt=r("p"),tn=a("Basically works like a linear layer but the weights are transposed."),nr=l(),R=r("div"),h(Ge.$$.fragment),on=l(),eo=r("p"),rn=a("Compute SQuAD start logits from sequence hidden states."),nn=l(),Pt=r("div"),h(Ue.$$.fragment),sr=l(),W=r("div"),h(Ke.$$.fragment),sn=l(),to=r("p"),an=a("Compute SQuAD end logits from sequence hidden states."),ln=l(),De=r("div"),h(Re.$$.fragment),dn=l(),h(Le.$$.fragment),ar=l(),X=r("div"),h(We.$$.fragment),cn=l(),oo=r("p"),mn=a("Compute SQuAD 2.0 answer class from classification and start tokens hidden states."),pn=l(),Pe=r("div"),h(Xe.$$.fragment),fn=l(),h(Ce.$$.fragment),ir=l(),pe=r("div"),h(Je.$$.fragment),un=l(),Ye=r("p"),hn=a("Base class for outputs of question answering models using a "),Ct=r("a"),gn=a("SQuADHead"),_n=a("."),lr=l(),J=r("div"),h(Ze.$$.fragment),bn=l(),ro=r("p"),vn=a("A SQuAD head inspired by XLNet."),yn=l(),zt=r("div"),h(et.$$.fragment),dr=l(),Y=r("div"),h(tt.$$.fragment),$n=l(),no=r("p"),wn=a("Compute a single vector summary of a sequence hidden states."),Tn=l(),ze=r("div"),h(ot.$$.fragment),kn=l(),so=r("p"),xn=a("Compute a single vector summary of a sequence hidden states."),cr=l(),fe=r("h2"),Se=r("a"),ao=r("span"),h(rt.$$.fragment),En=l(),io=r("span"),qn=a("PyTorch Helper Functions"),mr=l(),N=r("div"),h(nt.$$.fragment),Dn=l(),H=r("p"),Ln=a("This function chunks the "),lo=r("code"),Pn=a("input_tensors"),Cn=a(" into smaller input tensor parts of size "),co=r("code"),zn=a("chunk_size"),Sn=a(` over the dimension
`),mo=r("code"),Fn=a("chunk_dim"),An=a(". It then applies a layer "),po=r("code"),On=a("forward_fn"),In=a(" to each chunk independently to save memory."),Nn=l(),M=r("p"),Hn=a("If the "),fo=r("code"),Mn=a("forward_fn"),Vn=a(" is independent across the "),uo=r("code"),jn=a("chunk_dim"),Qn=a(` this function will yield the same result as directly
applying `),ho=r("code"),Bn=a("forward_fn"),Gn=a(" to "),go=r("code"),Un=a("input_tensors"),Kn=a("."),Rn=l(),h(Fe.$$.fragment),pr=l(),ue=r("div"),h(st.$$.fragment),Wn=l(),at=r("p"),Xn=a("Finds the heads and their indices taking "),_o=r("code"),Jn=a("already_pruned_heads"),Yn=a(" into account."),fr=l(),Z=r("div"),h(it.$$.fragment),Zn=l(),bo=r("p"),es=a("Prune a Conv1D or linear layer to keep only entries in index."),ts=l(),vo=r("p"),os=a("Used to remove heads."),ur=l(),ee=r("div"),h(lt.$$.fragment),rs=l(),yo=r("p"),ns=a(`Prune a Conv1D layer to keep only entries in index. A Conv1D work as a Linear layer (see e.g. BERT) but the weights
are transposed.`),ss=l(),$o=r("p"),as=a("Used to remove heads."),hr=l(),te=r("div"),h(dt.$$.fragment),is=l(),wo=r("p"),ls=a("Prune a linear layer to keep only entries in index."),ds=l(),To=r("p"),cs=a("Used to remove heads."),gr=l(),he=r("h2"),Ae=r("a"),ko=r("span"),h(ct.$$.fragment),ms=l(),xo=r("span"),ps=a("TensorFlow custom layers"),_r=l(),oe=r("div"),h(mt.$$.fragment),fs=l(),Eo=r("p"),us=a("1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),hs=l(),qo=r("p"),gs=a("Basically works like a linear layer but the weights are transposed."),br=l(),V=r("div"),h(pt.$$.fragment),_s=l(),Do=r("p"),bs=a("Construct shared token embeddings."),vs=l(),Lo=r("p"),ys=a(`The weights of the embedding layer is usually shared with the weights of the linear decoder when doing language
modeling.`),$s=l(),ie=r("div"),h(ft.$$.fragment),ws=l(),Po=r("p"),Ts=a("Get token embeddings of inputs or decode final hidden state."),ks=l(),ut=r("p"),xs=a(`Shared weights logic is adapted from
`),ht=r("a"),Es=a("here"),qs=a("."),vr=l(),ge=r("div"),h(gt.$$.fragment),Ds=l(),Co=r("p"),Ls=a("Compute a single vector summary of a sequence hidden states."),yr=l(),_e=r("h2"),Oe=r("a"),zo=r("span"),h(_t.$$.fragment),Ps=l(),So=r("span"),Cs=a("TensorFlow loss functions"),$r=l(),re=r("div"),h(bt.$$.fragment),zs=l(),Fo=r("p"),Ss=a("Loss function suitable for causal language modeling (CLM), that is, the task of guessing the next token."),Fs=l(),h(Ie.$$.fragment),wr=l(),ne=r("div"),h(vt.$$.fragment),As=l(),Ao=r("p"),Os=a("Loss function suitable for masked language modeling (MLM), that is, the task of guessing the masked tokens."),Is=l(),h(Ne.$$.fragment),Tr=l(),be=r("div"),h(yt.$$.fragment),Ns=l(),Oo=r("p"),Hs=a("Loss function suitable for multiple choice tasks."),kr=l(),ve=r("div"),h($t.$$.fragment),Ms=l(),Io=r("p"),Vs=a("Loss function suitable for question answering."),xr=l(),ye=r("div"),h(wt.$$.fragment),js=l(),No=r("p"),Qs=a("Loss function suitable for sequence classification."),Er=l(),se=r("div"),h(Tt.$$.fragment),Bs=l(),Ho=r("p"),Gs=a("Loss function suitable for token classification."),Us=l(),h(He.$$.fragment),qr=l(),$e=r("h2"),Me=r("a"),Mo=r("span"),h(kt.$$.fragment),Ks=l(),Vo=r("span"),Rs=a("TensorFlow Helper Functions"),Dr=l(),we=r("div"),h(xt.$$.fragment),Ws=l(),Et=r("p"),Xs=a("Creates a "),jo=r("code"),Js=a("tf.initializers.TruncatedNormal"),Ys=a(" with the given range."),Lr=l(),j=r("div"),h(qt.$$.fragment),Zs=l(),Qo=r("p"),ea=a("Decorate a Keras Layer class to support Keras serialization."),ta=l(),Bo=r("p"),oa=a("This is done by:"),ra=l(),Te=r("ol"),ke=r("li"),na=a("Adding a "),Go=r("code"),sa=a("transformers_config"),aa=a(" dict to the Keras config dictionary in "),Uo=r("code"),ia=a("get_config"),la=a(` (called by Keras at
serialization time.`),da=l(),xe=r("li"),ca=a("Wrapping "),Ko=r("code"),ma=a("__init__"),pa=a(" to accept that "),Ro=r("code"),fa=a("transformers_config"),ua=a(` dict (passed by Keras at deserialization time) and
convert it to a config object for the actual layer initializer.`),ha=l(),Ee=r("li"),ga=a(`Registering the class as a custom object in Keras (if the Tensorflow version supports this), so that it does not
need to be supplied in `),Wo=r("code"),_a=a("custom_objects"),ba=a(" in the call to "),Xo=r("code"),va=a("tf.keras.models.load_model"),ya=a("."),Pr=l(),qe=r("div"),h(Dt.$$.fragment),$a=l(),Jo=r("p"),wa=a("Deal with dynamic shape in tensorflow cleanly."),this.h()},l(e){const c=Oi('[data-svelte="svelte-1phssyn"]',document.head);m=n(c,"META",{name:!0,content:!0}),c.forEach(o),x=d(e),u=n(e,"H1",{class:!0});var Lt=s(u);$=n(Lt,"A",{id:!0,class:!0,href:!0});var Yo=s($);q=n(Yo,"SPAN",{});var Zo=s(q);g(w.$$.fragment,Zo),Zo.forEach(o),Yo.forEach(o),D=d(Lt),O=n(Lt,"SPAN",{});var er=s(O);P=i(er,"Custom Layers and Utilities"),er.forEach(o),Lt.forEach(o),Q=d(e),F=n(e,"P",{});var tr=s(F);C=i(tr,"This page lists all the custom layers used by the library, as well as the utility functions it provides for modeling."),tr.forEach(o),B=d(e),A=n(e,"P",{});var or=s(A);z=i(or,"Most of those are only useful if you are studying the code of the models in the library."),or.forEach(o),G=d(e),L=n(e,"H2",{class:!0});var zr=s(L);E=n(zr,"A",{id:!0,class:!0,href:!0});var Ta=s(E);T=n(Ta,"SPAN",{});var ka=s(T);g(I.$$.fragment,ka),ka.forEach(o),Ta.forEach(o),ce=d(zr),U=n(zr,"SPAN",{});var xa=s(U);me=i(xa,"Pytorch custom modules"),xa.forEach(o),zr.forEach(o),ae=d(e),K=n(e,"DIV",{class:!0});var St=s(K);g(Be.$$.fragment,St),Yr=d(St),Yt=n(St,"P",{});var Ea=s(Yt);Zr=i(Ea,"1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),Ea.forEach(o),en=d(St),Zt=n(St,"P",{});var qa=s(Zt);tn=i(qa,"Basically works like a linear layer but the weights are transposed."),qa.forEach(o),St.forEach(o),nr=d(e),R=n(e,"DIV",{class:!0});var Ft=s(R);g(Ge.$$.fragment,Ft),on=d(Ft),eo=n(Ft,"P",{});var Da=s(eo);rn=i(Da,"Compute SQuAD start logits from sequence hidden states."),Da.forEach(o),nn=d(Ft),Pt=n(Ft,"DIV",{class:!0});var La=s(Pt);g(Ue.$$.fragment,La),La.forEach(o),Ft.forEach(o),sr=d(e),W=n(e,"DIV",{class:!0});var At=s(W);g(Ke.$$.fragment,At),sn=d(At),to=n(At,"P",{});var Pa=s(to);an=i(Pa,"Compute SQuAD end logits from sequence hidden states."),Pa.forEach(o),ln=d(At),De=n(At,"DIV",{class:!0});var Sr=s(De);g(Re.$$.fragment,Sr),dn=d(Sr),g(Le.$$.fragment,Sr),Sr.forEach(o),At.forEach(o),ar=d(e),X=n(e,"DIV",{class:!0});var Ot=s(X);g(We.$$.fragment,Ot),cn=d(Ot),oo=n(Ot,"P",{});var Ca=s(oo);mn=i(Ca,"Compute SQuAD 2.0 answer class from classification and start tokens hidden states."),Ca.forEach(o),pn=d(Ot),Pe=n(Ot,"DIV",{class:!0});var Fr=s(Pe);g(Xe.$$.fragment,Fr),fn=d(Fr),g(Ce.$$.fragment,Fr),Fr.forEach(o),Ot.forEach(o),ir=d(e),pe=n(e,"DIV",{class:!0});var Ar=s(pe);g(Je.$$.fragment,Ar),un=d(Ar),Ye=n(Ar,"P",{});var Or=s(Ye);hn=i(Or,"Base class for outputs of question answering models using a "),Ct=n(Or,"A",{href:!0});var za=s(Ct);gn=i(za,"SQuADHead"),za.forEach(o),_n=i(Or,"."),Or.forEach(o),Ar.forEach(o),lr=d(e),J=n(e,"DIV",{class:!0});var It=s(J);g(Ze.$$.fragment,It),bn=d(It),ro=n(It,"P",{});var Sa=s(ro);vn=i(Sa,"A SQuAD head inspired by XLNet."),Sa.forEach(o),yn=d(It),zt=n(It,"DIV",{class:!0});var Fa=s(zt);g(et.$$.fragment,Fa),Fa.forEach(o),It.forEach(o),dr=d(e),Y=n(e,"DIV",{class:!0});var Nt=s(Y);g(tt.$$.fragment,Nt),$n=d(Nt),no=n(Nt,"P",{});var Aa=s(no);wn=i(Aa,"Compute a single vector summary of a sequence hidden states."),Aa.forEach(o),Tn=d(Nt),ze=n(Nt,"DIV",{class:!0});var Ir=s(ze);g(ot.$$.fragment,Ir),kn=d(Ir),so=n(Ir,"P",{});var Oa=s(so);xn=i(Oa,"Compute a single vector summary of a sequence hidden states."),Oa.forEach(o),Ir.forEach(o),Nt.forEach(o),cr=d(e),fe=n(e,"H2",{class:!0});var Nr=s(fe);Se=n(Nr,"A",{id:!0,class:!0,href:!0});var Ia=s(Se);ao=n(Ia,"SPAN",{});var Na=s(ao);g(rt.$$.fragment,Na),Na.forEach(o),Ia.forEach(o),En=d(Nr),io=n(Nr,"SPAN",{});var Ha=s(io);qn=i(Ha,"PyTorch Helper Functions"),Ha.forEach(o),Nr.forEach(o),mr=d(e),N=n(e,"DIV",{class:!0});var Ve=s(N);g(nt.$$.fragment,Ve),Dn=d(Ve),H=n(Ve,"P",{});var le=s(H);Ln=i(le,"This function chunks the "),lo=n(le,"CODE",{});var Ma=s(lo);Pn=i(Ma,"input_tensors"),Ma.forEach(o),Cn=i(le," into smaller input tensor parts of size "),co=n(le,"CODE",{});var Va=s(co);zn=i(Va,"chunk_size"),Va.forEach(o),Sn=i(le,` over the dimension
`),mo=n(le,"CODE",{});var ja=s(mo);Fn=i(ja,"chunk_dim"),ja.forEach(o),An=i(le,". It then applies a layer "),po=n(le,"CODE",{});var Qa=s(po);On=i(Qa,"forward_fn"),Qa.forEach(o),In=i(le," to each chunk independently to save memory."),le.forEach(o),Nn=d(Ve),M=n(Ve,"P",{});var de=s(M);Hn=i(de,"If the "),fo=n(de,"CODE",{});var Ba=s(fo);Mn=i(Ba,"forward_fn"),Ba.forEach(o),Vn=i(de," is independent across the "),uo=n(de,"CODE",{});var Ga=s(uo);jn=i(Ga,"chunk_dim"),Ga.forEach(o),Qn=i(de,` this function will yield the same result as directly
applying `),ho=n(de,"CODE",{});var Ua=s(ho);Bn=i(Ua,"forward_fn"),Ua.forEach(o),Gn=i(de," to "),go=n(de,"CODE",{});var Ka=s(go);Un=i(Ka,"input_tensors"),Ka.forEach(o),Kn=i(de,"."),de.forEach(o),Rn=d(Ve),g(Fe.$$.fragment,Ve),Ve.forEach(o),pr=d(e),ue=n(e,"DIV",{class:!0});var Hr=s(ue);g(st.$$.fragment,Hr),Wn=d(Hr),at=n(Hr,"P",{});var Mr=s(at);Xn=i(Mr,"Finds the heads and their indices taking "),_o=n(Mr,"CODE",{});var Ra=s(_o);Jn=i(Ra,"already_pruned_heads"),Ra.forEach(o),Yn=i(Mr," into account."),Mr.forEach(o),Hr.forEach(o),fr=d(e),Z=n(e,"DIV",{class:!0});var Ht=s(Z);g(it.$$.fragment,Ht),Zn=d(Ht),bo=n(Ht,"P",{});var Wa=s(bo);es=i(Wa,"Prune a Conv1D or linear layer to keep only entries in index."),Wa.forEach(o),ts=d(Ht),vo=n(Ht,"P",{});var Xa=s(vo);os=i(Xa,"Used to remove heads."),Xa.forEach(o),Ht.forEach(o),ur=d(e),ee=n(e,"DIV",{class:!0});var Mt=s(ee);g(lt.$$.fragment,Mt),rs=d(Mt),yo=n(Mt,"P",{});var Ja=s(yo);ns=i(Ja,`Prune a Conv1D layer to keep only entries in index. A Conv1D work as a Linear layer (see e.g. BERT) but the weights
are transposed.`),Ja.forEach(o),ss=d(Mt),$o=n(Mt,"P",{});var Ya=s($o);as=i(Ya,"Used to remove heads."),Ya.forEach(o),Mt.forEach(o),hr=d(e),te=n(e,"DIV",{class:!0});var Vt=s(te);g(dt.$$.fragment,Vt),is=d(Vt),wo=n(Vt,"P",{});var Za=s(wo);ls=i(Za,"Prune a linear layer to keep only entries in index."),Za.forEach(o),ds=d(Vt),To=n(Vt,"P",{});var ei=s(To);cs=i(ei,"Used to remove heads."),ei.forEach(o),Vt.forEach(o),gr=d(e),he=n(e,"H2",{class:!0});var Vr=s(he);Ae=n(Vr,"A",{id:!0,class:!0,href:!0});var ti=s(Ae);ko=n(ti,"SPAN",{});var oi=s(ko);g(ct.$$.fragment,oi),oi.forEach(o),ti.forEach(o),ms=d(Vr),xo=n(Vr,"SPAN",{});var ri=s(xo);ps=i(ri,"TensorFlow custom layers"),ri.forEach(o),Vr.forEach(o),_r=d(e),oe=n(e,"DIV",{class:!0});var jt=s(oe);g(mt.$$.fragment,jt),fs=d(jt),Eo=n(jt,"P",{});var ni=s(Eo);us=i(ni,"1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),ni.forEach(o),hs=d(jt),qo=n(jt,"P",{});var si=s(qo);gs=i(si,"Basically works like a linear layer but the weights are transposed."),si.forEach(o),jt.forEach(o),br=d(e),V=n(e,"DIV",{class:!0});var je=s(V);g(pt.$$.fragment,je),_s=d(je),Do=n(je,"P",{});var ai=s(Do);bs=i(ai,"Construct shared token embeddings."),ai.forEach(o),vs=d(je),Lo=n(je,"P",{});var ii=s(Lo);ys=i(ii,`The weights of the embedding layer is usually shared with the weights of the linear decoder when doing language
modeling.`),ii.forEach(o),$s=d(je),ie=n(je,"DIV",{class:!0});var Qt=s(ie);g(ft.$$.fragment,Qt),ws=d(Qt),Po=n(Qt,"P",{});var li=s(Po);Ts=i(li,"Get token embeddings of inputs or decode final hidden state."),li.forEach(o),ks=d(Qt),ut=n(Qt,"P",{});var jr=s(ut);xs=i(jr,`Shared weights logic is adapted from
`),ht=n(jr,"A",{href:!0,rel:!0});var di=s(ht);Es=i(di,"here"),di.forEach(o),qs=i(jr,"."),jr.forEach(o),Qt.forEach(o),je.forEach(o),vr=d(e),ge=n(e,"DIV",{class:!0});var Qr=s(ge);g(gt.$$.fragment,Qr),Ds=d(Qr),Co=n(Qr,"P",{});var ci=s(Co);Ls=i(ci,"Compute a single vector summary of a sequence hidden states."),ci.forEach(o),Qr.forEach(o),yr=d(e),_e=n(e,"H2",{class:!0});var Br=s(_e);Oe=n(Br,"A",{id:!0,class:!0,href:!0});var mi=s(Oe);zo=n(mi,"SPAN",{});var pi=s(zo);g(_t.$$.fragment,pi),pi.forEach(o),mi.forEach(o),Ps=d(Br),So=n(Br,"SPAN",{});var fi=s(So);Cs=i(fi,"TensorFlow loss functions"),fi.forEach(o),Br.forEach(o),$r=d(e),re=n(e,"DIV",{class:!0});var Bt=s(re);g(bt.$$.fragment,Bt),zs=d(Bt),Fo=n(Bt,"P",{});var ui=s(Fo);Ss=i(ui,"Loss function suitable for causal language modeling (CLM), that is, the task of guessing the next token."),ui.forEach(o),Fs=d(Bt),g(Ie.$$.fragment,Bt),Bt.forEach(o),wr=d(e),ne=n(e,"DIV",{class:!0});var Gt=s(ne);g(vt.$$.fragment,Gt),As=d(Gt),Ao=n(Gt,"P",{});var hi=s(Ao);Os=i(hi,"Loss function suitable for masked language modeling (MLM), that is, the task of guessing the masked tokens."),hi.forEach(o),Is=d(Gt),g(Ne.$$.fragment,Gt),Gt.forEach(o),Tr=d(e),be=n(e,"DIV",{class:!0});var Gr=s(be);g(yt.$$.fragment,Gr),Ns=d(Gr),Oo=n(Gr,"P",{});var gi=s(Oo);Hs=i(gi,"Loss function suitable for multiple choice tasks."),gi.forEach(o),Gr.forEach(o),kr=d(e),ve=n(e,"DIV",{class:!0});var Ur=s(ve);g($t.$$.fragment,Ur),Ms=d(Ur),Io=n(Ur,"P",{});var _i=s(Io);Vs=i(_i,"Loss function suitable for question answering."),_i.forEach(o),Ur.forEach(o),xr=d(e),ye=n(e,"DIV",{class:!0});var Kr=s(ye);g(wt.$$.fragment,Kr),js=d(Kr),No=n(Kr,"P",{});var bi=s(No);Qs=i(bi,"Loss function suitable for sequence classification."),bi.forEach(o),Kr.forEach(o),Er=d(e),se=n(e,"DIV",{class:!0});var Ut=s(se);g(Tt.$$.fragment,Ut),Bs=d(Ut),Ho=n(Ut,"P",{});var vi=s(Ho);Gs=i(vi,"Loss function suitable for token classification."),vi.forEach(o),Us=d(Ut),g(He.$$.fragment,Ut),Ut.forEach(o),qr=d(e),$e=n(e,"H2",{class:!0});var Rr=s($e);Me=n(Rr,"A",{id:!0,class:!0,href:!0});var yi=s(Me);Mo=n(yi,"SPAN",{});var $i=s(Mo);g(kt.$$.fragment,$i),$i.forEach(o),yi.forEach(o),Ks=d(Rr),Vo=n(Rr,"SPAN",{});var wi=s(Vo);Rs=i(wi,"TensorFlow Helper Functions"),wi.forEach(o),Rr.forEach(o),Dr=d(e),we=n(e,"DIV",{class:!0});var Wr=s(we);g(xt.$$.fragment,Wr),Ws=d(Wr),Et=n(Wr,"P",{});var Xr=s(Et);Xs=i(Xr,"Creates a "),jo=n(Xr,"CODE",{});var Ti=s(jo);Js=i(Ti,"tf.initializers.TruncatedNormal"),Ti.forEach(o),Ys=i(Xr," with the given range."),Xr.forEach(o),Wr.forEach(o),Lr=d(e),j=n(e,"DIV",{class:!0});var Qe=s(j);g(qt.$$.fragment,Qe),Zs=d(Qe),Qo=n(Qe,"P",{});var ki=s(Qo);ea=i(ki,"Decorate a Keras Layer class to support Keras serialization."),ki.forEach(o),ta=d(Qe),Bo=n(Qe,"P",{});var xi=s(Bo);oa=i(xi,"This is done by:"),xi.forEach(o),ra=d(Qe),Te=n(Qe,"OL",{});var Kt=s(Te);ke=n(Kt,"LI",{});var Rt=s(ke);na=i(Rt,"Adding a "),Go=n(Rt,"CODE",{});var Ei=s(Go);sa=i(Ei,"transformers_config"),Ei.forEach(o),aa=i(Rt," dict to the Keras config dictionary in "),Uo=n(Rt,"CODE",{});var qi=s(Uo);ia=i(qi,"get_config"),qi.forEach(o),la=i(Rt,` (called by Keras at
serialization time.`),Rt.forEach(o),da=d(Kt),xe=n(Kt,"LI",{});var Wt=s(xe);ca=i(Wt,"Wrapping "),Ko=n(Wt,"CODE",{});var Di=s(Ko);ma=i(Di,"__init__"),Di.forEach(o),pa=i(Wt," to accept that "),Ro=n(Wt,"CODE",{});var Li=s(Ro);fa=i(Li,"transformers_config"),Li.forEach(o),ua=i(Wt,` dict (passed by Keras at deserialization time) and
convert it to a config object for the actual layer initializer.`),Wt.forEach(o),ha=d(Kt),Ee=n(Kt,"LI",{});var Xt=s(Ee);ga=i(Xt,`Registering the class as a custom object in Keras (if the Tensorflow version supports this), so that it does not
need to be supplied in `),Wo=n(Xt,"CODE",{});var Pi=s(Wo);_a=i(Pi,"custom_objects"),Pi.forEach(o),ba=i(Xt," in the call to "),Xo=n(Xt,"CODE",{});var Ci=s(Xo);va=i(Ci,"tf.keras.models.load_model"),Ci.forEach(o),ya=i(Xt,"."),Xt.forEach(o),Kt.forEach(o),Qe.forEach(o),Pr=d(e),qe=n(e,"DIV",{class:!0});var Jr=s(qe);g(Dt.$$.fragment,Jr),$a=d(Jr),Jo=n(Jr,"P",{});var zi=s(Jo);wa=i(zi,"Deal with dynamic shape in tensorflow cleanly."),zi.forEach(o),Jr.forEach(o),this.h()},h(){f(m,"name","hf:doc:metadata"),f(m,"content",JSON.stringify(Ri)),f($,"id","custom-layers-and-utilities"),f($,"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"),f($,"href","#custom-layers-and-utilities"),f(u,"class","relative group"),f(E,"id","transformers.Conv1D"),f(E,"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"),f(E,"href","#transformers.Conv1D"),f(L,"class","relative group"),f(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Pt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(De,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Ct,"href","/docs/transformers/main/en/internal/modeling_utils#transformers.modeling_utils.SQuADHead"),f(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(zt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ze,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Se,"id","transformers.apply_chunking_to_forward"),f(Se,"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"),f(Se,"href","#transformers.apply_chunking_to_forward"),f(fe,"class","relative group"),f(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Ae,"id","transformers.modeling_tf_utils.TFConv1D"),f(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"),f(Ae,"href","#transformers.modeling_tf_utils.TFConv1D"),f(he,"class","relative group"),f(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ht,"href","https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24"),f(ht,"rel","nofollow"),f(ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ge,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Oe,"id","transformers.modeling_tf_utils.TFCausalLanguageModelingLoss"),f(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"),f(Oe,"href","#transformers.modeling_tf_utils.TFCausalLanguageModelingLoss"),f(_e,"class","relative group"),f(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Me,"id","transformers.modeling_tf_utils.get_initializer"),f(Me,"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"),f(Me,"href","#transformers.modeling_tf_utils.get_initializer"),f($e,"class","relative group"),f(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(qe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,c){t(document.head,m),p(e,x,c),p(e,u,c),t(u,$),t($,q),_(w,q,null),t(u,D),t(u,O),t(O,P),p(e,Q,c),p(e,F,c),t(F,C),p(e,B,c),p(e,A,c),t(A,z),p(e,G,c),p(e,L,c),t(L,E),t(E,T),_(I,T,null),t(L,ce),t(L,U),t(U,me),p(e,ae,c),p(e,K,c),_(Be,K,null),t(K,Yr),t(K,Yt),t(Yt,Zr),t(K,en),t(K,Zt),t(Zt,tn),p(e,nr,c),p(e,R,c),_(Ge,R,null),t(R,on),t(R,eo),t(eo,rn),t(R,nn),t(R,Pt),_(Ue,Pt,null),p(e,sr,c),p(e,W,c),_(Ke,W,null),t(W,sn),t(W,to),t(to,an),t(W,ln),t(W,De),_(Re,De,null),t(De,dn),_(Le,De,null),p(e,ar,c),p(e,X,c),_(We,X,null),t(X,cn),t(X,oo),t(oo,mn),t(X,pn),t(X,Pe),_(Xe,Pe,null),t(Pe,fn),_(Ce,Pe,null),p(e,ir,c),p(e,pe,c),_(Je,pe,null),t(pe,un),t(pe,Ye),t(Ye,hn),t(Ye,Ct),t(Ct,gn),t(Ye,_n),p(e,lr,c),p(e,J,c),_(Ze,J,null),t(J,bn),t(J,ro),t(ro,vn),t(J,yn),t(J,zt),_(et,zt,null),p(e,dr,c),p(e,Y,c),_(tt,Y,null),t(Y,$n),t(Y,no),t(no,wn),t(Y,Tn),t(Y,ze),_(ot,ze,null),t(ze,kn),t(ze,so),t(so,xn),p(e,cr,c),p(e,fe,c),t(fe,Se),t(Se,ao),_(rt,ao,null),t(fe,En),t(fe,io),t(io,qn),p(e,mr,c),p(e,N,c),_(nt,N,null),t(N,Dn),t(N,H),t(H,Ln),t(H,lo),t(lo,Pn),t(H,Cn),t(H,co),t(co,zn),t(H,Sn),t(H,mo),t(mo,Fn),t(H,An),t(H,po),t(po,On),t(H,In),t(N,Nn),t(N,M),t(M,Hn),t(M,fo),t(fo,Mn),t(M,Vn),t(M,uo),t(uo,jn),t(M,Qn),t(M,ho),t(ho,Bn),t(M,Gn),t(M,go),t(go,Un),t(M,Kn),t(N,Rn),_(Fe,N,null),p(e,pr,c),p(e,ue,c),_(st,ue,null),t(ue,Wn),t(ue,at),t(at,Xn),t(at,_o),t(_o,Jn),t(at,Yn),p(e,fr,c),p(e,Z,c),_(it,Z,null),t(Z,Zn),t(Z,bo),t(bo,es),t(Z,ts),t(Z,vo),t(vo,os),p(e,ur,c),p(e,ee,c),_(lt,ee,null),t(ee,rs),t(ee,yo),t(yo,ns),t(ee,ss),t(ee,$o),t($o,as),p(e,hr,c),p(e,te,c),_(dt,te,null),t(te,is),t(te,wo),t(wo,ls),t(te,ds),t(te,To),t(To,cs),p(e,gr,c),p(e,he,c),t(he,Ae),t(Ae,ko),_(ct,ko,null),t(he,ms),t(he,xo),t(xo,ps),p(e,_r,c),p(e,oe,c),_(mt,oe,null),t(oe,fs),t(oe,Eo),t(Eo,us),t(oe,hs),t(oe,qo),t(qo,gs),p(e,br,c),p(e,V,c),_(pt,V,null),t(V,_s),t(V,Do),t(Do,bs),t(V,vs),t(V,Lo),t(Lo,ys),t(V,$s),t(V,ie),_(ft,ie,null),t(ie,ws),t(ie,Po),t(Po,Ts),t(ie,ks),t(ie,ut),t(ut,xs),t(ut,ht),t(ht,Es),t(ut,qs),p(e,vr,c),p(e,ge,c),_(gt,ge,null),t(ge,Ds),t(ge,Co),t(Co,Ls),p(e,yr,c),p(e,_e,c),t(_e,Oe),t(Oe,zo),_(_t,zo,null),t(_e,Ps),t(_e,So),t(So,Cs),p(e,$r,c),p(e,re,c),_(bt,re,null),t(re,zs),t(re,Fo),t(Fo,Ss),t(re,Fs),_(Ie,re,null),p(e,wr,c),p(e,ne,c),_(vt,ne,null),t(ne,As),t(ne,Ao),t(Ao,Os),t(ne,Is),_(Ne,ne,null),p(e,Tr,c),p(e,be,c),_(yt,be,null),t(be,Ns),t(be,Oo),t(Oo,Hs),p(e,kr,c),p(e,ve,c),_($t,ve,null),t(ve,Ms),t(ve,Io),t(Io,Vs),p(e,xr,c),p(e,ye,c),_(wt,ye,null),t(ye,js),t(ye,No),t(No,Qs),p(e,Er,c),p(e,se,c),_(Tt,se,null),t(se,Bs),t(se,Ho),t(Ho,Gs),t(se,Us),_(He,se,null),p(e,qr,c),p(e,$e,c),t($e,Me),t(Me,Mo),_(kt,Mo,null),t($e,Ks),t($e,Vo),t(Vo,Rs),p(e,Dr,c),p(e,we,c),_(xt,we,null),t(we,Ws),t(we,Et),t(Et,Xs),t(Et,jo),t(jo,Js),t(Et,Ys),p(e,Lr,c),p(e,j,c),_(qt,j,null),t(j,Zs),t(j,Qo),t(Qo,ea),t(j,ta),t(j,Bo),t(Bo,oa),t(j,ra),t(j,Te),t(Te,ke),t(ke,na),t(ke,Go),t(Go,sa),t(ke,aa),t(ke,Uo),t(Uo,ia),t(ke,la),t(Te,da),t(Te,xe),t(xe,ca),t(xe,Ko),t(Ko,ma),t(xe,pa),t(xe,Ro),t(Ro,fa),t(xe,ua),t(Te,ha),t(Te,Ee),t(Ee,ga),t(Ee,Wo),t(Wo,_a),t(Ee,ba),t(Ee,Xo),t(Xo,va),t(Ee,ya),p(e,Pr,c),p(e,qe,c),_(Dt,qe,null),t(qe,$a),t(qe,Jo),t(Jo,wa),Cr=!0},p(e,[c]){const Lt={};c&2&&(Lt.$$scope={dirty:c,ctx:e}),Le.$set(Lt);const Yo={};c&2&&(Yo.$$scope={dirty:c,ctx:e}),Ce.$set(Yo);const Zo={};c&2&&(Zo.$$scope={dirty:c,ctx:e}),Fe.$set(Zo);const er={};c&2&&(er.$$scope={dirty:c,ctx:e}),Ie.$set(er);const tr={};c&2&&(tr.$$scope={dirty:c,ctx:e}),Ne.$set(tr);const or={};c&2&&(or.$$scope={dirty:c,ctx:e}),He.$set(or)},i(e){Cr||(b(w.$$.fragment,e),b(I.$$.fragment,e),b(Be.$$.fragment,e),b(Ge.$$.fragment,e),b(Ue.$$.fragment,e),b(Ke.$$.fragment,e),b(Re.$$.fragment,e),b(Le.$$.fragment,e),b(We.$$.fragment,e),b(Xe.$$.fragment,e),b(Ce.$$.fragment,e),b(Je.$$.fragment,e),b(Ze.$$.fragment,e),b(et.$$.fragment,e),b(tt.$$.fragment,e),b(ot.$$.fragment,e),b(rt.$$.fragment,e),b(nt.$$.fragment,e),b(Fe.$$.fragment,e),b(st.$$.fragment,e),b(it.$$.fragment,e),b(lt.$$.fragment,e),b(dt.$$.fragment,e),b(ct.$$.fragment,e),b(mt.$$.fragment,e),b(pt.$$.fragment,e),b(ft.$$.fragment,e),b(gt.$$.fragment,e),b(_t.$$.fragment,e),b(bt.$$.fragment,e),b(Ie.$$.fragment,e),b(vt.$$.fragment,e),b(Ne.$$.fragment,e),b(yt.$$.fragment,e),b($t.$$.fragment,e),b(wt.$$.fragment,e),b(Tt.$$.fragment,e),b(He.$$.fragment,e),b(kt.$$.fragment,e),b(xt.$$.fragment,e),b(qt.$$.fragment,e),b(Dt.$$.fragment,e),Cr=!0)},o(e){v(w.$$.fragment,e),v(I.$$.fragment,e),v(Be.$$.fragment,e),v(Ge.$$.fragment,e),v(Ue.$$.fragment,e),v(Ke.$$.fragment,e),v(Re.$$.fragment,e),v(Le.$$.fragment,e),v(We.$$.fragment,e),v(Xe.$$.fragment,e),v(Ce.$$.fragment,e),v(Je.$$.fragment,e),v(Ze.$$.fragment,e),v(et.$$.fragment,e),v(tt.$$.fragment,e),v(ot.$$.fragment,e),v(rt.$$.fragment,e),v(nt.$$.fragment,e),v(Fe.$$.fragment,e),v(st.$$.fragment,e),v(it.$$.fragment,e),v(lt.$$.fragment,e),v(dt.$$.fragment,e),v(ct.$$.fragment,e),v(mt.$$.fragment,e),v(pt.$$.fragment,e),v(ft.$$.fragment,e),v(gt.$$.fragment,e),v(_t.$$.fragment,e),v(bt.$$.fragment,e),v(Ie.$$.fragment,e),v(vt.$$.fragment,e),v(Ne.$$.fragment,e),v(yt.$$.fragment,e),v($t.$$.fragment,e),v(wt.$$.fragment,e),v(Tt.$$.fragment,e),v(He.$$.fragment,e),v(kt.$$.fragment,e),v(xt.$$.fragment,e),v(qt.$$.fragment,e),v(Dt.$$.fragment,e),Cr=!1},d(e){o(m),e&&o(x),e&&o(u),y(w),e&&o(Q),e&&o(F),e&&o(B),e&&o(A),e&&o(G),e&&o(L),y(I),e&&o(ae),e&&o(K),y(Be),e&&o(nr),e&&o(R),y(Ge),y(Ue),e&&o(sr),e&&o(W),y(Ke),y(Re),y(Le),e&&o(ar),e&&o(X),y(We),y(Xe),y(Ce),e&&o(ir),e&&o(pe),y(Je),e&&o(lr),e&&o(J),y(Ze),y(et),e&&o(dr),e&&o(Y),y(tt),y(ot),e&&o(cr),e&&o(fe),y(rt),e&&o(mr),e&&o(N),y(nt),y(Fe),e&&o(pr),e&&o(ue),y(st),e&&o(fr),e&&o(Z),y(it),e&&o(ur),e&&o(ee),y(lt),e&&o(hr),e&&o(te),y(dt),e&&o(gr),e&&o(he),y(ct),e&&o(_r),e&&o(oe),y(mt),e&&o(br),e&&o(V),y(pt),y(ft),e&&o(vr),e&&o(ge),y(gt),e&&o(yr),e&&o(_e),y(_t),e&&o($r),e&&o(re),y(bt),y(Ie),e&&o(wr),e&&o(ne),y(vt),y(Ne),e&&o(Tr),e&&o(be),y(yt),e&&o(kr),e&&o(ve),y($t),e&&o(xr),e&&o(ye),y(wt),e&&o(Er),e&&o(se),y(Tt),y(He),e&&o(qr),e&&o($e),y(kt),e&&o(Dr),e&&o(we),y(xt),e&&o(Lr),e&&o(j),y(qt),e&&o(Pr),e&&o(qe),y(Dt)}}}const Ri={local:"custom-layers-and-utilities",sections:[{local:"transformers.Conv1D",title:"Pytorch custom modules"},{local:"transformers.apply_chunking_to_forward",title:"PyTorch Helper Functions"},{local:"transformers.modeling_tf_utils.TFConv1D",title:"TensorFlow custom layers"},{local:"transformers.modeling_tf_utils.TFCausalLanguageModelingLoss",title:"TensorFlow loss functions"},{local:"transformers.modeling_tf_utils.get_initializer",title:"TensorFlow Helper Functions"}],title:"Custom Layers and Utilities"};function Wi(S){return Ii(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ol extends Si{constructor(m){super();Fi(this,m,Wi,Ki,Ai,{})}}export{ol as default,Ri as metadata};
