import{S as si,i as ai,s as ii,e as r,k as l,w as h,t as a,M as li,c as n,d as o,m as d,a as s,x as g,h as i,b as m,G as t,g as f,y as _,q as v,o as b,B as y,v as di,L as ci}from"../../chunks/vendor-hf-doc-builder.js";import{T as Zo}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}from"../../chunks/Docstring-hf-doc-builder.js";import{C as pi}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Gt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as fi}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function mi(F){let p,k,u,$,D,w,L,O,P,H,q,z,G,A,S,J,C;return{c(){p=r("p"),k=a("One of "),u=r("code"),$=a("start_states"),D=a(" or "),w=r("code"),L=a("start_positions"),O=a(" should be not "),P=r("code"),H=a("None"),q=a(". If both are set, "),z=r("code"),G=a("start_positions"),A=a(` overrides
`),S=r("code"),J=a("start_states"),C=a(".")},l(E){p=n(E,"P",{});var T=s(p);k=i(T,"One of "),u=n(T,"CODE",{});var I=s(u);$=i(I,"start_states"),I.forEach(o),D=i(T," or "),w=n(T,"CODE",{});var le=s(w);L=i(le,"start_positions"),le.forEach(o),O=i(T," should be not "),P=n(T,"CODE",{});var Q=s(P);H=i(Q,"None"),Q.forEach(o),q=i(T,". If both are set, "),z=n(T,"CODE",{});var de=s(z);G=i(de,"start_positions"),de.forEach(o),A=i(T,` overrides
`),S=n(T,"CODE",{});var se=s(S);J=i(se,"start_states"),se.forEach(o),C=i(T,"."),T.forEach(o)},m(E,T){f(E,p,T),t(p,k),t(p,u),t(u,$),t(p,D),t(p,w),t(w,L),t(p,O),t(p,P),t(P,H),t(p,q),t(p,z),t(z,G),t(p,A),t(p,S),t(S,J),t(p,C)},d(E){E&&o(p)}}}function ui(F){let p,k,u,$,D,w,L,O,P,H,q,z,G,A,S,J,C;return{c(){p=r("p"),k=a("One of "),u=r("code"),$=a("start_states"),D=a(" or "),w=r("code"),L=a("start_positions"),O=a(" should be not "),P=r("code"),H=a("None"),q=a(". If both are set, "),z=r("code"),G=a("start_positions"),A=a(` overrides
`),S=r("code"),J=a("start_states"),C=a(".")},l(E){p=n(E,"P",{});var T=s(p);k=i(T,"One of "),u=n(T,"CODE",{});var I=s(u);$=i(I,"start_states"),I.forEach(o),D=i(T," or "),w=n(T,"CODE",{});var le=s(w);L=i(le,"start_positions"),le.forEach(o),O=i(T," should be not "),P=n(T,"CODE",{});var Q=s(P);H=i(Q,"None"),Q.forEach(o),q=i(T,". If both are set, "),z=n(T,"CODE",{});var de=s(z);G=i(de,"start_positions"),de.forEach(o),A=i(T,` overrides
`),S=n(T,"CODE",{});var se=s(S);J=i(se,"start_states"),se.forEach(o),C=i(T,"."),T.forEach(o)},m(E,T){f(E,p,T),t(p,k),t(p,u),t(u,$),t(p,D),t(p,w),t(w,L),t(p,O),t(p,P),t(P,H),t(p,q),t(p,z),t(z,G),t(p,A),t(p,S),t(S,J),t(p,C)},d(E){E&&o(p)}}}function hi(F){let p,k,u,$,D;return $=new pi({props:{code:"JTIzJTIwcmVuYW1lJTIwdGhlJTIwdXN1YWwlMjBmb3J3YXJkKCklMjBmbiUyMHRvJTIwZm9yd2FyZF9jaHVuaygpJTBBZGVmJTIwZm9yd2FyZF9jaHVuayhzZWxmJTJDJTIwaGlkZGVuX3N0YXRlcyklM0ElMEElMjAlMjAlMjAlMjBoaWRkZW5fc3RhdGVzJTIwJTNEJTIwc2VsZi5kZWNvZGVyKGhpZGRlbl9zdGF0ZXMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaGlkZGVuX3N0YXRlcyUwQSUwQSUwQSUyMyUyMGltcGxlbWVudCUyMGElMjBjaHVua2VkJTIwZm9yd2FyZCUyMGZ1bmN0aW9uJTBBZGVmJTIwZm9yd2FyZChzZWxmJTJDJTIwaGlkZGVuX3N0YXRlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBhcHBseV9jaHVua2luZ190b19mb3J3YXJkKHNlbGYuZm9yd2FyZF9jaHVuayUyQyUyMHNlbGYuY2h1bmtfc2l6ZV9sbV9oZWFkJTJDJTIwc2VsZi5zZXFfbGVuX2RpbSUyQyUyMGhpZGRlbl9zdGF0ZXMp",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(){p=r("p"),k=a("Examples:"),u=l(),h($.$$.fragment)},l(w){p=n(w,"P",{});var L=s(p);k=i(L,"Examples:"),L.forEach(o),u=d(w),g($.$$.fragment,w)},m(w,L){f(w,p,L),t(p,k),f(w,u,L),_($,w,L),D=!0},p:ci,i(w){D||(v($.$$.fragment,w),D=!0)},o(w){b($.$$.fragment,w),D=!1},d(w){w&&o(p),w&&o(u),y($,w)}}}function gi(F){let p,k;return{c(){p=r("p"),k=a("Any label of -100 will be ignored (along with the corresponding logits) in the loss computation.")},l(u){p=n(u,"P",{});var $=s(p);k=i($,"Any label of -100 will be ignored (along with the corresponding logits) in the loss computation."),$.forEach(o)},m(u,$){f(u,p,$),t(p,k)},d(u){u&&o(p)}}}function _i(F){let p,k;return{c(){p=r("p"),k=a("Any label of -100 will be ignored (along with the corresponding logits) in the loss computation.")},l(u){p=n(u,"P",{});var $=s(p);k=i($,"Any label of -100 will be ignored (along with the corresponding logits) in the loss computation."),$.forEach(o)},m(u,$){f(u,p,$),t(p,k)},d(u){u&&o(p)}}}function vi(F){let p,k;return{c(){p=r("p"),k=a("Any label of -100 will be ignored (along with the corresponding logits) in the loss computation.")},l(u){p=n(u,"P",{});var $=s(p);k=i($,"Any label of -100 will be ignored (along with the corresponding logits) in the loss computation."),$.forEach(o)},m(u,$){f(u,p,$),t(p,k)},d(u){u&&o(p)}}}function bi(F){let p,k,u,$,D,w,L,O,P,H,q,z,G,A,S,J,C,E,T,I,le,Q,de,se,Z,je,Mr,Jt,Vr,jr,Qt,Hr,Bo,B,He,Gr,Zt,Jr,Qr,Tt,Ge,Uo,U,Je,Zr,Bt,Br,Ur,Ee,Qe,Rr,De,Ro,R,Ze,Xr,Ut,Kr,Wr,Le,Be,Yr,Ce,Xo,ce,Ue,en,Re,tn,kt,on,rn,Ko,X,Xe,nn,Rt,sn,an,xt,Ke,Wo,K,We,ln,Xt,dn,cn,Pe,Ye,pn,Kt,fn,Yo,pe,ze,Wt,et,mn,Yt,un,er,N,tt,hn,M,gn,eo,_n,vn,to,bn,yn,oo,$n,wn,ro,Tn,kn,xn,V,En,no,Dn,Ln,so,Cn,Pn,ao,zn,Sn,io,Fn,qn,An,Se,tr,fe,ot,On,rt,In,lo,Nn,Mn,or,W,nt,Vn,co,jn,Hn,po,Gn,rr,Y,st,Jn,fo,Qn,Zn,mo,Bn,nr,ee,at,Un,uo,Rn,Xn,ho,Kn,sr,me,Fe,go,it,Wn,_o,Yn,ar,te,lt,es,vo,ts,os,bo,rs,ir,ue,dt,ns,yo,ss,lr,he,qe,$o,ct,as,wo,is,dr,oe,pt,ls,To,ds,cs,Ae,cr,re,ft,ps,ko,fs,ms,Oe,pr,ge,mt,us,xo,hs,fr,_e,ut,gs,Eo,_s,mr,ve,ht,vs,Do,bs,ur,ne,gt,ys,Lo,$s,ws,Ie,hr,be,Ne,Co,_t,Ts,Po,ks,gr,ye,vt,xs,bt,Es,zo,Ds,Ls,_r,j,yt,Cs,So,Ps,zs,Fo,Ss,Fs,$e,we,qs,qo,As,Os,Ao,Is,Ns,Ms,Te,Vs,Oo,js,Hs,Io,Gs,Js,Qs,ke,Zs,No,Bs,Us,Mo,Rs,Xs,vr,xe,$t,Ks,Vo,Ws,br;return w=new Gt({}),I=new Gt({}),je=new x({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/v4.30.0/src/transformers/pytorch_utils.py#L83"}}),He=new x({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/v4.30.0/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/v4.30.0/src/transformers/modeling_utils.py#L3456"}}),Ge=new x({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/v4.30.0/src/transformers/modeling_utils.py#L3469",returnDescription:`
<p>The start logits for SQuAD.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Je=new x({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/v4.30.0/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/v4.30.0/src/transformers/modeling_utils.py#L3494"}}),Qe=new x({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/v4.30.0/src/transformers/modeling_utils.py#L3511",returnDescription:`
<p>The end logits for SQuAD.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),De=new Zo({props:{$$slots:{default:[mi]},$$scope:{ctx:F}}}),Ze=new x({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/v4.30.0/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/v4.30.0/src/transformers/modeling_utils.py#L3563"}}),Be=new x({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/v4.30.0/src/transformers/modeling_utils.py#L3578",returnDescription:`
<p>The SQuAD 2.0 answer class.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),Ce=new Zo({props:{$$slots:{default:[ui]},$$scope:{ctx:F}}}),Ue=new x({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/v4.30.0/src/transformers/modeling_utils.py#L3629"}}),Xe=new x({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/v4.30.0/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/v4.30.0/src/transformers/modeling_utils.py#L3659"}}),Ke=new x({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/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_utils.py#L3678",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/modeling_utils#transformers.modeling_utils.SquadHeadOutput"
>transformers.modeling_utils.SquadHeadOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),We=new x({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/v4.30.0/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/v4.30.0/src/transformers/modeling_utils.py#L3776"}}),Ye=new x({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/v4.30.0/src/transformers/modeling_utils.py#L3831",returnDescription:`
<p>The summary of the sequence hidden states.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),et=new Gt({}),tt=new x({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/v4.30.0/src/transformers/pytorch_utils.py#L165",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>
`}}),Se=new fi({props:{anchor:"transformers.apply_chunking_to_forward.example",$$slots:{default:[hi]},$$scope:{ctx:F}}}),ot=new x({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/v4.30.0/src/transformers/pytorch_utils.py#L240",returnDescription:`
<p>A tuple with the indices of heads to prune taking <code>already_pruned_heads</code>
into account and the indices of rows/columns to keep in the layer weight.</p>
`,returnType:`
<p><code>Tuple[Set[int], torch.LongTensor]</code></p>
`}}),nt=new x({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/v4.30.0/src/transformers/pytorch_utils.py#L141",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/v4.30.0/en/internal/modeling_utils#transformers.Conv1D"
>Conv1D</a></p>
`}}),st=new x({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/v4.30.0/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/v4.30.0/src/transformers/pytorch_utils.py#L108",returnDescription:`
<p>The pruned layer as a new layer with <code>requires_grad=True</code>.</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/internal/modeling_utils#transformers.Conv1D"
>Conv1D</a></p>
`}}),at=new x({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/v4.30.0/src/transformers/pytorch_utils.py#L49",returnDescription:`
<p>The pruned layer as a new layer with <code>requires_grad=True</code>.</p>
`,returnType:`
<p><code>torch.nn.Linear</code></p>
`}}),it=new Gt({}),lt=new x({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/v4.30.0/src/transformers/modeling_tf_utils.py#L3152"}}),dt=new x({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/v4.30.0/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/v4.30.0/src/transformers/modeling_tf_utils.py#L3295"}}),ct=new Gt({}),pt=new x({props:{name:"class transformers.modeling_tf_utils.TFCausalLanguageModelingLoss",anchor:"transformers.modeling_tf_utils.TFCausalLanguageModelingLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_tf_utils.py#L208"}}),Ae=new Zo({props:{$$slots:{default:[gi]},$$scope:{ctx:F}}}),ft=new x({props:{name:"class transformers.modeling_tf_utils.TFMaskedLanguageModelingLoss",anchor:"transformers.modeling_tf_utils.TFMaskedLanguageModelingLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_tf_utils.py#L327"}}),Oe=new Zo({props:{$$slots:{default:[_i]},$$scope:{ctx:F}}}),mt=new x({props:{name:"class transformers.modeling_tf_utils.TFMultipleChoiceLoss",anchor:"transformers.modeling_tf_utils.TFMultipleChoiceLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_tf_utils.py#L317"}}),ut=new x({props:{name:"class transformers.modeling_tf_utils.TFQuestionAnsweringLoss",anchor:"transformers.modeling_tf_utils.TFQuestionAnsweringLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_tf_utils.py#L239"}}),ht=new x({props:{name:"class transformers.modeling_tf_utils.TFSequenceClassificationLoss",anchor:"transformers.modeling_tf_utils.TFSequenceClassificationLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_tf_utils.py#L298"}}),gt=new x({props:{name:"class transformers.modeling_tf_utils.TFTokenClassificationLoss",anchor:"transformers.modeling_tf_utils.TFTokenClassificationLoss",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/modeling_tf_utils.py#L254"}}),Ie=new Zo({props:{$$slots:{default:[vi]},$$scope:{ctx:F}}}),_t=new Gt({}),vt=new x({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/v4.30.0/src/transformers/modeling_tf_utils.py#L3411",returnDescription:`
<p>The truncated normal initializer.</p>
`,returnType:`
<p><code>tf.keras.initializers.TruncatedNormal</code></p>
`}}),yt=new x({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/v4.30.0/src/transformers/modeling_tf_utils.py#L143",returnDescription:`
<p>The same class object, with modifications for Keras deserialization.</p>
`}}),$t=new x({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/v4.30.0/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(){p=r("meta"),k=l(),u=r("h1"),$=r("a"),D=r("span"),h(w.$$.fragment),L=l(),O=r("span"),P=a("Custom Layers and Utilities"),H=l(),q=r("p"),z=a("This page lists all the custom layers used by the library, as well as the utility functions it provides for modeling."),G=l(),A=r("p"),S=a("Most of those are only useful if you are studying the code of the models in the library."),J=l(),C=r("h2"),E=r("a"),T=r("span"),h(I.$$.fragment),le=l(),Q=r("span"),de=a("Pytorch custom modules"),se=l(),Z=r("div"),h(je.$$.fragment),Mr=l(),Jt=r("p"),Vr=a("1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),jr=l(),Qt=r("p"),Hr=a("Basically works like a linear layer but the weights are transposed."),Bo=l(),B=r("div"),h(He.$$.fragment),Gr=l(),Zt=r("p"),Jr=a("Compute SQuAD start logits from sequence hidden states."),Qr=l(),Tt=r("div"),h(Ge.$$.fragment),Uo=l(),U=r("div"),h(Je.$$.fragment),Zr=l(),Bt=r("p"),Br=a("Compute SQuAD end logits from sequence hidden states."),Ur=l(),Ee=r("div"),h(Qe.$$.fragment),Rr=l(),h(De.$$.fragment),Ro=l(),R=r("div"),h(Ze.$$.fragment),Xr=l(),Ut=r("p"),Kr=a("Compute SQuAD 2.0 answer class from classification and start tokens hidden states."),Wr=l(),Le=r("div"),h(Be.$$.fragment),Yr=l(),h(Ce.$$.fragment),Xo=l(),ce=r("div"),h(Ue.$$.fragment),en=l(),Re=r("p"),tn=a("Base class for outputs of question answering models using a "),kt=r("a"),on=a("SQuADHead"),rn=a("."),Ko=l(),X=r("div"),h(Xe.$$.fragment),nn=l(),Rt=r("p"),sn=a("A SQuAD head inspired by XLNet."),an=l(),xt=r("div"),h(Ke.$$.fragment),Wo=l(),K=r("div"),h(We.$$.fragment),ln=l(),Xt=r("p"),dn=a("Compute a single vector summary of a sequence hidden states."),cn=l(),Pe=r("div"),h(Ye.$$.fragment),pn=l(),Kt=r("p"),fn=a("Compute a single vector summary of a sequence hidden states."),Yo=l(),pe=r("h2"),ze=r("a"),Wt=r("span"),h(et.$$.fragment),mn=l(),Yt=r("span"),un=a("PyTorch Helper Functions"),er=l(),N=r("div"),h(tt.$$.fragment),hn=l(),M=r("p"),gn=a("This function chunks the "),eo=r("code"),_n=a("input_tensors"),vn=a(" into smaller input tensor parts of size "),to=r("code"),bn=a("chunk_size"),yn=a(` over the dimension
`),oo=r("code"),$n=a("chunk_dim"),wn=a(". It then applies a layer "),ro=r("code"),Tn=a("forward_fn"),kn=a(" to each chunk independently to save memory."),xn=l(),V=r("p"),En=a("If the "),no=r("code"),Dn=a("forward_fn"),Ln=a(" is independent across the "),so=r("code"),Cn=a("chunk_dim"),Pn=a(` this function will yield the same result as directly
applying `),ao=r("code"),zn=a("forward_fn"),Sn=a(" to "),io=r("code"),Fn=a("input_tensors"),qn=a("."),An=l(),h(Se.$$.fragment),tr=l(),fe=r("div"),h(ot.$$.fragment),On=l(),rt=r("p"),In=a("Finds the heads and their indices taking "),lo=r("code"),Nn=a("already_pruned_heads"),Mn=a(" into account."),or=l(),W=r("div"),h(nt.$$.fragment),Vn=l(),co=r("p"),jn=a("Prune a Conv1D or linear layer to keep only entries in index."),Hn=l(),po=r("p"),Gn=a("Used to remove heads."),rr=l(),Y=r("div"),h(st.$$.fragment),Jn=l(),fo=r("p"),Qn=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.`),Zn=l(),mo=r("p"),Bn=a("Used to remove heads."),nr=l(),ee=r("div"),h(at.$$.fragment),Un=l(),uo=r("p"),Rn=a("Prune a linear layer to keep only entries in index."),Xn=l(),ho=r("p"),Kn=a("Used to remove heads."),sr=l(),me=r("h2"),Fe=r("a"),go=r("span"),h(it.$$.fragment),Wn=l(),_o=r("span"),Yn=a("TensorFlow custom layers"),ar=l(),te=r("div"),h(lt.$$.fragment),es=l(),vo=r("p"),ts=a("1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),os=l(),bo=r("p"),rs=a("Basically works like a linear layer but the weights are transposed."),ir=l(),ue=r("div"),h(dt.$$.fragment),ns=l(),yo=r("p"),ss=a("Compute a single vector summary of a sequence hidden states."),lr=l(),he=r("h2"),qe=r("a"),$o=r("span"),h(ct.$$.fragment),as=l(),wo=r("span"),is=a("TensorFlow loss functions"),dr=l(),oe=r("div"),h(pt.$$.fragment),ls=l(),To=r("p"),ds=a("Loss function suitable for causal language modeling (CLM), that is, the task of guessing the next token."),cs=l(),h(Ae.$$.fragment),cr=l(),re=r("div"),h(ft.$$.fragment),ps=l(),ko=r("p"),fs=a("Loss function suitable for masked language modeling (MLM), that is, the task of guessing the masked tokens."),ms=l(),h(Oe.$$.fragment),pr=l(),ge=r("div"),h(mt.$$.fragment),us=l(),xo=r("p"),hs=a("Loss function suitable for multiple choice tasks."),fr=l(),_e=r("div"),h(ut.$$.fragment),gs=l(),Eo=r("p"),_s=a("Loss function suitable for question answering."),mr=l(),ve=r("div"),h(ht.$$.fragment),vs=l(),Do=r("p"),bs=a("Loss function suitable for sequence classification."),ur=l(),ne=r("div"),h(gt.$$.fragment),ys=l(),Lo=r("p"),$s=a("Loss function suitable for token classification."),ws=l(),h(Ie.$$.fragment),hr=l(),be=r("h2"),Ne=r("a"),Co=r("span"),h(_t.$$.fragment),Ts=l(),Po=r("span"),ks=a("TensorFlow Helper Functions"),gr=l(),ye=r("div"),h(vt.$$.fragment),xs=l(),bt=r("p"),Es=a("Creates a "),zo=r("code"),Ds=a("tf.keras.initializers.TruncatedNormal"),Ls=a(" with the given range."),_r=l(),j=r("div"),h(yt.$$.fragment),Cs=l(),So=r("p"),Ps=a("Decorate a Keras Layer class to support Keras serialization."),zs=l(),Fo=r("p"),Ss=a("This is done by:"),Fs=l(),$e=r("ol"),we=r("li"),qs=a("Adding a "),qo=r("code"),As=a("transformers_config"),Os=a(" dict to the Keras config dictionary in "),Ao=r("code"),Is=a("get_config"),Ns=a(` (called by Keras at
serialization time.`),Ms=l(),Te=r("li"),Vs=a("Wrapping "),Oo=r("code"),js=a("__init__"),Hs=a(" to accept that "),Io=r("code"),Gs=a("transformers_config"),Js=a(` dict (passed by Keras at deserialization time) and
convert it to a config object for the actual layer initializer.`),Qs=l(),ke=r("li"),Zs=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 `),No=r("code"),Bs=a("custom_objects"),Us=a(" in the call to "),Mo=r("code"),Rs=a("tf.keras.models.load_model"),Xs=a("."),vr=l(),xe=r("div"),h($t.$$.fragment),Ks=l(),Vo=r("p"),Ws=a("Deal with dynamic shape in tensorflow cleanly."),this.h()},l(e){const c=li('[data-svelte="svelte-1phssyn"]',document.head);p=n(c,"META",{name:!0,content:!0}),c.forEach(o),k=d(e),u=n(e,"H1",{class:!0});var wt=s(u);$=n(wt,"A",{id:!0,class:!0,href:!0});var jo=s($);D=n(jo,"SPAN",{});var Ho=s(D);g(w.$$.fragment,Ho),Ho.forEach(o),jo.forEach(o),L=d(wt),O=n(wt,"SPAN",{});var Go=s(O);P=i(Go,"Custom Layers and Utilities"),Go.forEach(o),wt.forEach(o),H=d(e),q=n(e,"P",{});var Jo=s(q);z=i(Jo,"This page lists all the custom layers used by the library, as well as the utility functions it provides for modeling."),Jo.forEach(o),G=d(e),A=n(e,"P",{});var Qo=s(A);S=i(Qo,"Most of those are only useful if you are studying the code of the models in the library."),Qo.forEach(o),J=d(e),C=n(e,"H2",{class:!0});var yr=s(C);E=n(yr,"A",{id:!0,class:!0,href:!0});var Ys=s(E);T=n(Ys,"SPAN",{});var ea=s(T);g(I.$$.fragment,ea),ea.forEach(o),Ys.forEach(o),le=d(yr),Q=n(yr,"SPAN",{});var ta=s(Q);de=i(ta,"Pytorch custom modules"),ta.forEach(o),yr.forEach(o),se=d(e),Z=n(e,"DIV",{class:!0});var Et=s(Z);g(je.$$.fragment,Et),Mr=d(Et),Jt=n(Et,"P",{});var oa=s(Jt);Vr=i(oa,"1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),oa.forEach(o),jr=d(Et),Qt=n(Et,"P",{});var ra=s(Qt);Hr=i(ra,"Basically works like a linear layer but the weights are transposed."),ra.forEach(o),Et.forEach(o),Bo=d(e),B=n(e,"DIV",{class:!0});var Dt=s(B);g(He.$$.fragment,Dt),Gr=d(Dt),Zt=n(Dt,"P",{});var na=s(Zt);Jr=i(na,"Compute SQuAD start logits from sequence hidden states."),na.forEach(o),Qr=d(Dt),Tt=n(Dt,"DIV",{class:!0});var sa=s(Tt);g(Ge.$$.fragment,sa),sa.forEach(o),Dt.forEach(o),Uo=d(e),U=n(e,"DIV",{class:!0});var Lt=s(U);g(Je.$$.fragment,Lt),Zr=d(Lt),Bt=n(Lt,"P",{});var aa=s(Bt);Br=i(aa,"Compute SQuAD end logits from sequence hidden states."),aa.forEach(o),Ur=d(Lt),Ee=n(Lt,"DIV",{class:!0});var $r=s(Ee);g(Qe.$$.fragment,$r),Rr=d($r),g(De.$$.fragment,$r),$r.forEach(o),Lt.forEach(o),Ro=d(e),R=n(e,"DIV",{class:!0});var Ct=s(R);g(Ze.$$.fragment,Ct),Xr=d(Ct),Ut=n(Ct,"P",{});var ia=s(Ut);Kr=i(ia,"Compute SQuAD 2.0 answer class from classification and start tokens hidden states."),ia.forEach(o),Wr=d(Ct),Le=n(Ct,"DIV",{class:!0});var wr=s(Le);g(Be.$$.fragment,wr),Yr=d(wr),g(Ce.$$.fragment,wr),wr.forEach(o),Ct.forEach(o),Xo=d(e),ce=n(e,"DIV",{class:!0});var Tr=s(ce);g(Ue.$$.fragment,Tr),en=d(Tr),Re=n(Tr,"P",{});var kr=s(Re);tn=i(kr,"Base class for outputs of question answering models using a "),kt=n(kr,"A",{href:!0});var la=s(kt);on=i(la,"SQuADHead"),la.forEach(o),rn=i(kr,"."),kr.forEach(o),Tr.forEach(o),Ko=d(e),X=n(e,"DIV",{class:!0});var Pt=s(X);g(Xe.$$.fragment,Pt),nn=d(Pt),Rt=n(Pt,"P",{});var da=s(Rt);sn=i(da,"A SQuAD head inspired by XLNet."),da.forEach(o),an=d(Pt),xt=n(Pt,"DIV",{class:!0});var ca=s(xt);g(Ke.$$.fragment,ca),ca.forEach(o),Pt.forEach(o),Wo=d(e),K=n(e,"DIV",{class:!0});var zt=s(K);g(We.$$.fragment,zt),ln=d(zt),Xt=n(zt,"P",{});var pa=s(Xt);dn=i(pa,"Compute a single vector summary of a sequence hidden states."),pa.forEach(o),cn=d(zt),Pe=n(zt,"DIV",{class:!0});var xr=s(Pe);g(Ye.$$.fragment,xr),pn=d(xr),Kt=n(xr,"P",{});var fa=s(Kt);fn=i(fa,"Compute a single vector summary of a sequence hidden states."),fa.forEach(o),xr.forEach(o),zt.forEach(o),Yo=d(e),pe=n(e,"H2",{class:!0});var Er=s(pe);ze=n(Er,"A",{id:!0,class:!0,href:!0});var ma=s(ze);Wt=n(ma,"SPAN",{});var ua=s(Wt);g(et.$$.fragment,ua),ua.forEach(o),ma.forEach(o),mn=d(Er),Yt=n(Er,"SPAN",{});var ha=s(Yt);un=i(ha,"PyTorch Helper Functions"),ha.forEach(o),Er.forEach(o),er=d(e),N=n(e,"DIV",{class:!0});var Me=s(N);g(tt.$$.fragment,Me),hn=d(Me),M=n(Me,"P",{});var ae=s(M);gn=i(ae,"This function chunks the "),eo=n(ae,"CODE",{});var ga=s(eo);_n=i(ga,"input_tensors"),ga.forEach(o),vn=i(ae," into smaller input tensor parts of size "),to=n(ae,"CODE",{});var _a=s(to);bn=i(_a,"chunk_size"),_a.forEach(o),yn=i(ae,` over the dimension
`),oo=n(ae,"CODE",{});var va=s(oo);$n=i(va,"chunk_dim"),va.forEach(o),wn=i(ae,". It then applies a layer "),ro=n(ae,"CODE",{});var ba=s(ro);Tn=i(ba,"forward_fn"),ba.forEach(o),kn=i(ae," to each chunk independently to save memory."),ae.forEach(o),xn=d(Me),V=n(Me,"P",{});var ie=s(V);En=i(ie,"If the "),no=n(ie,"CODE",{});var ya=s(no);Dn=i(ya,"forward_fn"),ya.forEach(o),Ln=i(ie," is independent across the "),so=n(ie,"CODE",{});var $a=s(so);Cn=i($a,"chunk_dim"),$a.forEach(o),Pn=i(ie,` this function will yield the same result as directly
applying `),ao=n(ie,"CODE",{});var wa=s(ao);zn=i(wa,"forward_fn"),wa.forEach(o),Sn=i(ie," to "),io=n(ie,"CODE",{});var Ta=s(io);Fn=i(Ta,"input_tensors"),Ta.forEach(o),qn=i(ie,"."),ie.forEach(o),An=d(Me),g(Se.$$.fragment,Me),Me.forEach(o),tr=d(e),fe=n(e,"DIV",{class:!0});var Dr=s(fe);g(ot.$$.fragment,Dr),On=d(Dr),rt=n(Dr,"P",{});var Lr=s(rt);In=i(Lr,"Finds the heads and their indices taking "),lo=n(Lr,"CODE",{});var ka=s(lo);Nn=i(ka,"already_pruned_heads"),ka.forEach(o),Mn=i(Lr," into account."),Lr.forEach(o),Dr.forEach(o),or=d(e),W=n(e,"DIV",{class:!0});var St=s(W);g(nt.$$.fragment,St),Vn=d(St),co=n(St,"P",{});var xa=s(co);jn=i(xa,"Prune a Conv1D or linear layer to keep only entries in index."),xa.forEach(o),Hn=d(St),po=n(St,"P",{});var Ea=s(po);Gn=i(Ea,"Used to remove heads."),Ea.forEach(o),St.forEach(o),rr=d(e),Y=n(e,"DIV",{class:!0});var Ft=s(Y);g(st.$$.fragment,Ft),Jn=d(Ft),fo=n(Ft,"P",{});var Da=s(fo);Qn=i(Da,`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.`),Da.forEach(o),Zn=d(Ft),mo=n(Ft,"P",{});var La=s(mo);Bn=i(La,"Used to remove heads."),La.forEach(o),Ft.forEach(o),nr=d(e),ee=n(e,"DIV",{class:!0});var qt=s(ee);g(at.$$.fragment,qt),Un=d(qt),uo=n(qt,"P",{});var Ca=s(uo);Rn=i(Ca,"Prune a linear layer to keep only entries in index."),Ca.forEach(o),Xn=d(qt),ho=n(qt,"P",{});var Pa=s(ho);Kn=i(Pa,"Used to remove heads."),Pa.forEach(o),qt.forEach(o),sr=d(e),me=n(e,"H2",{class:!0});var Cr=s(me);Fe=n(Cr,"A",{id:!0,class:!0,href:!0});var za=s(Fe);go=n(za,"SPAN",{});var Sa=s(go);g(it.$$.fragment,Sa),Sa.forEach(o),za.forEach(o),Wn=d(Cr),_o=n(Cr,"SPAN",{});var Fa=s(_o);Yn=i(Fa,"TensorFlow custom layers"),Fa.forEach(o),Cr.forEach(o),ar=d(e),te=n(e,"DIV",{class:!0});var At=s(te);g(lt.$$.fragment,At),es=d(At),vo=n(At,"P",{});var qa=s(vo);ts=i(qa,"1D-convolutional layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2)."),qa.forEach(o),os=d(At),bo=n(At,"P",{});var Aa=s(bo);rs=i(Aa,"Basically works like a linear layer but the weights are transposed."),Aa.forEach(o),At.forEach(o),ir=d(e),ue=n(e,"DIV",{class:!0});var Pr=s(ue);g(dt.$$.fragment,Pr),ns=d(Pr),yo=n(Pr,"P",{});var Oa=s(yo);ss=i(Oa,"Compute a single vector summary of a sequence hidden states."),Oa.forEach(o),Pr.forEach(o),lr=d(e),he=n(e,"H2",{class:!0});var zr=s(he);qe=n(zr,"A",{id:!0,class:!0,href:!0});var Ia=s(qe);$o=n(Ia,"SPAN",{});var Na=s($o);g(ct.$$.fragment,Na),Na.forEach(o),Ia.forEach(o),as=d(zr),wo=n(zr,"SPAN",{});var Ma=s(wo);is=i(Ma,"TensorFlow loss functions"),Ma.forEach(o),zr.forEach(o),dr=d(e),oe=n(e,"DIV",{class:!0});var Ot=s(oe);g(pt.$$.fragment,Ot),ls=d(Ot),To=n(Ot,"P",{});var Va=s(To);ds=i(Va,"Loss function suitable for causal language modeling (CLM), that is, the task of guessing the next token."),Va.forEach(o),cs=d(Ot),g(Ae.$$.fragment,Ot),Ot.forEach(o),cr=d(e),re=n(e,"DIV",{class:!0});var It=s(re);g(ft.$$.fragment,It),ps=d(It),ko=n(It,"P",{});var ja=s(ko);fs=i(ja,"Loss function suitable for masked language modeling (MLM), that is, the task of guessing the masked tokens."),ja.forEach(o),ms=d(It),g(Oe.$$.fragment,It),It.forEach(o),pr=d(e),ge=n(e,"DIV",{class:!0});var Sr=s(ge);g(mt.$$.fragment,Sr),us=d(Sr),xo=n(Sr,"P",{});var Ha=s(xo);hs=i(Ha,"Loss function suitable for multiple choice tasks."),Ha.forEach(o),Sr.forEach(o),fr=d(e),_e=n(e,"DIV",{class:!0});var Fr=s(_e);g(ut.$$.fragment,Fr),gs=d(Fr),Eo=n(Fr,"P",{});var Ga=s(Eo);_s=i(Ga,"Loss function suitable for question answering."),Ga.forEach(o),Fr.forEach(o),mr=d(e),ve=n(e,"DIV",{class:!0});var qr=s(ve);g(ht.$$.fragment,qr),vs=d(qr),Do=n(qr,"P",{});var Ja=s(Do);bs=i(Ja,"Loss function suitable for sequence classification."),Ja.forEach(o),qr.forEach(o),ur=d(e),ne=n(e,"DIV",{class:!0});var Nt=s(ne);g(gt.$$.fragment,Nt),ys=d(Nt),Lo=n(Nt,"P",{});var Qa=s(Lo);$s=i(Qa,"Loss function suitable for token classification."),Qa.forEach(o),ws=d(Nt),g(Ie.$$.fragment,Nt),Nt.forEach(o),hr=d(e),be=n(e,"H2",{class:!0});var Ar=s(be);Ne=n(Ar,"A",{id:!0,class:!0,href:!0});var Za=s(Ne);Co=n(Za,"SPAN",{});var Ba=s(Co);g(_t.$$.fragment,Ba),Ba.forEach(o),Za.forEach(o),Ts=d(Ar),Po=n(Ar,"SPAN",{});var Ua=s(Po);ks=i(Ua,"TensorFlow Helper Functions"),Ua.forEach(o),Ar.forEach(o),gr=d(e),ye=n(e,"DIV",{class:!0});var Or=s(ye);g(vt.$$.fragment,Or),xs=d(Or),bt=n(Or,"P",{});var Ir=s(bt);Es=i(Ir,"Creates a "),zo=n(Ir,"CODE",{});var Ra=s(zo);Ds=i(Ra,"tf.keras.initializers.TruncatedNormal"),Ra.forEach(o),Ls=i(Ir," with the given range."),Ir.forEach(o),Or.forEach(o),_r=d(e),j=n(e,"DIV",{class:!0});var Ve=s(j);g(yt.$$.fragment,Ve),Cs=d(Ve),So=n(Ve,"P",{});var Xa=s(So);Ps=i(Xa,"Decorate a Keras Layer class to support Keras serialization."),Xa.forEach(o),zs=d(Ve),Fo=n(Ve,"P",{});var Ka=s(Fo);Ss=i(Ka,"This is done by:"),Ka.forEach(o),Fs=d(Ve),$e=n(Ve,"OL",{});var Mt=s($e);we=n(Mt,"LI",{});var Vt=s(we);qs=i(Vt,"Adding a "),qo=n(Vt,"CODE",{});var Wa=s(qo);As=i(Wa,"transformers_config"),Wa.forEach(o),Os=i(Vt," dict to the Keras config dictionary in "),Ao=n(Vt,"CODE",{});var Ya=s(Ao);Is=i(Ya,"get_config"),Ya.forEach(o),Ns=i(Vt,` (called by Keras at
serialization time.`),Vt.forEach(o),Ms=d(Mt),Te=n(Mt,"LI",{});var jt=s(Te);Vs=i(jt,"Wrapping "),Oo=n(jt,"CODE",{});var ei=s(Oo);js=i(ei,"__init__"),ei.forEach(o),Hs=i(jt," to accept that "),Io=n(jt,"CODE",{});var ti=s(Io);Gs=i(ti,"transformers_config"),ti.forEach(o),Js=i(jt,` dict (passed by Keras at deserialization time) and
convert it to a config object for the actual layer initializer.`),jt.forEach(o),Qs=d(Mt),ke=n(Mt,"LI",{});var Ht=s(ke);Zs=i(Ht,`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 `),No=n(Ht,"CODE",{});var oi=s(No);Bs=i(oi,"custom_objects"),oi.forEach(o),Us=i(Ht," in the call to "),Mo=n(Ht,"CODE",{});var ri=s(Mo);Rs=i(ri,"tf.keras.models.load_model"),ri.forEach(o),Xs=i(Ht,"."),Ht.forEach(o),Mt.forEach(o),Ve.forEach(o),vr=d(e),xe=n(e,"DIV",{class:!0});var Nr=s(xe);g($t.$$.fragment,Nr),Ks=d(Nr),Vo=n(Nr,"P",{});var ni=s(Vo);Ws=i(ni,"Deal with dynamic shape in tensorflow cleanly."),ni.forEach(o),Nr.forEach(o),this.h()},h(){m(p,"name","hf:doc:metadata"),m(p,"content",JSON.stringify(yi)),m($,"id","custom-layers-and-utilities"),m($,"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"),m($,"href","#custom-layers-and-utilities"),m(u,"class","relative group"),m(E,"id","transformers.Conv1D"),m(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"),m(E,"href","#transformers.Conv1D"),m(C,"class","relative group"),m(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Tt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(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(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(kt,"href","/docs/transformers/v4.30.0/en/internal/modeling_utils#transformers.modeling_utils.SQuADHead"),m(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ze,"id","transformers.apply_chunking_to_forward"),m(ze,"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"),m(ze,"href","#transformers.apply_chunking_to_forward"),m(pe,"class","relative group"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(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(Fe,"id","transformers.modeling_tf_utils.TFConv1D"),m(Fe,"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"),m(Fe,"href","#transformers.modeling_tf_utils.TFConv1D"),m(me,"class","relative group"),m(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(qe,"id","transformers.modeling_tf_utils.TFCausalLanguageModelingLoss"),m(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"),m(qe,"href","#transformers.modeling_tf_utils.TFCausalLanguageModelingLoss"),m(he,"class","relative group"),m(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ge,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ne,"id","transformers.modeling_tf_utils.get_initializer"),m(Ne,"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"),m(Ne,"href","#transformers.modeling_tf_utils.get_initializer"),m(be,"class","relative group"),m(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(xe,"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,p),f(e,k,c),f(e,u,c),t(u,$),t($,D),_(w,D,null),t(u,L),t(u,O),t(O,P),f(e,H,c),f(e,q,c),t(q,z),f(e,G,c),f(e,A,c),t(A,S),f(e,J,c),f(e,C,c),t(C,E),t(E,T),_(I,T,null),t(C,le),t(C,Q),t(Q,de),f(e,se,c),f(e,Z,c),_(je,Z,null),t(Z,Mr),t(Z,Jt),t(Jt,Vr),t(Z,jr),t(Z,Qt),t(Qt,Hr),f(e,Bo,c),f(e,B,c),_(He,B,null),t(B,Gr),t(B,Zt),t(Zt,Jr),t(B,Qr),t(B,Tt),_(Ge,Tt,null),f(e,Uo,c),f(e,U,c),_(Je,U,null),t(U,Zr),t(U,Bt),t(Bt,Br),t(U,Ur),t(U,Ee),_(Qe,Ee,null),t(Ee,Rr),_(De,Ee,null),f(e,Ro,c),f(e,R,c),_(Ze,R,null),t(R,Xr),t(R,Ut),t(Ut,Kr),t(R,Wr),t(R,Le),_(Be,Le,null),t(Le,Yr),_(Ce,Le,null),f(e,Xo,c),f(e,ce,c),_(Ue,ce,null),t(ce,en),t(ce,Re),t(Re,tn),t(Re,kt),t(kt,on),t(Re,rn),f(e,Ko,c),f(e,X,c),_(Xe,X,null),t(X,nn),t(X,Rt),t(Rt,sn),t(X,an),t(X,xt),_(Ke,xt,null),f(e,Wo,c),f(e,K,c),_(We,K,null),t(K,ln),t(K,Xt),t(Xt,dn),t(K,cn),t(K,Pe),_(Ye,Pe,null),t(Pe,pn),t(Pe,Kt),t(Kt,fn),f(e,Yo,c),f(e,pe,c),t(pe,ze),t(ze,Wt),_(et,Wt,null),t(pe,mn),t(pe,Yt),t(Yt,un),f(e,er,c),f(e,N,c),_(tt,N,null),t(N,hn),t(N,M),t(M,gn),t(M,eo),t(eo,_n),t(M,vn),t(M,to),t(to,bn),t(M,yn),t(M,oo),t(oo,$n),t(M,wn),t(M,ro),t(ro,Tn),t(M,kn),t(N,xn),t(N,V),t(V,En),t(V,no),t(no,Dn),t(V,Ln),t(V,so),t(so,Cn),t(V,Pn),t(V,ao),t(ao,zn),t(V,Sn),t(V,io),t(io,Fn),t(V,qn),t(N,An),_(Se,N,null),f(e,tr,c),f(e,fe,c),_(ot,fe,null),t(fe,On),t(fe,rt),t(rt,In),t(rt,lo),t(lo,Nn),t(rt,Mn),f(e,or,c),f(e,W,c),_(nt,W,null),t(W,Vn),t(W,co),t(co,jn),t(W,Hn),t(W,po),t(po,Gn),f(e,rr,c),f(e,Y,c),_(st,Y,null),t(Y,Jn),t(Y,fo),t(fo,Qn),t(Y,Zn),t(Y,mo),t(mo,Bn),f(e,nr,c),f(e,ee,c),_(at,ee,null),t(ee,Un),t(ee,uo),t(uo,Rn),t(ee,Xn),t(ee,ho),t(ho,Kn),f(e,sr,c),f(e,me,c),t(me,Fe),t(Fe,go),_(it,go,null),t(me,Wn),t(me,_o),t(_o,Yn),f(e,ar,c),f(e,te,c),_(lt,te,null),t(te,es),t(te,vo),t(vo,ts),t(te,os),t(te,bo),t(bo,rs),f(e,ir,c),f(e,ue,c),_(dt,ue,null),t(ue,ns),t(ue,yo),t(yo,ss),f(e,lr,c),f(e,he,c),t(he,qe),t(qe,$o),_(ct,$o,null),t(he,as),t(he,wo),t(wo,is),f(e,dr,c),f(e,oe,c),_(pt,oe,null),t(oe,ls),t(oe,To),t(To,ds),t(oe,cs),_(Ae,oe,null),f(e,cr,c),f(e,re,c),_(ft,re,null),t(re,ps),t(re,ko),t(ko,fs),t(re,ms),_(Oe,re,null),f(e,pr,c),f(e,ge,c),_(mt,ge,null),t(ge,us),t(ge,xo),t(xo,hs),f(e,fr,c),f(e,_e,c),_(ut,_e,null),t(_e,gs),t(_e,Eo),t(Eo,_s),f(e,mr,c),f(e,ve,c),_(ht,ve,null),t(ve,vs),t(ve,Do),t(Do,bs),f(e,ur,c),f(e,ne,c),_(gt,ne,null),t(ne,ys),t(ne,Lo),t(Lo,$s),t(ne,ws),_(Ie,ne,null),f(e,hr,c),f(e,be,c),t(be,Ne),t(Ne,Co),_(_t,Co,null),t(be,Ts),t(be,Po),t(Po,ks),f(e,gr,c),f(e,ye,c),_(vt,ye,null),t(ye,xs),t(ye,bt),t(bt,Es),t(bt,zo),t(zo,Ds),t(bt,Ls),f(e,_r,c),f(e,j,c),_(yt,j,null),t(j,Cs),t(j,So),t(So,Ps),t(j,zs),t(j,Fo),t(Fo,Ss),t(j,Fs),t(j,$e),t($e,we),t(we,qs),t(we,qo),t(qo,As),t(we,Os),t(we,Ao),t(Ao,Is),t(we,Ns),t($e,Ms),t($e,Te),t(Te,Vs),t(Te,Oo),t(Oo,js),t(Te,Hs),t(Te,Io),t(Io,Gs),t(Te,Js),t($e,Qs),t($e,ke),t(ke,Zs),t(ke,No),t(No,Bs),t(ke,Us),t(ke,Mo),t(Mo,Rs),t(ke,Xs),f(e,vr,c),f(e,xe,c),_($t,xe,null),t(xe,Ks),t(xe,Vo),t(Vo,Ws),br=!0},p(e,[c]){const wt={};c&2&&(wt.$$scope={dirty:c,ctx:e}),De.$set(wt);const jo={};c&2&&(jo.$$scope={dirty:c,ctx:e}),Ce.$set(jo);const Ho={};c&2&&(Ho.$$scope={dirty:c,ctx:e}),Se.$set(Ho);const Go={};c&2&&(Go.$$scope={dirty:c,ctx:e}),Ae.$set(Go);const Jo={};c&2&&(Jo.$$scope={dirty:c,ctx:e}),Oe.$set(Jo);const Qo={};c&2&&(Qo.$$scope={dirty:c,ctx:e}),Ie.$set(Qo)},i(e){br||(v(w.$$.fragment,e),v(I.$$.fragment,e),v(je.$$.fragment,e),v(He.$$.fragment,e),v(Ge.$$.fragment,e),v(Je.$$.fragment,e),v(Qe.$$.fragment,e),v(De.$$.fragment,e),v(Ze.$$.fragment,e),v(Be.$$.fragment,e),v(Ce.$$.fragment,e),v(Ue.$$.fragment,e),v(Xe.$$.fragment,e),v(Ke.$$.fragment,e),v(We.$$.fragment,e),v(Ye.$$.fragment,e),v(et.$$.fragment,e),v(tt.$$.fragment,e),v(Se.$$.fragment,e),v(ot.$$.fragment,e),v(nt.$$.fragment,e),v(st.$$.fragment,e),v(at.$$.fragment,e),v(it.$$.fragment,e),v(lt.$$.fragment,e),v(dt.$$.fragment,e),v(ct.$$.fragment,e),v(pt.$$.fragment,e),v(Ae.$$.fragment,e),v(ft.$$.fragment,e),v(Oe.$$.fragment,e),v(mt.$$.fragment,e),v(ut.$$.fragment,e),v(ht.$$.fragment,e),v(gt.$$.fragment,e),v(Ie.$$.fragment,e),v(_t.$$.fragment,e),v(vt.$$.fragment,e),v(yt.$$.fragment,e),v($t.$$.fragment,e),br=!0)},o(e){b(w.$$.fragment,e),b(I.$$.fragment,e),b(je.$$.fragment,e),b(He.$$.fragment,e),b(Ge.$$.fragment,e),b(Je.$$.fragment,e),b(Qe.$$.fragment,e),b(De.$$.fragment,e),b(Ze.$$.fragment,e),b(Be.$$.fragment,e),b(Ce.$$.fragment,e),b(Ue.$$.fragment,e),b(Xe.$$.fragment,e),b(Ke.$$.fragment,e),b(We.$$.fragment,e),b(Ye.$$.fragment,e),b(et.$$.fragment,e),b(tt.$$.fragment,e),b(Se.$$.fragment,e),b(ot.$$.fragment,e),b(nt.$$.fragment,e),b(st.$$.fragment,e),b(at.$$.fragment,e),b(it.$$.fragment,e),b(lt.$$.fragment,e),b(dt.$$.fragment,e),b(ct.$$.fragment,e),b(pt.$$.fragment,e),b(Ae.$$.fragment,e),b(ft.$$.fragment,e),b(Oe.$$.fragment,e),b(mt.$$.fragment,e),b(ut.$$.fragment,e),b(ht.$$.fragment,e),b(gt.$$.fragment,e),b(Ie.$$.fragment,e),b(_t.$$.fragment,e),b(vt.$$.fragment,e),b(yt.$$.fragment,e),b($t.$$.fragment,e),br=!1},d(e){o(p),e&&o(k),e&&o(u),y(w),e&&o(H),e&&o(q),e&&o(G),e&&o(A),e&&o(J),e&&o(C),y(I),e&&o(se),e&&o(Z),y(je),e&&o(Bo),e&&o(B),y(He),y(Ge),e&&o(Uo),e&&o(U),y(Je),y(Qe),y(De),e&&o(Ro),e&&o(R),y(Ze),y(Be),y(Ce),e&&o(Xo),e&&o(ce),y(Ue),e&&o(Ko),e&&o(X),y(Xe),y(Ke),e&&o(Wo),e&&o(K),y(We),y(Ye),e&&o(Yo),e&&o(pe),y(et),e&&o(er),e&&o(N),y(tt),y(Se),e&&o(tr),e&&o(fe),y(ot),e&&o(or),e&&o(W),y(nt),e&&o(rr),e&&o(Y),y(st),e&&o(nr),e&&o(ee),y(at),e&&o(sr),e&&o(me),y(it),e&&o(ar),e&&o(te),y(lt),e&&o(ir),e&&o(ue),y(dt),e&&o(lr),e&&o(he),y(ct),e&&o(dr),e&&o(oe),y(pt),y(Ae),e&&o(cr),e&&o(re),y(ft),y(Oe),e&&o(pr),e&&o(ge),y(mt),e&&o(fr),e&&o(_e),y(ut),e&&o(mr),e&&o(ve),y(ht),e&&o(ur),e&&o(ne),y(gt),y(Ie),e&&o(hr),e&&o(be),y(_t),e&&o(gr),e&&o(ye),y(vt),e&&o(_r),e&&o(j),y(yt),e&&o(vr),e&&o(xe),y($t)}}}const yi={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 $i(F){return di(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Li extends si{constructor(p){super();ai(this,p,$i,bi,ii,{})}}export{Li as default,yi as metadata};
