import{S as Ju,i as Gu,s as Ku,e as r,k as d,w as _,t as n,M as Zu,c as a,d as o,m as c,a as i,x as b,h as s,b as l,F as e,g as u,y as k,q as Q,o as v,B as w}from"../../chunks/vendor-4833417e.js";import{T as ut}from"../../chunks/Tip-fffd6df1.js";import{D as E}from"../../chunks/Docstring-4f315ed9.js";import{C as Z}from"../../chunks/CodeBlock-6a3d1b46.js";import{I as K}from"../../chunks/IconCopyLink-4b81c553.js";import"../../chunks/CopyButton-dacfbfaf.js";function Yu(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function em(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function tm(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function om(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function nm(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function sm(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function rm(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function am(D){let h,y,m,T,q;return{c(){h=r("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=r("code"),T=n("Module"),q=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(g){h=a(g,"P",{});var f=i(h);y=s(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(f,"CODE",{});var $=i(m);T=s($,"Module"),$.forEach(o),q=s(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(g,f){u(g,h,f),e(h,y),e(h,m),e(m,T),e(h,q)},d(g){g&&o(h)}}}function im(D){let h,y,m,T,q,g,f,$,ka,Ys,_e,Ie,Bn,mt,Qa,Mn,va,er,Oe,wa,ft,Ta,ya,tr,Ro,qa,or,Uo,En,$a,nr,Vo,Da,sr,Y,xn,Fn,za,Ba,jn,We,Ma,gt,Ea,xa,Pn,Fa,ja,Cn,_t,Pa,An,Ca,Aa,Na,Nn,bt,Sa,Xo,La,Ia,rr,He,Oa,kt,Wa,Ha,ar,be,Re,Sn,Qt,Ra,Ln,Ua,ir,x,Va,In,Xa,Ja,vt,Ga,Ka,On,Za,Ya,Wn,ei,ti,wt,oi,ni,lr,Ue,si,Hn,ri,ai,dr,Jo,ii,cr,Tt,pr,ke,Ve,Rn,yt,li,Un,di,hr,Go,ci,ur,qt,mr,Qe,Xe,Vn,$t,pi,Xn,hi,fr,te,ui,Dt,mi,fi,zt,gi,_i,gr,Bt,_r,ve,Je,Jn,Mt,bi,Gn,ki,br,F,Et,Qi,we,vi,Ko,wi,Ti,xt,yi,qi,$i,Te,Di,Zo,zi,Bi,Yo,Mi,Ei,xi,Kn,Fi,ji,Ft,kr,ye,Ge,Zn,jt,Pi,Yn,Ci,Qr,z,Pt,Ai,es,Ni,Si,Ct,Li,en,Ii,Oi,Wi,At,Hi,Nt,Ri,Ui,Vi,St,Xi,Lt,Ji,Gi,Ki,M,Zi,ts,Yi,el,os,tl,ol,ns,nl,sl,ss,rl,al,rs,il,ll,as,dl,cl,pl,I,It,hl,qe,ul,tn,ml,fl,is,gl,_l,bl,Ke,kl,ls,Ql,vl,Ot,vr,$e,Ze,ds,Wt,wl,cs,Tl,wr,j,Ht,yl,Rt,ql,ps,$l,Dl,zl,Ut,Bl,on,Ml,El,xl,Vt,Fl,Xt,jl,Pl,Cl,O,Jt,Al,De,Nl,nn,Sl,Ll,hs,Il,Ol,Wl,Ye,Hl,us,Rl,Ul,Gt,Tr,ze,et,ms,Kt,Vl,fs,Xl,yr,P,Zt,Jl,Yt,Gl,gs,Kl,Zl,Yl,eo,ed,sn,td,od,nd,to,sd,oo,rd,ad,id,W,no,ld,Be,dd,rn,cd,pd,_s,hd,ud,md,tt,fd,bs,gd,_d,so,qr,Me,ot,ks,ro,bd,Qs,kd,$r,C,ao,Qd,vs,vd,wd,io,Td,an,yd,qd,$d,lo,Dd,co,zd,Bd,Md,B,po,Ed,Ee,xd,ln,Fd,jd,ws,Pd,Cd,Ad,nt,Nd,Ts,Sd,Ld,ho,Id,ys,Od,Wd,uo,Dr,xe,st,qs,mo,Hd,$s,Rd,zr,A,fo,Ud,go,Vd,Ds,Xd,Jd,Gd,_o,Kd,dn,Zd,Yd,ec,bo,tc,ko,oc,nc,sc,H,Qo,rc,Fe,ac,cn,ic,lc,zs,dc,cc,pc,rt,hc,Bs,uc,mc,vo,Br,je,at,Ms,wo,fc,Es,gc,Mr,N,To,_c,xs,bc,kc,yo,Qc,pn,vc,wc,Tc,qo,yc,$o,qc,$c,Dc,R,Do,zc,Pe,Bc,hn,Mc,Ec,Fs,xc,Fc,jc,it,Pc,js,Cc,Ac,zo,Er,Ce,lt,Ps,Bo,Nc,Cs,Sc,xr,S,Mo,Lc,As,Ic,Oc,Eo,Wc,un,Hc,Rc,Uc,xo,Vc,Fo,Xc,Jc,Gc,U,jo,Kc,Ae,Zc,mn,Yc,ep,Ns,tp,op,np,dt,sp,Ss,rp,ap,Po,Fr,Ne,ct,Ls,Co,ip,Is,lp,jr,L,Ao,dp,Se,cp,Os,pp,hp,Ws,up,mp,fp,No,gp,fn,_p,bp,kp,So,Qp,Lo,vp,wp,Tp,V,Io,yp,Le,qp,gn,$p,Dp,Hs,zp,Bp,Mp,pt,Ep,Rs,xp,Fp,Oo,Pr;return g=new K({}),mt=new K({}),Qt=new K({}),Tt=new Z({props:{code:`import pytorch_quantization.nn as quant_nn
from pytorch_quantization.tensor_quant import QuantDescriptor

# The default tensor quantizer is set to use Max calibration method
input_desc = QuantDescriptor(num_bits=8, calib_method="max")
# The default tensor quantizer is set to be per-channel quantization for weights
weight_desc = QuantDescriptor(num_bits=8, axis=((0,)))
quant_nn.QuantLinear.set_default_quant_desc_input(input_desc)
quant_nn.QuantLinear.set_default_quant_desc_weight(weight_desc)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> pytorch_quantization.nn <span class="hljs-keyword">as</span> quant_nn
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pytorch_quantization.tensor_quant <span class="hljs-keyword">import</span> QuantDescriptor

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># The default tensor quantizer is set to use Max calibration method</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_desc = QuantDescriptor(num_bits=<span class="hljs-number">8</span>, calib_method=<span class="hljs-string">&quot;max&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># The default tensor quantizer is set to be per-channel quantization for weights</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>weight_desc = QuantDescriptor(num_bits=<span class="hljs-number">8</span>, axis=((<span class="hljs-number">0</span>,)))
<span class="hljs-meta">&gt;&gt;&gt; </span>quant_nn.QuantLinear.set_default_quant_desc_input(input_desc)
<span class="hljs-meta">&gt;&gt;&gt; </span>quant_nn.QuantLinear.set_default_quant_desc_weight(weight_desc)`}}),yt=new K({}),qt=new Z({props:{code:`# Find the TensorQuantizer and enable calibration
for name, module in model.named_modules():
    if name.endswith("_input_quantizer"):
        module.enable_calib()
        module.disable_quant()  # Use full precision data to calibrate

# Feeding data samples
model(x)
# ...

# Finalize calibration
for name, module in model.named_modules():
    if name.endswith("_input_quantizer"):
        module.load_calib_amax()
        module.enable_quant()

# If running on GPU, it needs to call .cuda() again because new tensors will be created by calibration process
model.cuda()

# Keep running the quantized model
# ...`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Find the TensorQuantizer and enable calibration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> name, module <span class="hljs-keyword">in</span> model.named_modules():
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> name.endswith(<span class="hljs-string">&quot;_input_quantizer&quot;</span>):
<span class="hljs-meta">... </span>        module.enable_calib()
<span class="hljs-meta">... </span>        module.disable_quant()  <span class="hljs-comment"># Use full precision data to calibrate</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Feeding data samples</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model(x)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># ...</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Finalize calibration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> name, module <span class="hljs-keyword">in</span> model.named_modules():
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> name.endswith(<span class="hljs-string">&quot;_input_quantizer&quot;</span>):
<span class="hljs-meta">... </span>        module.load_calib_amax()
<span class="hljs-meta">... </span>        module.enable_quant()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If running on GPU, it needs to call .cuda() again because new tensors will be created by calibration process</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.cuda()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Keep running the quantized model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># ...</span>`}}),$t=new K({}),Bt=new Z({props:{code:`from pytorch_quantization.nn import TensorQuantizer

TensorQuantizer.use_fb_fake_quant = True

# Load the calibrated model
...
# ONNX export
torch.onnx.export(...)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pytorch_quantization.nn <span class="hljs-keyword">import</span> TensorQuantizer

<span class="hljs-meta">&gt;&gt;&gt; </span>TensorQuantizer.use_fb_fake_quant = <span class="hljs-literal">True</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Load the calibrated model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>...
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># ONNX export</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>torch.onnx.export(...)`}}),Mt=new K({}),Et=new E({props:{name:"class transformers.QDQBertConfig",anchor:"transformers.QDQBertConfig",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 512"},{name:"type_vocab_size",val:" = 2"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"use_cache",val:" = True"},{name:"is_encoder_decoder",val:" = False"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/configuration_qdqbert.py#L29",parametersDescription:[{anchor:"transformers.QDQBertConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the QDQBERT model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertModel">QDQBertModel</a>.`,name:"vocab_size"},{anchor:"transformers.QDQBertConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimension of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.QDQBertConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.QDQBertConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.QDQBertConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.QDQBertConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.QDQBertConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.QDQBertConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.QDQBertConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.QDQBertConfig.type_vocab_size",description:`<strong>type_vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The vocabulary size of the <code>token_type_ids</code> passed when calling <a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertModel">QDQBertModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.QDQBertConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.QDQBertConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.QDQBertConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"}]}}),Ft=new Z({props:{code:`from transformers import QDQBertModel, QDQBertConfig

# Initializing a QDQBERT bert-base-uncased style configuration
configuration = QDQBertConfig()

# Initializing a model from the bert-base-uncased style configuration
model = QDQBertModel(configuration)

# Accessing the model configuration
configuration = model.config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> QDQBertModel, QDQBertConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a QDQBERT bert-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = QDQBertConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the bert-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),jt=new K({}),Pt=new E({props:{name:"class transformers.QDQBertModel",anchor:"transformers.QDQBertModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L831",parametersDescription:[{anchor:"transformers.QDQBertModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),It=new E({props:{name:"forward",anchor:"transformers.QDQBertModel.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"past_key_values",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L871",parametersDescription:[{anchor:"transformers.QDQBertModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.QDQBertModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.QDQBertModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.QDQBertModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ke=new ut({props:{$$slots:{default:[Yu]},$$scope:{ctx:D}}}),Ot=new Z({props:{code:`from transformers import BertTokenizer, QDQBertModel
import torch

tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertModel.from_pretrained("bert-base-uncased")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),Wt=new K({}),Ht=new E({props:{name:"class transformers.QDQBertLMHeadModel",anchor:"transformers.QDQBertLMHeadModel",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1012",parametersDescription:[{anchor:"transformers.QDQBertLMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Jt=new E({props:{name:"forward",anchor:"transformers.QDQBertLMHeadModel.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"labels",val:" = None"},{name:"past_key_values",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1035",parametersDescription:[{anchor:"transformers.QDQBertLMHeadModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertLMHeadModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertLMHeadModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertLMHeadModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertLMHeadModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertLMHeadModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertLMHeadModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertLMHeadModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertLMHeadModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertLMHeadModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.QDQBertLMHeadModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.QDQBertLMHeadModel.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
<code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are
ignored (masked), the loss is only computed for the tokens with labels n <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.QDQBertLMHeadModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.QDQBertLMHeadModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ye=new ut({props:{$$slots:{default:[em]},$$scope:{ctx:D}}}),Gt=new Z({props:{code:`from transformers import BertTokenizer, QDQBertLMHeadModel, QDQBertConfig
import torch

tokenizer = BertTokenizer.from_pretrained("bert-base-cased")
config = QDQBertConfig.from_pretrained("bert-base-cased")
config.is_decoder = True
model = QDQBertLMHeadModel.from_pretrained("bert-base-cased", config=config)

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)

prediction_logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertLMHeadModel, QDQBertConfig
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>config = QDQBertConfig.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>config.is_decoder = <span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertLMHeadModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, config=config)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>prediction_logits = outputs.logits`}}),Kt=new K({}),Zt=new E({props:{name:"class transformers.QDQBertForMaskedLM",anchor:"transformers.QDQBertForMaskedLM",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1160",parametersDescription:[{anchor:"transformers.QDQBertForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),no=new E({props:{name:"forward",anchor:"transformers.QDQBertForMaskedLM.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"labels",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1186",parametersDescription:[{anchor:"transformers.QDQBertForMaskedLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertForMaskedLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertForMaskedLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertForMaskedLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertForMaskedLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertForMaskedLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertForMaskedLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertForMaskedLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertForMaskedLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertForMaskedLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Masked language modeling (MLM) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),tt=new ut({props:{$$slots:{default:[tm]},$$scope:{ctx:D}}}),so=new Z({props:{code:`from transformers import BertTokenizer, QDQBertForMaskedLM
import torch

tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForMaskedLM.from_pretrained("bert-base-uncased")

inputs = tokenizer("The capital of France is [MASK].", return_tensors="pt")
labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]

outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForMaskedLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;The capital of France is [MASK].&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;The capital of France is Paris.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),ro=new K({}),ao=new E({props:{name:"class transformers.QDQBertForSequenceClassification",anchor:"transformers.QDQBertForSequenceClassification",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1374",parametersDescription:[{anchor:"transformers.QDQBertForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),po=new E({props:{name:"forward",anchor:"transformers.QDQBertForSequenceClassification.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"labels",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1386",parametersDescription:[{anchor:"transformers.QDQBertForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertForSequenceClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertForSequenceClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertForSequenceClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertForSequenceClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertForSequenceClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),nt=new ut({props:{$$slots:{default:[om]},$$scope:{ctx:D}}}),ho=new Z({props:{code:`import torch
from transformers import BertTokenizer, QDQBertForSequenceClassification

torch.manual_seed(0)
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=2)

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([1]).unsqueeze(0)  # Batch size 1
outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits
list(logits.shape)
`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>]).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)
`}}),uo=new Z({props:{code:`import torch
from transformers import BertTokenizer, QDQBertForSequenceClassification

torch.manual_seed(0)
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForSequenceClassification.from_pretrained("bert-base-uncased", problem_type="multi_label_classification", num_labels=2)

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([[1, 1]], dtype=torch.float)  # need dtype=float for BCEWithLogitsLoss
outputs = model(**inputs, labels=labels)
loss = outputs.loss
list(logits.shape)
`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>, num_labels=<span class="hljs-number">2</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>]], dtype=torch.<span class="hljs-built_in">float</span>)  <span class="hljs-comment"># need dtype=float for BCEWithLogitsLoss</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)
`}}),mo=new K({}),fo=new E({props:{name:"class transformers.QDQBertForNextSentencePrediction",anchor:"transformers.QDQBertForNextSentencePrediction",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1271",parametersDescription:[{anchor:"transformers.QDQBertForNextSentencePrediction.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Qo=new E({props:{name:"forward",anchor:"transformers.QDQBertForNextSentencePrediction.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"labels",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1281",parametersDescription:[{anchor:"transformers.QDQBertForNextSentencePrediction.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertForNextSentencePrediction.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair
(see <code>input_ids</code> docstring). Indices should be in <code>[0, 1]</code>:</p>
<ul>
<li>0 indicates sequence B is a continuation of sequence A,</li>
<li>1 indicates sequence B is a random sequence.</li>
</ul>`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>next_sentence_label</code> is provided) \u2014 Next sequence prediction (classification) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, 2)</code>) \u2014 Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),rt=new ut({props:{$$slots:{default:[nm]},$$scope:{ctx:D}}}),vo=new Z({props:{code:`from transformers import BertTokenizer, QDQBertForNextSentencePrediction
import torch

tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForNextSentencePrediction.from_pretrained("bert-base-uncased")

prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced."
next_sentence = "The sky is blue due to the shorter wavelength of blue light."
encoding = tokenizer(prompt, next_sentence, return_tensors="pt")

outputs = model(**encoding, labels=torch.LongTensor([1]))
logits = outputs.logits
assert logits[0, 0] < logits[0, 1]  # next sentence was random`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForNextSentencePrediction
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForNextSentencePrediction.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>next_sentence = <span class="hljs-string">&quot;The sky is blue due to the shorter wavelength of blue light.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(prompt, next_sentence, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, labels=torch.LongTensor([<span class="hljs-number">1</span>]))
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">assert</span> logits[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>] &lt; logits[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]  <span class="hljs-comment"># next sentence was random</span>`}}),wo=new K({}),To=new E({props:{name:"class transformers.QDQBertForMultipleChoice",anchor:"transformers.QDQBertForMultipleChoice",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1472",parametersDescription:[{anchor:"transformers.QDQBertForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Do=new E({props:{name:"forward",anchor:"transformers.QDQBertForMultipleChoice.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"labels",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1483",parametersDescription:[{anchor:"transformers.QDQBertForMultipleChoice.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertForMultipleChoice.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertForMultipleChoice.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertForMultipleChoice.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertForMultipleChoice.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertForMultipleChoice.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertForMultipleChoice.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertForMultipleChoice.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertForMultipleChoice.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertForMultipleChoice.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the multiple choice classification loss. Indices should be in <code>[0, ..., num_choices-1]</code> where <code>num_choices</code> is the size of the second dimension of the input tensors. (See
<code>input_ids</code> above)`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <em>(1,)</em>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 <em>num_choices</em> is the second dimension of the input tensors. (see <em>input_ids</em> above).</p>
<p>Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),it=new ut({props:{$$slots:{default:[sm]},$$scope:{ctx:D}}}),zo=new Z({props:{code:`from transformers import BertTokenizer, QDQBertForMultipleChoice
import torch

tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForMultipleChoice.from_pretrained("bert-base-uncased")

prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced."
choice0 = "It is eaten with a fork and a knife."
choice1 = "It is eaten while held in the hand."
labels = torch.tensor(0).unsqueeze(0)  # choice0 is correct (according to Wikipedia ;)), batch size 1

encoding = tokenizer([prompt, prompt], [choice0, choice1], return_tensors="pt", padding=True)
outputs = model(**{k: v.unsqueeze(0) for k, v in encoding.items()}, labels=labels)  # batch size is 1

# the linear classifier still needs to be trained
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForMultipleChoice
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>choice0 = <span class="hljs-string">&quot;It is eaten with a fork and a knife.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>choice1 = <span class="hljs-string">&quot;It is eaten while held in the hand.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor(<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># choice0 is correct (according to Wikipedia ;)), batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer([prompt, prompt], [choice0, choice1], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**{k: v.unsqueeze(<span class="hljs-number">0</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> encoding.items()}, labels=labels)  <span class="hljs-comment"># batch size is 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the linear classifier still needs to be trained</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Bo=new K({}),Mo=new E({props:{name:"class transformers.QDQBertForTokenClassification",anchor:"transformers.QDQBertForTokenClassification",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1564",parametersDescription:[{anchor:"transformers.QDQBertForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),jo=new E({props:{name:"forward",anchor:"transformers.QDQBertForTokenClassification.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"labels",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1579",parametersDescription:[{anchor:"transformers.QDQBertForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertForTokenClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertForTokenClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertForTokenClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertForTokenClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertForTokenClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertForTokenClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertForTokenClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the token classification loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>.`,name:"labels"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided)  \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),dt=new ut({props:{$$slots:{default:[rm]},$$scope:{ctx:D}}}),Po=new Z({props:{code:`from transformers import BertTokenizer, QDQBertForTokenClassification
import torch

tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForTokenClassification.from_pretrained("bert-base-uncased")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([1] * inputs["input_ids"].size(1)).unsqueeze(0)  # Batch size 1

outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForTokenClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>] * inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].size(<span class="hljs-number">1</span>)).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),Co=new K({}),Ao=new E({props:{name:"class transformers.QDQBertForQuestionAnswering",anchor:"transformers.QDQBertForQuestionAnswering",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1646",parametersDescription:[{anchor:"transformers.QDQBertForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig">QDQBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]}}),Io=new E({props:{name:"forward",anchor:"transformers.QDQBertForQuestionAnswering.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"token_type_ids",val:" = None"},{name:"position_ids",val:" = None"},{name:"head_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"start_positions",val:" = None"},{name:"end_positions",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],source:"https://github.com/huggingface/transformers/blob/pr_15839/src/transformers/models/qdqbert/modeling_qdqbert.py#L1660",parametersDescription:[{anchor:"transformers.QDQBertForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/pr_15839/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a>. See <a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/pr_15839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/pr_15839/en/main_classes/output#transformers.file_utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.QDQBertForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],returnDescription:`
<p>A <a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</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 (<a
  href="/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertConfig"
>QDQBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/pr_15839/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),pt=new ut({props:{$$slots:{default:[am]},$$scope:{ctx:D}}}),Oo=new Z({props:{code:`from transformers import BertTokenizer, QDQBertForQuestionAnswering
import torch

torch.manual_seed(0)
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = QDQBertForQuestionAnswering.from_pretrained("bert-base-uncased")

question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
inputs = tokenizer(question, text, return_tensors="pt")
start_positions = torch.tensor([1])
end_positions = torch.tensor([3])

outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
loss = outputs.loss
round(loss.item(), 2)


start_scores = outputs.start_logits
list(start_scores.shape)


end_scores = outputs.end_logits
list(end_scores.shape)
`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, QDQBertForQuestionAnswering
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = QDQBertForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>question, text = <span class="hljs-string">&quot;Who was Jim Henson?&quot;</span>, <span class="hljs-string">&quot;Jim Henson was a nice puppet&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>start_positions = torch.tensor([<span class="hljs-number">1</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>end_positions = torch.tensor([<span class="hljs-number">3</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>start_scores = outputs.start_logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(start_scores.shape)


<span class="hljs-meta">&gt;&gt;&gt; </span>end_scores = outputs.end_logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(end_scores.shape)
`}}),{c(){h=r("meta"),y=d(),m=r("h1"),T=r("a"),q=r("span"),_(g.$$.fragment),f=d(),$=r("span"),ka=n("QDQBERT"),Ys=d(),_e=r("h2"),Ie=r("a"),Bn=r("span"),_(mt.$$.fragment),Qa=d(),Mn=r("span"),va=n("Overview"),er=d(),Oe=r("p"),wa=n("The QDQBERT model can be referenced in "),ft=r("a"),Ta=n(`Integer Quantization for Deep Learning Inference: Principles and Empirical
Evaluation`),ya=n(` by Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius
Micikevicius.`),tr=d(),Ro=r("p"),qa=n("The abstract from the paper is the following:"),or=d(),Uo=r("p"),En=r("em"),$a=n(`Quantization techniques can reduce the size of Deep Neural Networks and improve inference latency and throughput by
taking advantage of high throughput integer instructions. In this paper we review the mathematical aspects of
quantization parameters and evaluate their choices on a wide range of neural network models for different application
domains, including vision, speech, and language. We focus on quantization techniques that are amenable to acceleration
by processors with high-throughput integer math pipelines. We also present a workflow for 8-bit quantization that is
able to maintain accuracy within 1% of the floating-point baseline on all networks studied, including models that are
more difficult to quantize, such as MobileNets and BERT-large.`),nr=d(),Vo=r("p"),Da=n("Tips:"),sr=d(),Y=r("ul"),xn=r("li"),Fn=r("p"),za=n(`QDQBERT model adds fake quantization operations (pair of QuantizeLinear/DequantizeLinear ops) to (i) linear layer
inputs and weights, (ii) matmul inputs, (iii) residual add inputs, in BERT model.`),Ba=d(),jn=r("li"),We=r("p"),Ma=n("QDQBERT requires the dependency of "),gt=r("a"),Ea=n("Pytorch Quantization Toolkit"),xa=n(". To install "),Pn=r("code"),Fa=n("pip install pytorch-quantization --extra-index-url https://pypi.ngc.nvidia.com"),ja=d(),Cn=r("li"),_t=r("p"),Pa=n("QDQBERT model can be loaded from any checkpoint of HuggingFace BERT model (for example "),An=r("em"),Ca=n("bert-base-uncased"),Aa=n(`), and
perform Quantization Aware Training/Post Training Quantization.`),Na=d(),Nn=r("li"),bt=r("p"),Sa=n(`A complete example of using QDQBERT model to perform Quatization Aware Training and Post Training Quantization for
SQUAD task can be found at `),Xo=r("a"),La=n("transformers/examples/research_projects/quantization-qdqbert/"),Ia=n("."),rr=d(),He=r("p"),Oa=n("This model was contributed by "),kt=r("a"),Wa=n("shangz"),Ha=n("."),ar=d(),be=r("h3"),Re=r("a"),Sn=r("span"),_(Qt.$$.fragment),Ra=d(),Ln=r("span"),Ua=n("Set default quantizers"),ir=d(),x=r("p"),Va=n(`QDQBERT model adds fake quantization operations (pair of QuantizeLinear/DequantizeLinear ops) to BERT by
`),In=r("code"),Xa=n("TensorQuantizer"),Ja=n(" in "),vt=r("a"),Ga=n("Pytorch Quantization Toolkit"),Ka=n(". "),On=r("code"),Za=n("TensorQuantizer"),Ya=n(` is the module
for quantizing tensors, with `),Wn=r("code"),ei=n("QuantDescriptor"),ti=n(" defining how the tensor should be quantized. Refer to "),wt=r("a"),oi=n(`Pytorch
Quantization Toolkit userguide`),ni=n(" for more details."),lr=d(),Ue=r("p"),si=n("Before creating QDQBERT model, one has to set the default "),Hn=r("code"),ri=n("QuantDescriptor"),ai=n(" defining default tensor quantizers."),dr=d(),Jo=r("p"),ii=n("Example:"),cr=d(),_(Tt.$$.fragment),pr=d(),ke=r("h3"),Ve=r("a"),Rn=r("span"),_(yt.$$.fragment),li=d(),Un=r("span"),di=n("Calibration"),hr=d(),Go=r("p"),ci=n(`Calibration is the terminology of passing data samples to the quantizer and deciding the best scaling factors for
tensors. After setting up the tensor quantizers, one can use the following example to calibrate the model:`),ur=d(),_(qt.$$.fragment),mr=d(),Qe=r("h3"),Xe=r("a"),Vn=r("span"),_($t.$$.fragment),pi=d(),Xn=r("span"),hi=n("Export to ONNX"),fr=d(),te=r("p"),ui=n("The goal of exporting to ONNX is to deploy inference by "),Dt=r("a"),mi=n("TensorRT"),fi=n(`. Fake
quantization will be broken into a pair of QuantizeLinear/DequantizeLinear ONNX ops. After setting static member of
TensorQuantizer to use Pytorch\u2019s own fake quantization functions, fake quantized model can be exported to ONNX, follow
the instructions in `),zt=r("a"),gi=n("torch.onnx"),_i=n(". Example:"),gr=d(),_(Bt.$$.fragment),_r=d(),ve=r("h2"),Je=r("a"),Jn=r("span"),_(Mt.$$.fragment),bi=d(),Gn=r("span"),ki=n("QDQBertConfig"),br=d(),F=r("div"),_(Et.$$.fragment),Qi=d(),we=r("p"),vi=n("This is the configuration class to store the configuration of a "),Ko=r("a"),wi=n("QDQBertModel"),Ti=n(`. It is used to instantiate an
QDQBERT model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the BERT
`),xt=r("a"),yi=n("bert-base-uncased"),qi=n(" architecture."),$i=d(),Te=r("p"),Di=n("Configuration objects inherit from "),Zo=r("a"),zi=n("PretrainedConfig"),Bi=n(` and can be used to control the model outputs. Read the
documentation from `),Yo=r("a"),Mi=n("PretrainedConfig"),Ei=n(" for more information."),xi=d(),Kn=r("p"),Fi=n("Examples:"),ji=d(),_(Ft.$$.fragment),kr=d(),ye=r("h2"),Ge=r("a"),Zn=r("span"),_(jt.$$.fragment),Pi=d(),Yn=r("span"),Ci=n("QDQBertModel"),Qr=d(),z=r("div"),_(Pt.$$.fragment),Ai=d(),es=r("p"),Ni=n("The bare QDQBERT Model transformer outputting raw hidden-states without any specific head on top."),Si=d(),Ct=r("p"),Li=n("This model inherits from "),en=r("a"),Ii=n("PreTrainedModel"),Oi=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Wi=d(),At=r("p"),Hi=n("This model is also a PyTorch "),Nt=r("a"),Ri=n("torch.nn.Module"),Ui=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Vi=d(),St=r("p"),Xi=n(`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in `),Lt=r("a"),Ji=n(`Attention is
all you need`),Gi=n(` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),Ki=d(),M=r("p"),Zi=n("To behave as an decoder the model needs to be initialized with the "),ts=r("code"),Yi=n("is_decoder"),el=n(` argument of the configuration set
to `),os=r("code"),tl=n("True"),ol=n(". To be used in a Seq2Seq model, the model needs to initialized with both "),ns=r("code"),nl=n("is_decoder"),sl=n(` argument and
`),ss=r("code"),rl=n("add_cross_attention"),al=n(" set to "),rs=r("code"),il=n("True"),ll=n("; an "),as=r("code"),dl=n("encoder_hidden_states"),cl=n(" is then expected as an input to the forward pass."),pl=d(),I=r("div"),_(It.$$.fragment),hl=d(),qe=r("p"),ul=n("The "),tn=r("a"),ml=n("QDQBertModel"),fl=n(" forward method, overrides the "),is=r("code"),gl=n("__call__"),_l=n(" special method."),bl=d(),_(Ke.$$.fragment),kl=d(),ls=r("p"),Ql=n("Example:"),vl=d(),_(Ot.$$.fragment),vr=d(),$e=r("h2"),Ze=r("a"),ds=r("span"),_(Wt.$$.fragment),wl=d(),cs=r("span"),Tl=n("QDQBertLMHeadModel"),wr=d(),j=r("div"),_(Ht.$$.fragment),yl=d(),Rt=r("p"),ql=n("QDQBERT Model with a "),ps=r("code"),$l=n("language modeling"),Dl=n(" head on top for CLM fine-tuning."),zl=d(),Ut=r("p"),Bl=n("This model inherits from "),on=r("a"),Ml=n("PreTrainedModel"),El=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),xl=d(),Vt=r("p"),Fl=n("This model is also a PyTorch "),Xt=r("a"),jl=n("torch.nn.Module"),Pl=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Cl=d(),O=r("div"),_(Jt.$$.fragment),Al=d(),De=r("p"),Nl=n("The "),nn=r("a"),Sl=n("QDQBertLMHeadModel"),Ll=n(" forward method, overrides the "),hs=r("code"),Il=n("__call__"),Ol=n(" special method."),Wl=d(),_(Ye.$$.fragment),Hl=d(),us=r("p"),Rl=n("Example:"),Ul=d(),_(Gt.$$.fragment),Tr=d(),ze=r("h2"),et=r("a"),ms=r("span"),_(Kt.$$.fragment),Vl=d(),fs=r("span"),Xl=n("QDQBertForMaskedLM"),yr=d(),P=r("div"),_(Zt.$$.fragment),Jl=d(),Yt=r("p"),Gl=n("QDQBERT Model with a "),gs=r("code"),Kl=n("language modeling"),Zl=n(" head on top."),Yl=d(),eo=r("p"),ed=n("This model inherits from "),sn=r("a"),td=n("PreTrainedModel"),od=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),nd=d(),to=r("p"),sd=n("This model is also a PyTorch "),oo=r("a"),rd=n("torch.nn.Module"),ad=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),id=d(),W=r("div"),_(no.$$.fragment),ld=d(),Be=r("p"),dd=n("The "),rn=r("a"),cd=n("QDQBertForMaskedLM"),pd=n(" forward method, overrides the "),_s=r("code"),hd=n("__call__"),ud=n(" special method."),md=d(),_(tt.$$.fragment),fd=d(),bs=r("p"),gd=n("Example:"),_d=d(),_(so.$$.fragment),qr=d(),Me=r("h2"),ot=r("a"),ks=r("span"),_(ro.$$.fragment),bd=d(),Qs=r("span"),kd=n("QDQBertForSequenceClassification"),$r=d(),C=r("div"),_(ao.$$.fragment),Qd=d(),vs=r("p"),vd=n(`Bert Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled
output) e.g. for GLUE tasks.`),wd=d(),io=r("p"),Td=n("This model inherits from "),an=r("a"),yd=n("PreTrainedModel"),qd=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),$d=d(),lo=r("p"),Dd=n("This model is also a PyTorch "),co=r("a"),zd=n("torch.nn.Module"),Bd=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Md=d(),B=r("div"),_(po.$$.fragment),Ed=d(),Ee=r("p"),xd=n("The "),ln=r("a"),Fd=n("QDQBertForSequenceClassification"),jd=n(" forward method, overrides the "),ws=r("code"),Pd=n("__call__"),Cd=n(" special method."),Ad=d(),_(nt.$$.fragment),Nd=d(),Ts=r("p"),Sd=n("Example of single-label classification:"),Ld=d(),_(ho.$$.fragment),Id=d(),ys=r("p"),Od=n("Example of multi-label classification:"),Wd=d(),_(uo.$$.fragment),Dr=d(),xe=r("h2"),st=r("a"),qs=r("span"),_(mo.$$.fragment),Hd=d(),$s=r("span"),Rd=n("QDQBertForNextSentencePrediction"),zr=d(),A=r("div"),_(fo.$$.fragment),Ud=d(),go=r("p"),Vd=n("Bert Model with a "),Ds=r("code"),Xd=n("next sentence prediction (classification)"),Jd=n(" head on top."),Gd=d(),_o=r("p"),Kd=n("This model inherits from "),dn=r("a"),Zd=n("PreTrainedModel"),Yd=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ec=d(),bo=r("p"),tc=n("This model is also a PyTorch "),ko=r("a"),oc=n("torch.nn.Module"),nc=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),sc=d(),H=r("div"),_(Qo.$$.fragment),rc=d(),Fe=r("p"),ac=n("The "),cn=r("a"),ic=n("QDQBertForNextSentencePrediction"),lc=n(" forward method, overrides the "),zs=r("code"),dc=n("__call__"),cc=n(" special method."),pc=d(),_(rt.$$.fragment),hc=d(),Bs=r("p"),uc=n("Example:"),mc=d(),_(vo.$$.fragment),Br=d(),je=r("h2"),at=r("a"),Ms=r("span"),_(wo.$$.fragment),fc=d(),Es=r("span"),gc=n("QDQBertForMultipleChoice"),Mr=d(),N=r("div"),_(To.$$.fragment),_c=d(),xs=r("p"),bc=n(`Bert Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
softmax) e.g. for RocStories/SWAG tasks.`),kc=d(),yo=r("p"),Qc=n("This model inherits from "),pn=r("a"),vc=n("PreTrainedModel"),wc=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Tc=d(),qo=r("p"),yc=n("This model is also a PyTorch "),$o=r("a"),qc=n("torch.nn.Module"),$c=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Dc=d(),R=r("div"),_(Do.$$.fragment),zc=d(),Pe=r("p"),Bc=n("The "),hn=r("a"),Mc=n("QDQBertForMultipleChoice"),Ec=n(" forward method, overrides the "),Fs=r("code"),xc=n("__call__"),Fc=n(" special method."),jc=d(),_(it.$$.fragment),Pc=d(),js=r("p"),Cc=n("Example:"),Ac=d(),_(zo.$$.fragment),Er=d(),Ce=r("h2"),lt=r("a"),Ps=r("span"),_(Bo.$$.fragment),Nc=d(),Cs=r("span"),Sc=n("QDQBertForTokenClassification"),xr=d(),S=r("div"),_(Mo.$$.fragment),Lc=d(),As=r("p"),Ic=n(`QDQBERT Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),Oc=d(),Eo=r("p"),Wc=n("This model inherits from "),un=r("a"),Hc=n("PreTrainedModel"),Rc=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Uc=d(),xo=r("p"),Vc=n("This model is also a PyTorch "),Fo=r("a"),Xc=n("torch.nn.Module"),Jc=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Gc=d(),U=r("div"),_(jo.$$.fragment),Kc=d(),Ae=r("p"),Zc=n("The "),mn=r("a"),Yc=n("QDQBertForTokenClassification"),ep=n(" forward method, overrides the "),Ns=r("code"),tp=n("__call__"),op=n(" special method."),np=d(),_(dt.$$.fragment),sp=d(),Ss=r("p"),rp=n("Example:"),ap=d(),_(Po.$$.fragment),Fr=d(),Ne=r("h2"),ct=r("a"),Ls=r("span"),_(Co.$$.fragment),ip=d(),Is=r("span"),lp=n("QDQBertForQuestionAnswering"),jr=d(),L=r("div"),_(Ao.$$.fragment),dp=d(),Se=r("p"),cp=n(`QDQBERT Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `),Os=r("code"),pp=n("span start logits"),hp=n(" and "),Ws=r("code"),up=n("span end logits"),mp=n(")."),fp=d(),No=r("p"),gp=n("This model inherits from "),fn=r("a"),_p=n("PreTrainedModel"),bp=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),kp=d(),So=r("p"),Qp=n("This model is also a PyTorch "),Lo=r("a"),vp=n("torch.nn.Module"),wp=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Tp=d(),V=r("div"),_(Io.$$.fragment),yp=d(),Le=r("p"),qp=n("The "),gn=r("a"),$p=n("QDQBertForQuestionAnswering"),Dp=n(" forward method, overrides the "),Hs=r("code"),zp=n("__call__"),Bp=n(" special method."),Mp=d(),_(pt.$$.fragment),Ep=d(),Rs=r("p"),xp=n("Example:"),Fp=d(),_(Oo.$$.fragment),this.h()},l(t){const p=Zu('[data-svelte="svelte-1phssyn"]',document.head);h=a(p,"META",{name:!0,content:!0}),p.forEach(o),y=c(t),m=a(t,"H1",{class:!0});var Wo=i(m);T=a(Wo,"A",{id:!0,class:!0,href:!0});var Us=i(T);q=a(Us,"SPAN",{});var Vs=i(q);b(g.$$.fragment,Vs),Vs.forEach(o),Us.forEach(o),f=c(Wo),$=a(Wo,"SPAN",{});var Xs=i($);ka=s(Xs,"QDQBERT"),Xs.forEach(o),Wo.forEach(o),Ys=c(t),_e=a(t,"H2",{class:!0});var Ho=i(_e);Ie=a(Ho,"A",{id:!0,class:!0,href:!0});var Js=i(Ie);Bn=a(Js,"SPAN",{});var Gs=i(Bn);b(mt.$$.fragment,Gs),Gs.forEach(o),Js.forEach(o),Qa=c(Ho),Mn=a(Ho,"SPAN",{});var Ks=i(Mn);va=s(Ks,"Overview"),Ks.forEach(o),Ho.forEach(o),er=c(t),Oe=a(t,"P",{});var Cr=i(Oe);wa=s(Cr,"The QDQBERT model can be referenced in "),ft=a(Cr,"A",{href:!0,rel:!0});var jp=i(ft);Ta=s(jp,`Integer Quantization for Deep Learning Inference: Principles and Empirical
Evaluation`),jp.forEach(o),ya=s(Cr,` by Hao Wu, Patrick Judd, Xiaojie Zhang, Mikhail Isaev and Paulius
Micikevicius.`),Cr.forEach(o),tr=c(t),Ro=a(t,"P",{});var Pp=i(Ro);qa=s(Pp,"The abstract from the paper is the following:"),Pp.forEach(o),or=c(t),Uo=a(t,"P",{});var Cp=i(Uo);En=a(Cp,"EM",{});var Ap=i(En);$a=s(Ap,`Quantization techniques can reduce the size of Deep Neural Networks and improve inference latency and throughput by
taking advantage of high throughput integer instructions. In this paper we review the mathematical aspects of
quantization parameters and evaluate their choices on a wide range of neural network models for different application
domains, including vision, speech, and language. We focus on quantization techniques that are amenable to acceleration
by processors with high-throughput integer math pipelines. We also present a workflow for 8-bit quantization that is
able to maintain accuracy within 1% of the floating-point baseline on all networks studied, including models that are
more difficult to quantize, such as MobileNets and BERT-large.`),Ap.forEach(o),Cp.forEach(o),nr=c(t),Vo=a(t,"P",{});var Np=i(Vo);Da=s(Np,"Tips:"),Np.forEach(o),sr=c(t),Y=a(t,"UL",{});var ht=i(Y);xn=a(ht,"LI",{});var Sp=i(xn);Fn=a(Sp,"P",{});var Lp=i(Fn);za=s(Lp,`QDQBERT model adds fake quantization operations (pair of QuantizeLinear/DequantizeLinear ops) to (i) linear layer
inputs and weights, (ii) matmul inputs, (iii) residual add inputs, in BERT model.`),Lp.forEach(o),Sp.forEach(o),Ba=c(ht),jn=a(ht,"LI",{});var Ip=i(jn);We=a(Ip,"P",{});var Zs=i(We);Ma=s(Zs,"QDQBERT requires the dependency of "),gt=a(Zs,"A",{href:!0,rel:!0});var Op=i(gt);Ea=s(Op,"Pytorch Quantization Toolkit"),Op.forEach(o),xa=s(Zs,". To install "),Pn=a(Zs,"CODE",{});var Wp=i(Pn);Fa=s(Wp,"pip install pytorch-quantization --extra-index-url https://pypi.ngc.nvidia.com"),Wp.forEach(o),Zs.forEach(o),Ip.forEach(o),ja=c(ht),Cn=a(ht,"LI",{});var Hp=i(Cn);_t=a(Hp,"P",{});var Ar=i(_t);Pa=s(Ar,"QDQBERT model can be loaded from any checkpoint of HuggingFace BERT model (for example "),An=a(Ar,"EM",{});var Rp=i(An);Ca=s(Rp,"bert-base-uncased"),Rp.forEach(o),Aa=s(Ar,`), and
perform Quantization Aware Training/Post Training Quantization.`),Ar.forEach(o),Hp.forEach(o),Na=c(ht),Nn=a(ht,"LI",{});var Up=i(Nn);bt=a(Up,"P",{});var Nr=i(bt);Sa=s(Nr,`A complete example of using QDQBERT model to perform Quatization Aware Training and Post Training Quantization for
SQUAD task can be found at `),Xo=a(Nr,"A",{href:!0});var Vp=i(Xo);La=s(Vp,"transformers/examples/research_projects/quantization-qdqbert/"),Vp.forEach(o),Ia=s(Nr,"."),Nr.forEach(o),Up.forEach(o),ht.forEach(o),rr=c(t),He=a(t,"P",{});var Sr=i(He);Oa=s(Sr,"This model was contributed by "),kt=a(Sr,"A",{href:!0,rel:!0});var Xp=i(kt);Wa=s(Xp,"shangz"),Xp.forEach(o),Ha=s(Sr,"."),Sr.forEach(o),ar=c(t),be=a(t,"H3",{class:!0});var Lr=i(be);Re=a(Lr,"A",{id:!0,class:!0,href:!0});var Jp=i(Re);Sn=a(Jp,"SPAN",{});var Gp=i(Sn);b(Qt.$$.fragment,Gp),Gp.forEach(o),Jp.forEach(o),Ra=c(Lr),Ln=a(Lr,"SPAN",{});var Kp=i(Ln);Ua=s(Kp,"Set default quantizers"),Kp.forEach(o),Lr.forEach(o),ir=c(t),x=a(t,"P",{});var ee=i(x);Va=s(ee,`QDQBERT model adds fake quantization operations (pair of QuantizeLinear/DequantizeLinear ops) to BERT by
`),In=a(ee,"CODE",{});var Zp=i(In);Xa=s(Zp,"TensorQuantizer"),Zp.forEach(o),Ja=s(ee," in "),vt=a(ee,"A",{href:!0,rel:!0});var Yp=i(vt);Ga=s(Yp,"Pytorch Quantization Toolkit"),Yp.forEach(o),Ka=s(ee,". "),On=a(ee,"CODE",{});var eh=i(On);Za=s(eh,"TensorQuantizer"),eh.forEach(o),Ya=s(ee,` is the module
for quantizing tensors, with `),Wn=a(ee,"CODE",{});var th=i(Wn);ei=s(th,"QuantDescriptor"),th.forEach(o),ti=s(ee," defining how the tensor should be quantized. Refer to "),wt=a(ee,"A",{href:!0,rel:!0});var oh=i(wt);oi=s(oh,`Pytorch
Quantization Toolkit userguide`),oh.forEach(o),ni=s(ee," for more details."),ee.forEach(o),lr=c(t),Ue=a(t,"P",{});var Ir=i(Ue);si=s(Ir,"Before creating QDQBERT model, one has to set the default "),Hn=a(Ir,"CODE",{});var nh=i(Hn);ri=s(nh,"QuantDescriptor"),nh.forEach(o),ai=s(Ir," defining default tensor quantizers."),Ir.forEach(o),dr=c(t),Jo=a(t,"P",{});var sh=i(Jo);ii=s(sh,"Example:"),sh.forEach(o),cr=c(t),b(Tt.$$.fragment,t),pr=c(t),ke=a(t,"H3",{class:!0});var Or=i(ke);Ve=a(Or,"A",{id:!0,class:!0,href:!0});var rh=i(Ve);Rn=a(rh,"SPAN",{});var ah=i(Rn);b(yt.$$.fragment,ah),ah.forEach(o),rh.forEach(o),li=c(Or),Un=a(Or,"SPAN",{});var ih=i(Un);di=s(ih,"Calibration"),ih.forEach(o),Or.forEach(o),hr=c(t),Go=a(t,"P",{});var lh=i(Go);ci=s(lh,`Calibration is the terminology of passing data samples to the quantizer and deciding the best scaling factors for
tensors. After setting up the tensor quantizers, one can use the following example to calibrate the model:`),lh.forEach(o),ur=c(t),b(qt.$$.fragment,t),mr=c(t),Qe=a(t,"H3",{class:!0});var Wr=i(Qe);Xe=a(Wr,"A",{id:!0,class:!0,href:!0});var dh=i(Xe);Vn=a(dh,"SPAN",{});var ch=i(Vn);b($t.$$.fragment,ch),ch.forEach(o),dh.forEach(o),pi=c(Wr),Xn=a(Wr,"SPAN",{});var ph=i(Xn);hi=s(ph,"Export to ONNX"),ph.forEach(o),Wr.forEach(o),fr=c(t),te=a(t,"P",{});var _n=i(te);ui=s(_n,"The goal of exporting to ONNX is to deploy inference by "),Dt=a(_n,"A",{href:!0,rel:!0});var hh=i(Dt);mi=s(hh,"TensorRT"),hh.forEach(o),fi=s(_n,`. Fake
quantization will be broken into a pair of QuantizeLinear/DequantizeLinear ONNX ops. After setting static member of
TensorQuantizer to use Pytorch\u2019s own fake quantization functions, fake quantized model can be exported to ONNX, follow
the instructions in `),zt=a(_n,"A",{href:!0,rel:!0});var uh=i(zt);gi=s(uh,"torch.onnx"),uh.forEach(o),_i=s(_n,". Example:"),_n.forEach(o),gr=c(t),b(Bt.$$.fragment,t),_r=c(t),ve=a(t,"H2",{class:!0});var Hr=i(ve);Je=a(Hr,"A",{id:!0,class:!0,href:!0});var mh=i(Je);Jn=a(mh,"SPAN",{});var fh=i(Jn);b(Mt.$$.fragment,fh),fh.forEach(o),mh.forEach(o),bi=c(Hr),Gn=a(Hr,"SPAN",{});var gh=i(Gn);ki=s(gh,"QDQBertConfig"),gh.forEach(o),Hr.forEach(o),br=c(t),F=a(t,"DIV",{class:!0});var oe=i(F);b(Et.$$.fragment,oe),Qi=c(oe),we=a(oe,"P",{});var bn=i(we);vi=s(bn,"This is the configuration class to store the configuration of a "),Ko=a(bn,"A",{href:!0});var _h=i(Ko);wi=s(_h,"QDQBertModel"),_h.forEach(o),Ti=s(bn,`. It is used to instantiate an
QDQBERT model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the BERT
`),xt=a(bn,"A",{href:!0,rel:!0});var bh=i(xt);yi=s(bh,"bert-base-uncased"),bh.forEach(o),qi=s(bn," architecture."),bn.forEach(o),$i=c(oe),Te=a(oe,"P",{});var kn=i(Te);Di=s(kn,"Configuration objects inherit from "),Zo=a(kn,"A",{href:!0});var kh=i(Zo);zi=s(kh,"PretrainedConfig"),kh.forEach(o),Bi=s(kn,` and can be used to control the model outputs. Read the
documentation from `),Yo=a(kn,"A",{href:!0});var Qh=i(Yo);Mi=s(Qh,"PretrainedConfig"),Qh.forEach(o),Ei=s(kn," for more information."),kn.forEach(o),xi=c(oe),Kn=a(oe,"P",{});var vh=i(Kn);Fi=s(vh,"Examples:"),vh.forEach(o),ji=c(oe),b(Ft.$$.fragment,oe),oe.forEach(o),kr=c(t),ye=a(t,"H2",{class:!0});var Rr=i(ye);Ge=a(Rr,"A",{id:!0,class:!0,href:!0});var wh=i(Ge);Zn=a(wh,"SPAN",{});var Th=i(Zn);b(jt.$$.fragment,Th),Th.forEach(o),wh.forEach(o),Pi=c(Rr),Yn=a(Rr,"SPAN",{});var yh=i(Yn);Ci=s(yh,"QDQBertModel"),yh.forEach(o),Rr.forEach(o),Qr=c(t),z=a(t,"DIV",{class:!0});var X=i(z);b(Pt.$$.fragment,X),Ai=c(X),es=a(X,"P",{});var qh=i(es);Ni=s(qh,"The bare QDQBERT Model transformer outputting raw hidden-states without any specific head on top."),qh.forEach(o),Si=c(X),Ct=a(X,"P",{});var Ur=i(Ct);Li=s(Ur,"This model inherits from "),en=a(Ur,"A",{href:!0});var $h=i(en);Ii=s($h,"PreTrainedModel"),$h.forEach(o),Oi=s(Ur,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ur.forEach(o),Wi=c(X),At=a(X,"P",{});var Vr=i(At);Hi=s(Vr,"This model is also a PyTorch "),Nt=a(Vr,"A",{href:!0,rel:!0});var Dh=i(Nt);Ri=s(Dh,"torch.nn.Module"),Dh.forEach(o),Ui=s(Vr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Vr.forEach(o),Vi=c(X),St=a(X,"P",{});var Xr=i(St);Xi=s(Xr,`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in `),Lt=a(Xr,"A",{href:!0,rel:!0});var zh=i(Lt);Ji=s(zh,`Attention is
all you need`),zh.forEach(o),Gi=s(Xr,` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),Xr.forEach(o),Ki=c(X),M=a(X,"P",{});var J=i(M);Zi=s(J,"To behave as an decoder the model needs to be initialized with the "),ts=a(J,"CODE",{});var Bh=i(ts);Yi=s(Bh,"is_decoder"),Bh.forEach(o),el=s(J,` argument of the configuration set
to `),os=a(J,"CODE",{});var Mh=i(os);tl=s(Mh,"True"),Mh.forEach(o),ol=s(J,". To be used in a Seq2Seq model, the model needs to initialized with both "),ns=a(J,"CODE",{});var Eh=i(ns);nl=s(Eh,"is_decoder"),Eh.forEach(o),sl=s(J,` argument and
`),ss=a(J,"CODE",{});var xh=i(ss);rl=s(xh,"add_cross_attention"),xh.forEach(o),al=s(J," set to "),rs=a(J,"CODE",{});var Fh=i(rs);il=s(Fh,"True"),Fh.forEach(o),ll=s(J,"; an "),as=a(J,"CODE",{});var jh=i(as);dl=s(jh,"encoder_hidden_states"),jh.forEach(o),cl=s(J," is then expected as an input to the forward pass."),J.forEach(o),pl=c(X),I=a(X,"DIV",{class:!0});var ne=i(I);b(It.$$.fragment,ne),hl=c(ne),qe=a(ne,"P",{});var Qn=i(qe);ul=s(Qn,"The "),tn=a(Qn,"A",{href:!0});var Ph=i(tn);ml=s(Ph,"QDQBertModel"),Ph.forEach(o),fl=s(Qn," forward method, overrides the "),is=a(Qn,"CODE",{});var Ch=i(is);gl=s(Ch,"__call__"),Ch.forEach(o),_l=s(Qn," special method."),Qn.forEach(o),bl=c(ne),b(Ke.$$.fragment,ne),kl=c(ne),ls=a(ne,"P",{});var Ah=i(ls);Ql=s(Ah,"Example:"),Ah.forEach(o),vl=c(ne),b(Ot.$$.fragment,ne),ne.forEach(o),X.forEach(o),vr=c(t),$e=a(t,"H2",{class:!0});var Jr=i($e);Ze=a(Jr,"A",{id:!0,class:!0,href:!0});var Nh=i(Ze);ds=a(Nh,"SPAN",{});var Sh=i(ds);b(Wt.$$.fragment,Sh),Sh.forEach(o),Nh.forEach(o),wl=c(Jr),cs=a(Jr,"SPAN",{});var Lh=i(cs);Tl=s(Lh,"QDQBertLMHeadModel"),Lh.forEach(o),Jr.forEach(o),wr=c(t),j=a(t,"DIV",{class:!0});var se=i(j);b(Ht.$$.fragment,se),yl=c(se),Rt=a(se,"P",{});var Gr=i(Rt);ql=s(Gr,"QDQBERT Model with a "),ps=a(Gr,"CODE",{});var Ih=i(ps);$l=s(Ih,"language modeling"),Ih.forEach(o),Dl=s(Gr," head on top for CLM fine-tuning."),Gr.forEach(o),zl=c(se),Ut=a(se,"P",{});var Kr=i(Ut);Bl=s(Kr,"This model inherits from "),on=a(Kr,"A",{href:!0});var Oh=i(on);Ml=s(Oh,"PreTrainedModel"),Oh.forEach(o),El=s(Kr,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Kr.forEach(o),xl=c(se),Vt=a(se,"P",{});var Zr=i(Vt);Fl=s(Zr,"This model is also a PyTorch "),Xt=a(Zr,"A",{href:!0,rel:!0});var Wh=i(Xt);jl=s(Wh,"torch.nn.Module"),Wh.forEach(o),Pl=s(Zr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Zr.forEach(o),Cl=c(se),O=a(se,"DIV",{class:!0});var re=i(O);b(Jt.$$.fragment,re),Al=c(re),De=a(re,"P",{});var vn=i(De);Nl=s(vn,"The "),nn=a(vn,"A",{href:!0});var Hh=i(nn);Sl=s(Hh,"QDQBertLMHeadModel"),Hh.forEach(o),Ll=s(vn," forward method, overrides the "),hs=a(vn,"CODE",{});var Rh=i(hs);Il=s(Rh,"__call__"),Rh.forEach(o),Ol=s(vn," special method."),vn.forEach(o),Wl=c(re),b(Ye.$$.fragment,re),Hl=c(re),us=a(re,"P",{});var Uh=i(us);Rl=s(Uh,"Example:"),Uh.forEach(o),Ul=c(re),b(Gt.$$.fragment,re),re.forEach(o),se.forEach(o),Tr=c(t),ze=a(t,"H2",{class:!0});var Yr=i(ze);et=a(Yr,"A",{id:!0,class:!0,href:!0});var Vh=i(et);ms=a(Vh,"SPAN",{});var Xh=i(ms);b(Kt.$$.fragment,Xh),Xh.forEach(o),Vh.forEach(o),Vl=c(Yr),fs=a(Yr,"SPAN",{});var Jh=i(fs);Xl=s(Jh,"QDQBertForMaskedLM"),Jh.forEach(o),Yr.forEach(o),yr=c(t),P=a(t,"DIV",{class:!0});var ae=i(P);b(Zt.$$.fragment,ae),Jl=c(ae),Yt=a(ae,"P",{});var ea=i(Yt);Gl=s(ea,"QDQBERT Model with a "),gs=a(ea,"CODE",{});var Gh=i(gs);Kl=s(Gh,"language modeling"),Gh.forEach(o),Zl=s(ea," head on top."),ea.forEach(o),Yl=c(ae),eo=a(ae,"P",{});var ta=i(eo);ed=s(ta,"This model inherits from "),sn=a(ta,"A",{href:!0});var Kh=i(sn);td=s(Kh,"PreTrainedModel"),Kh.forEach(o),od=s(ta,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ta.forEach(o),nd=c(ae),to=a(ae,"P",{});var oa=i(to);sd=s(oa,"This model is also a PyTorch "),oo=a(oa,"A",{href:!0,rel:!0});var Zh=i(oo);rd=s(Zh,"torch.nn.Module"),Zh.forEach(o),ad=s(oa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),oa.forEach(o),id=c(ae),W=a(ae,"DIV",{class:!0});var ie=i(W);b(no.$$.fragment,ie),ld=c(ie),Be=a(ie,"P",{});var wn=i(Be);dd=s(wn,"The "),rn=a(wn,"A",{href:!0});var Yh=i(rn);cd=s(Yh,"QDQBertForMaskedLM"),Yh.forEach(o),pd=s(wn," forward method, overrides the "),_s=a(wn,"CODE",{});var eu=i(_s);hd=s(eu,"__call__"),eu.forEach(o),ud=s(wn," special method."),wn.forEach(o),md=c(ie),b(tt.$$.fragment,ie),fd=c(ie),bs=a(ie,"P",{});var tu=i(bs);gd=s(tu,"Example:"),tu.forEach(o),_d=c(ie),b(so.$$.fragment,ie),ie.forEach(o),ae.forEach(o),qr=c(t),Me=a(t,"H2",{class:!0});var na=i(Me);ot=a(na,"A",{id:!0,class:!0,href:!0});var ou=i(ot);ks=a(ou,"SPAN",{});var nu=i(ks);b(ro.$$.fragment,nu),nu.forEach(o),ou.forEach(o),bd=c(na),Qs=a(na,"SPAN",{});var su=i(Qs);kd=s(su,"QDQBertForSequenceClassification"),su.forEach(o),na.forEach(o),$r=c(t),C=a(t,"DIV",{class:!0});var le=i(C);b(ao.$$.fragment,le),Qd=c(le),vs=a(le,"P",{});var ru=i(vs);vd=s(ru,`Bert Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled
output) e.g. for GLUE tasks.`),ru.forEach(o),wd=c(le),io=a(le,"P",{});var sa=i(io);Td=s(sa,"This model inherits from "),an=a(sa,"A",{href:!0});var au=i(an);yd=s(au,"PreTrainedModel"),au.forEach(o),qd=s(sa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),sa.forEach(o),$d=c(le),lo=a(le,"P",{});var ra=i(lo);Dd=s(ra,"This model is also a PyTorch "),co=a(ra,"A",{href:!0,rel:!0});var iu=i(co);zd=s(iu,"torch.nn.Module"),iu.forEach(o),Bd=s(ra,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ra.forEach(o),Md=c(le),B=a(le,"DIV",{class:!0});var G=i(B);b(po.$$.fragment,G),Ed=c(G),Ee=a(G,"P",{});var Tn=i(Ee);xd=s(Tn,"The "),ln=a(Tn,"A",{href:!0});var lu=i(ln);Fd=s(lu,"QDQBertForSequenceClassification"),lu.forEach(o),jd=s(Tn," forward method, overrides the "),ws=a(Tn,"CODE",{});var du=i(ws);Pd=s(du,"__call__"),du.forEach(o),Cd=s(Tn," special method."),Tn.forEach(o),Ad=c(G),b(nt.$$.fragment,G),Nd=c(G),Ts=a(G,"P",{});var cu=i(Ts);Sd=s(cu,"Example of single-label classification:"),cu.forEach(o),Ld=c(G),b(ho.$$.fragment,G),Id=c(G),ys=a(G,"P",{});var pu=i(ys);Od=s(pu,"Example of multi-label classification:"),pu.forEach(o),Wd=c(G),b(uo.$$.fragment,G),G.forEach(o),le.forEach(o),Dr=c(t),xe=a(t,"H2",{class:!0});var aa=i(xe);st=a(aa,"A",{id:!0,class:!0,href:!0});var hu=i(st);qs=a(hu,"SPAN",{});var uu=i(qs);b(mo.$$.fragment,uu),uu.forEach(o),hu.forEach(o),Hd=c(aa),$s=a(aa,"SPAN",{});var mu=i($s);Rd=s(mu,"QDQBertForNextSentencePrediction"),mu.forEach(o),aa.forEach(o),zr=c(t),A=a(t,"DIV",{class:!0});var de=i(A);b(fo.$$.fragment,de),Ud=c(de),go=a(de,"P",{});var ia=i(go);Vd=s(ia,"Bert Model with a "),Ds=a(ia,"CODE",{});var fu=i(Ds);Xd=s(fu,"next sentence prediction (classification)"),fu.forEach(o),Jd=s(ia," head on top."),ia.forEach(o),Gd=c(de),_o=a(de,"P",{});var la=i(_o);Kd=s(la,"This model inherits from "),dn=a(la,"A",{href:!0});var gu=i(dn);Zd=s(gu,"PreTrainedModel"),gu.forEach(o),Yd=s(la,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),la.forEach(o),ec=c(de),bo=a(de,"P",{});var da=i(bo);tc=s(da,"This model is also a PyTorch "),ko=a(da,"A",{href:!0,rel:!0});var _u=i(ko);oc=s(_u,"torch.nn.Module"),_u.forEach(o),nc=s(da,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),da.forEach(o),sc=c(de),H=a(de,"DIV",{class:!0});var ce=i(H);b(Qo.$$.fragment,ce),rc=c(ce),Fe=a(ce,"P",{});var yn=i(Fe);ac=s(yn,"The "),cn=a(yn,"A",{href:!0});var bu=i(cn);ic=s(bu,"QDQBertForNextSentencePrediction"),bu.forEach(o),lc=s(yn," forward method, overrides the "),zs=a(yn,"CODE",{});var ku=i(zs);dc=s(ku,"__call__"),ku.forEach(o),cc=s(yn," special method."),yn.forEach(o),pc=c(ce),b(rt.$$.fragment,ce),hc=c(ce),Bs=a(ce,"P",{});var Qu=i(Bs);uc=s(Qu,"Example:"),Qu.forEach(o),mc=c(ce),b(vo.$$.fragment,ce),ce.forEach(o),de.forEach(o),Br=c(t),je=a(t,"H2",{class:!0});var ca=i(je);at=a(ca,"A",{id:!0,class:!0,href:!0});var vu=i(at);Ms=a(vu,"SPAN",{});var wu=i(Ms);b(wo.$$.fragment,wu),wu.forEach(o),vu.forEach(o),fc=c(ca),Es=a(ca,"SPAN",{});var Tu=i(Es);gc=s(Tu,"QDQBertForMultipleChoice"),Tu.forEach(o),ca.forEach(o),Mr=c(t),N=a(t,"DIV",{class:!0});var pe=i(N);b(To.$$.fragment,pe),_c=c(pe),xs=a(pe,"P",{});var yu=i(xs);bc=s(yu,`Bert Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
softmax) e.g. for RocStories/SWAG tasks.`),yu.forEach(o),kc=c(pe),yo=a(pe,"P",{});var pa=i(yo);Qc=s(pa,"This model inherits from "),pn=a(pa,"A",{href:!0});var qu=i(pn);vc=s(qu,"PreTrainedModel"),qu.forEach(o),wc=s(pa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),pa.forEach(o),Tc=c(pe),qo=a(pe,"P",{});var ha=i(qo);yc=s(ha,"This model is also a PyTorch "),$o=a(ha,"A",{href:!0,rel:!0});var $u=i($o);qc=s($u,"torch.nn.Module"),$u.forEach(o),$c=s(ha,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ha.forEach(o),Dc=c(pe),R=a(pe,"DIV",{class:!0});var he=i(R);b(Do.$$.fragment,he),zc=c(he),Pe=a(he,"P",{});var qn=i(Pe);Bc=s(qn,"The "),hn=a(qn,"A",{href:!0});var Du=i(hn);Mc=s(Du,"QDQBertForMultipleChoice"),Du.forEach(o),Ec=s(qn," forward method, overrides the "),Fs=a(qn,"CODE",{});var zu=i(Fs);xc=s(zu,"__call__"),zu.forEach(o),Fc=s(qn," special method."),qn.forEach(o),jc=c(he),b(it.$$.fragment,he),Pc=c(he),js=a(he,"P",{});var Bu=i(js);Cc=s(Bu,"Example:"),Bu.forEach(o),Ac=c(he),b(zo.$$.fragment,he),he.forEach(o),pe.forEach(o),Er=c(t),Ce=a(t,"H2",{class:!0});var ua=i(Ce);lt=a(ua,"A",{id:!0,class:!0,href:!0});var Mu=i(lt);Ps=a(Mu,"SPAN",{});var Eu=i(Ps);b(Bo.$$.fragment,Eu),Eu.forEach(o),Mu.forEach(o),Nc=c(ua),Cs=a(ua,"SPAN",{});var xu=i(Cs);Sc=s(xu,"QDQBertForTokenClassification"),xu.forEach(o),ua.forEach(o),xr=c(t),S=a(t,"DIV",{class:!0});var ue=i(S);b(Mo.$$.fragment,ue),Lc=c(ue),As=a(ue,"P",{});var Fu=i(As);Ic=s(Fu,`QDQBERT Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),Fu.forEach(o),Oc=c(ue),Eo=a(ue,"P",{});var ma=i(Eo);Wc=s(ma,"This model inherits from "),un=a(ma,"A",{href:!0});var ju=i(un);Hc=s(ju,"PreTrainedModel"),ju.forEach(o),Rc=s(ma,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ma.forEach(o),Uc=c(ue),xo=a(ue,"P",{});var fa=i(xo);Vc=s(fa,"This model is also a PyTorch "),Fo=a(fa,"A",{href:!0,rel:!0});var Pu=i(Fo);Xc=s(Pu,"torch.nn.Module"),Pu.forEach(o),Jc=s(fa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),fa.forEach(o),Gc=c(ue),U=a(ue,"DIV",{class:!0});var me=i(U);b(jo.$$.fragment,me),Kc=c(me),Ae=a(me,"P",{});var $n=i(Ae);Zc=s($n,"The "),mn=a($n,"A",{href:!0});var Cu=i(mn);Yc=s(Cu,"QDQBertForTokenClassification"),Cu.forEach(o),ep=s($n," forward method, overrides the "),Ns=a($n,"CODE",{});var Au=i(Ns);tp=s(Au,"__call__"),Au.forEach(o),op=s($n," special method."),$n.forEach(o),np=c(me),b(dt.$$.fragment,me),sp=c(me),Ss=a(me,"P",{});var Nu=i(Ss);rp=s(Nu,"Example:"),Nu.forEach(o),ap=c(me),b(Po.$$.fragment,me),me.forEach(o),ue.forEach(o),Fr=c(t),Ne=a(t,"H2",{class:!0});var ga=i(Ne);ct=a(ga,"A",{id:!0,class:!0,href:!0});var Su=i(ct);Ls=a(Su,"SPAN",{});var Lu=i(Ls);b(Co.$$.fragment,Lu),Lu.forEach(o),Su.forEach(o),ip=c(ga),Is=a(ga,"SPAN",{});var Iu=i(Is);lp=s(Iu,"QDQBertForQuestionAnswering"),Iu.forEach(o),ga.forEach(o),jr=c(t),L=a(t,"DIV",{class:!0});var fe=i(L);b(Ao.$$.fragment,fe),dp=c(fe),Se=a(fe,"P",{});var Dn=i(Se);cp=s(Dn,`QDQBERT Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `),Os=a(Dn,"CODE",{});var Ou=i(Os);pp=s(Ou,"span start logits"),Ou.forEach(o),hp=s(Dn," and "),Ws=a(Dn,"CODE",{});var Wu=i(Ws);up=s(Wu,"span end logits"),Wu.forEach(o),mp=s(Dn,")."),Dn.forEach(o),fp=c(fe),No=a(fe,"P",{});var _a=i(No);gp=s(_a,"This model inherits from "),fn=a(_a,"A",{href:!0});var Hu=i(fn);_p=s(Hu,"PreTrainedModel"),Hu.forEach(o),bp=s(_a,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),_a.forEach(o),kp=c(fe),So=a(fe,"P",{});var ba=i(So);Qp=s(ba,"This model is also a PyTorch "),Lo=a(ba,"A",{href:!0,rel:!0});var Ru=i(Lo);vp=s(Ru,"torch.nn.Module"),Ru.forEach(o),wp=s(ba,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ba.forEach(o),Tp=c(fe),V=a(fe,"DIV",{class:!0});var ge=i(V);b(Io.$$.fragment,ge),yp=c(ge),Le=a(ge,"P",{});var zn=i(Le);qp=s(zn,"The "),gn=a(zn,"A",{href:!0});var Uu=i(gn);$p=s(Uu,"QDQBertForQuestionAnswering"),Uu.forEach(o),Dp=s(zn," forward method, overrides the "),Hs=a(zn,"CODE",{});var Vu=i(Hs);zp=s(Vu,"__call__"),Vu.forEach(o),Bp=s(zn," special method."),zn.forEach(o),Mp=c(ge),b(pt.$$.fragment,ge),Ep=c(ge),Rs=a(ge,"P",{});var Xu=i(Rs);xp=s(Xu,"Example:"),Xu.forEach(o),Fp=c(ge),b(Oo.$$.fragment,ge),ge.forEach(o),fe.forEach(o),this.h()},h(){l(h,"name","hf:doc:metadata"),l(h,"content",JSON.stringify(lm)),l(T,"id","qdqbert"),l(T,"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"),l(T,"href","#qdqbert"),l(m,"class","relative group"),l(Ie,"id","overview"),l(Ie,"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"),l(Ie,"href","#overview"),l(_e,"class","relative group"),l(ft,"href","https://arxiv.org/abs/2004.09602"),l(ft,"rel","nofollow"),l(gt,"href","https://github.com/NVIDIA/TensorRT/tree/master/tools/pytorch-quantization"),l(gt,"rel","nofollow"),l(Xo,"href","examples/research_projects/quantization-qdqbert/"),l(kt,"href","https://huggingface.co/shangz"),l(kt,"rel","nofollow"),l(Re,"id","set-default-quantizers"),l(Re,"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"),l(Re,"href","#set-default-quantizers"),l(be,"class","relative group"),l(vt,"href","https://github.com/NVIDIA/TensorRT/tree/master/tools/pytorch-quantization"),l(vt,"rel","nofollow"),l(wt,"href","https://docs.nvidia.com/deeplearning/tensorrt/pytorch-quantization-toolkit/docs/userguide.html"),l(wt,"rel","nofollow"),l(Ve,"id","calibration"),l(Ve,"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"),l(Ve,"href","#calibration"),l(ke,"class","relative group"),l(Xe,"id","export-to-onnx"),l(Xe,"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"),l(Xe,"href","#export-to-onnx"),l(Qe,"class","relative group"),l(Dt,"href","https://developer.nvidia.com/tensorrt"),l(Dt,"rel","nofollow"),l(zt,"href","https://pytorch.org/docs/stable/onnx.html"),l(zt,"rel","nofollow"),l(Je,"id","transformers.QDQBertConfig"),l(Je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Je,"href","#transformers.QDQBertConfig"),l(ve,"class","relative group"),l(Ko,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertModel"),l(xt,"href","https://huggingface.co/bert-base-uncased"),l(xt,"rel","nofollow"),l(Zo,"href","/docs/transformers/pr_15839/en/main_classes/configuration#transformers.PretrainedConfig"),l(Yo,"href","/docs/transformers/pr_15839/en/main_classes/configuration#transformers.PretrainedConfig"),l(F,"class","docstring"),l(Ge,"id","transformers.QDQBertModel"),l(Ge,"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"),l(Ge,"href","#transformers.QDQBertModel"),l(ye,"class","relative group"),l(en,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(Nt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Nt,"rel","nofollow"),l(Lt,"href","https://arxiv.org/abs/1706.03762"),l(Lt,"rel","nofollow"),l(tn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertModel"),l(I,"class","docstring"),l(z,"class","docstring"),l(Ze,"id","transformers.QDQBertLMHeadModel"),l(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"),l(Ze,"href","#transformers.QDQBertLMHeadModel"),l($e,"class","relative group"),l(on,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(Xt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Xt,"rel","nofollow"),l(nn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertLMHeadModel"),l(O,"class","docstring"),l(j,"class","docstring"),l(et,"id","transformers.QDQBertForMaskedLM"),l(et,"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"),l(et,"href","#transformers.QDQBertForMaskedLM"),l(ze,"class","relative group"),l(sn,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(oo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(oo,"rel","nofollow"),l(rn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertForMaskedLM"),l(W,"class","docstring"),l(P,"class","docstring"),l(ot,"id","transformers.QDQBertForSequenceClassification"),l(ot,"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"),l(ot,"href","#transformers.QDQBertForSequenceClassification"),l(Me,"class","relative group"),l(an,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(co,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(co,"rel","nofollow"),l(ln,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertForSequenceClassification"),l(B,"class","docstring"),l(C,"class","docstring"),l(st,"id","transformers.QDQBertForNextSentencePrediction"),l(st,"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"),l(st,"href","#transformers.QDQBertForNextSentencePrediction"),l(xe,"class","relative group"),l(dn,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(ko,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(ko,"rel","nofollow"),l(cn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertForNextSentencePrediction"),l(H,"class","docstring"),l(A,"class","docstring"),l(at,"id","transformers.QDQBertForMultipleChoice"),l(at,"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"),l(at,"href","#transformers.QDQBertForMultipleChoice"),l(je,"class","relative group"),l(pn,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l($o,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l($o,"rel","nofollow"),l(hn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertForMultipleChoice"),l(R,"class","docstring"),l(N,"class","docstring"),l(lt,"id","transformers.QDQBertForTokenClassification"),l(lt,"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"),l(lt,"href","#transformers.QDQBertForTokenClassification"),l(Ce,"class","relative group"),l(un,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(Fo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Fo,"rel","nofollow"),l(mn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertForTokenClassification"),l(U,"class","docstring"),l(S,"class","docstring"),l(ct,"id","transformers.QDQBertForQuestionAnswering"),l(ct,"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"),l(ct,"href","#transformers.QDQBertForQuestionAnswering"),l(Ne,"class","relative group"),l(fn,"href","/docs/transformers/pr_15839/en/main_classes/model#transformers.PreTrainedModel"),l(Lo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Lo,"rel","nofollow"),l(gn,"href","/docs/transformers/pr_15839/en/model_doc/qdqbert#transformers.QDQBertForQuestionAnswering"),l(V,"class","docstring"),l(L,"class","docstring")},m(t,p){e(document.head,h),u(t,y,p),u(t,m,p),e(m,T),e(T,q),k(g,q,null),e(m,f),e(m,$),e($,ka),u(t,Ys,p),u(t,_e,p),e(_e,Ie),e(Ie,Bn),k(mt,Bn,null),e(_e,Qa),e(_e,Mn),e(Mn,va),u(t,er,p),u(t,Oe,p),e(Oe,wa),e(Oe,ft),e(ft,Ta),e(Oe,ya),u(t,tr,p),u(t,Ro,p),e(Ro,qa),u(t,or,p),u(t,Uo,p),e(Uo,En),e(En,$a),u(t,nr,p),u(t,Vo,p),e(Vo,Da),u(t,sr,p),u(t,Y,p),e(Y,xn),e(xn,Fn),e(Fn,za),e(Y,Ba),e(Y,jn),e(jn,We),e(We,Ma),e(We,gt),e(gt,Ea),e(We,xa),e(We,Pn),e(Pn,Fa),e(Y,ja),e(Y,Cn),e(Cn,_t),e(_t,Pa),e(_t,An),e(An,Ca),e(_t,Aa),e(Y,Na),e(Y,Nn),e(Nn,bt),e(bt,Sa),e(bt,Xo),e(Xo,La),e(bt,Ia),u(t,rr,p),u(t,He,p),e(He,Oa),e(He,kt),e(kt,Wa),e(He,Ha),u(t,ar,p),u(t,be,p),e(be,Re),e(Re,Sn),k(Qt,Sn,null),e(be,Ra),e(be,Ln),e(Ln,Ua),u(t,ir,p),u(t,x,p),e(x,Va),e(x,In),e(In,Xa),e(x,Ja),e(x,vt),e(vt,Ga),e(x,Ka),e(x,On),e(On,Za),e(x,Ya),e(x,Wn),e(Wn,ei),e(x,ti),e(x,wt),e(wt,oi),e(x,ni),u(t,lr,p),u(t,Ue,p),e(Ue,si),e(Ue,Hn),e(Hn,ri),e(Ue,ai),u(t,dr,p),u(t,Jo,p),e(Jo,ii),u(t,cr,p),k(Tt,t,p),u(t,pr,p),u(t,ke,p),e(ke,Ve),e(Ve,Rn),k(yt,Rn,null),e(ke,li),e(ke,Un),e(Un,di),u(t,hr,p),u(t,Go,p),e(Go,ci),u(t,ur,p),k(qt,t,p),u(t,mr,p),u(t,Qe,p),e(Qe,Xe),e(Xe,Vn),k($t,Vn,null),e(Qe,pi),e(Qe,Xn),e(Xn,hi),u(t,fr,p),u(t,te,p),e(te,ui),e(te,Dt),e(Dt,mi),e(te,fi),e(te,zt),e(zt,gi),e(te,_i),u(t,gr,p),k(Bt,t,p),u(t,_r,p),u(t,ve,p),e(ve,Je),e(Je,Jn),k(Mt,Jn,null),e(ve,bi),e(ve,Gn),e(Gn,ki),u(t,br,p),u(t,F,p),k(Et,F,null),e(F,Qi),e(F,we),e(we,vi),e(we,Ko),e(Ko,wi),e(we,Ti),e(we,xt),e(xt,yi),e(we,qi),e(F,$i),e(F,Te),e(Te,Di),e(Te,Zo),e(Zo,zi),e(Te,Bi),e(Te,Yo),e(Yo,Mi),e(Te,Ei),e(F,xi),e(F,Kn),e(Kn,Fi),e(F,ji),k(Ft,F,null),u(t,kr,p),u(t,ye,p),e(ye,Ge),e(Ge,Zn),k(jt,Zn,null),e(ye,Pi),e(ye,Yn),e(Yn,Ci),u(t,Qr,p),u(t,z,p),k(Pt,z,null),e(z,Ai),e(z,es),e(es,Ni),e(z,Si),e(z,Ct),e(Ct,Li),e(Ct,en),e(en,Ii),e(Ct,Oi),e(z,Wi),e(z,At),e(At,Hi),e(At,Nt),e(Nt,Ri),e(At,Ui),e(z,Vi),e(z,St),e(St,Xi),e(St,Lt),e(Lt,Ji),e(St,Gi),e(z,Ki),e(z,M),e(M,Zi),e(M,ts),e(ts,Yi),e(M,el),e(M,os),e(os,tl),e(M,ol),e(M,ns),e(ns,nl),e(M,sl),e(M,ss),e(ss,rl),e(M,al),e(M,rs),e(rs,il),e(M,ll),e(M,as),e(as,dl),e(M,cl),e(z,pl),e(z,I),k(It,I,null),e(I,hl),e(I,qe),e(qe,ul),e(qe,tn),e(tn,ml),e(qe,fl),e(qe,is),e(is,gl),e(qe,_l),e(I,bl),k(Ke,I,null),e(I,kl),e(I,ls),e(ls,Ql),e(I,vl),k(Ot,I,null),u(t,vr,p),u(t,$e,p),e($e,Ze),e(Ze,ds),k(Wt,ds,null),e($e,wl),e($e,cs),e(cs,Tl),u(t,wr,p),u(t,j,p),k(Ht,j,null),e(j,yl),e(j,Rt),e(Rt,ql),e(Rt,ps),e(ps,$l),e(Rt,Dl),e(j,zl),e(j,Ut),e(Ut,Bl),e(Ut,on),e(on,Ml),e(Ut,El),e(j,xl),e(j,Vt),e(Vt,Fl),e(Vt,Xt),e(Xt,jl),e(Vt,Pl),e(j,Cl),e(j,O),k(Jt,O,null),e(O,Al),e(O,De),e(De,Nl),e(De,nn),e(nn,Sl),e(De,Ll),e(De,hs),e(hs,Il),e(De,Ol),e(O,Wl),k(Ye,O,null),e(O,Hl),e(O,us),e(us,Rl),e(O,Ul),k(Gt,O,null),u(t,Tr,p),u(t,ze,p),e(ze,et),e(et,ms),k(Kt,ms,null),e(ze,Vl),e(ze,fs),e(fs,Xl),u(t,yr,p),u(t,P,p),k(Zt,P,null),e(P,Jl),e(P,Yt),e(Yt,Gl),e(Yt,gs),e(gs,Kl),e(Yt,Zl),e(P,Yl),e(P,eo),e(eo,ed),e(eo,sn),e(sn,td),e(eo,od),e(P,nd),e(P,to),e(to,sd),e(to,oo),e(oo,rd),e(to,ad),e(P,id),e(P,W),k(no,W,null),e(W,ld),e(W,Be),e(Be,dd),e(Be,rn),e(rn,cd),e(Be,pd),e(Be,_s),e(_s,hd),e(Be,ud),e(W,md),k(tt,W,null),e(W,fd),e(W,bs),e(bs,gd),e(W,_d),k(so,W,null),u(t,qr,p),u(t,Me,p),e(Me,ot),e(ot,ks),k(ro,ks,null),e(Me,bd),e(Me,Qs),e(Qs,kd),u(t,$r,p),u(t,C,p),k(ao,C,null),e(C,Qd),e(C,vs),e(vs,vd),e(C,wd),e(C,io),e(io,Td),e(io,an),e(an,yd),e(io,qd),e(C,$d),e(C,lo),e(lo,Dd),e(lo,co),e(co,zd),e(lo,Bd),e(C,Md),e(C,B),k(po,B,null),e(B,Ed),e(B,Ee),e(Ee,xd),e(Ee,ln),e(ln,Fd),e(Ee,jd),e(Ee,ws),e(ws,Pd),e(Ee,Cd),e(B,Ad),k(nt,B,null),e(B,Nd),e(B,Ts),e(Ts,Sd),e(B,Ld),k(ho,B,null),e(B,Id),e(B,ys),e(ys,Od),e(B,Wd),k(uo,B,null),u(t,Dr,p),u(t,xe,p),e(xe,st),e(st,qs),k(mo,qs,null),e(xe,Hd),e(xe,$s),e($s,Rd),u(t,zr,p),u(t,A,p),k(fo,A,null),e(A,Ud),e(A,go),e(go,Vd),e(go,Ds),e(Ds,Xd),e(go,Jd),e(A,Gd),e(A,_o),e(_o,Kd),e(_o,dn),e(dn,Zd),e(_o,Yd),e(A,ec),e(A,bo),e(bo,tc),e(bo,ko),e(ko,oc),e(bo,nc),e(A,sc),e(A,H),k(Qo,H,null),e(H,rc),e(H,Fe),e(Fe,ac),e(Fe,cn),e(cn,ic),e(Fe,lc),e(Fe,zs),e(zs,dc),e(Fe,cc),e(H,pc),k(rt,H,null),e(H,hc),e(H,Bs),e(Bs,uc),e(H,mc),k(vo,H,null),u(t,Br,p),u(t,je,p),e(je,at),e(at,Ms),k(wo,Ms,null),e(je,fc),e(je,Es),e(Es,gc),u(t,Mr,p),u(t,N,p),k(To,N,null),e(N,_c),e(N,xs),e(xs,bc),e(N,kc),e(N,yo),e(yo,Qc),e(yo,pn),e(pn,vc),e(yo,wc),e(N,Tc),e(N,qo),e(qo,yc),e(qo,$o),e($o,qc),e(qo,$c),e(N,Dc),e(N,R),k(Do,R,null),e(R,zc),e(R,Pe),e(Pe,Bc),e(Pe,hn),e(hn,Mc),e(Pe,Ec),e(Pe,Fs),e(Fs,xc),e(Pe,Fc),e(R,jc),k(it,R,null),e(R,Pc),e(R,js),e(js,Cc),e(R,Ac),k(zo,R,null),u(t,Er,p),u(t,Ce,p),e(Ce,lt),e(lt,Ps),k(Bo,Ps,null),e(Ce,Nc),e(Ce,Cs),e(Cs,Sc),u(t,xr,p),u(t,S,p),k(Mo,S,null),e(S,Lc),e(S,As),e(As,Ic),e(S,Oc),e(S,Eo),e(Eo,Wc),e(Eo,un),e(un,Hc),e(Eo,Rc),e(S,Uc),e(S,xo),e(xo,Vc),e(xo,Fo),e(Fo,Xc),e(xo,Jc),e(S,Gc),e(S,U),k(jo,U,null),e(U,Kc),e(U,Ae),e(Ae,Zc),e(Ae,mn),e(mn,Yc),e(Ae,ep),e(Ae,Ns),e(Ns,tp),e(Ae,op),e(U,np),k(dt,U,null),e(U,sp),e(U,Ss),e(Ss,rp),e(U,ap),k(Po,U,null),u(t,Fr,p),u(t,Ne,p),e(Ne,ct),e(ct,Ls),k(Co,Ls,null),e(Ne,ip),e(Ne,Is),e(Is,lp),u(t,jr,p),u(t,L,p),k(Ao,L,null),e(L,dp),e(L,Se),e(Se,cp),e(Se,Os),e(Os,pp),e(Se,hp),e(Se,Ws),e(Ws,up),e(Se,mp),e(L,fp),e(L,No),e(No,gp),e(No,fn),e(fn,_p),e(No,bp),e(L,kp),e(L,So),e(So,Qp),e(So,Lo),e(Lo,vp),e(So,wp),e(L,Tp),e(L,V),k(Io,V,null),e(V,yp),e(V,Le),e(Le,qp),e(Le,gn),e(gn,$p),e(Le,Dp),e(Le,Hs),e(Hs,zp),e(Le,Bp),e(V,Mp),k(pt,V,null),e(V,Ep),e(V,Rs),e(Rs,xp),e(V,Fp),k(Oo,V,null),Pr=!0},p(t,[p]){const Wo={};p&2&&(Wo.$$scope={dirty:p,ctx:t}),Ke.$set(Wo);const Us={};p&2&&(Us.$$scope={dirty:p,ctx:t}),Ye.$set(Us);const Vs={};p&2&&(Vs.$$scope={dirty:p,ctx:t}),tt.$set(Vs);const Xs={};p&2&&(Xs.$$scope={dirty:p,ctx:t}),nt.$set(Xs);const Ho={};p&2&&(Ho.$$scope={dirty:p,ctx:t}),rt.$set(Ho);const Js={};p&2&&(Js.$$scope={dirty:p,ctx:t}),it.$set(Js);const Gs={};p&2&&(Gs.$$scope={dirty:p,ctx:t}),dt.$set(Gs);const Ks={};p&2&&(Ks.$$scope={dirty:p,ctx:t}),pt.$set(Ks)},i(t){Pr||(Q(g.$$.fragment,t),Q(mt.$$.fragment,t),Q(Qt.$$.fragment,t),Q(Tt.$$.fragment,t),Q(yt.$$.fragment,t),Q(qt.$$.fragment,t),Q($t.$$.fragment,t),Q(Bt.$$.fragment,t),Q(Mt.$$.fragment,t),Q(Et.$$.fragment,t),Q(Ft.$$.fragment,t),Q(jt.$$.fragment,t),Q(Pt.$$.fragment,t),Q(It.$$.fragment,t),Q(Ke.$$.fragment,t),Q(Ot.$$.fragment,t),Q(Wt.$$.fragment,t),Q(Ht.$$.fragment,t),Q(Jt.$$.fragment,t),Q(Ye.$$.fragment,t),Q(Gt.$$.fragment,t),Q(Kt.$$.fragment,t),Q(Zt.$$.fragment,t),Q(no.$$.fragment,t),Q(tt.$$.fragment,t),Q(so.$$.fragment,t),Q(ro.$$.fragment,t),Q(ao.$$.fragment,t),Q(po.$$.fragment,t),Q(nt.$$.fragment,t),Q(ho.$$.fragment,t),Q(uo.$$.fragment,t),Q(mo.$$.fragment,t),Q(fo.$$.fragment,t),Q(Qo.$$.fragment,t),Q(rt.$$.fragment,t),Q(vo.$$.fragment,t),Q(wo.$$.fragment,t),Q(To.$$.fragment,t),Q(Do.$$.fragment,t),Q(it.$$.fragment,t),Q(zo.$$.fragment,t),Q(Bo.$$.fragment,t),Q(Mo.$$.fragment,t),Q(jo.$$.fragment,t),Q(dt.$$.fragment,t),Q(Po.$$.fragment,t),Q(Co.$$.fragment,t),Q(Ao.$$.fragment,t),Q(Io.$$.fragment,t),Q(pt.$$.fragment,t),Q(Oo.$$.fragment,t),Pr=!0)},o(t){v(g.$$.fragment,t),v(mt.$$.fragment,t),v(Qt.$$.fragment,t),v(Tt.$$.fragment,t),v(yt.$$.fragment,t),v(qt.$$.fragment,t),v($t.$$.fragment,t),v(Bt.$$.fragment,t),v(Mt.$$.fragment,t),v(Et.$$.fragment,t),v(Ft.$$.fragment,t),v(jt.$$.fragment,t),v(Pt.$$.fragment,t),v(It.$$.fragment,t),v(Ke.$$.fragment,t),v(Ot.$$.fragment,t),v(Wt.$$.fragment,t),v(Ht.$$.fragment,t),v(Jt.$$.fragment,t),v(Ye.$$.fragment,t),v(Gt.$$.fragment,t),v(Kt.$$.fragment,t),v(Zt.$$.fragment,t),v(no.$$.fragment,t),v(tt.$$.fragment,t),v(so.$$.fragment,t),v(ro.$$.fragment,t),v(ao.$$.fragment,t),v(po.$$.fragment,t),v(nt.$$.fragment,t),v(ho.$$.fragment,t),v(uo.$$.fragment,t),v(mo.$$.fragment,t),v(fo.$$.fragment,t),v(Qo.$$.fragment,t),v(rt.$$.fragment,t),v(vo.$$.fragment,t),v(wo.$$.fragment,t),v(To.$$.fragment,t),v(Do.$$.fragment,t),v(it.$$.fragment,t),v(zo.$$.fragment,t),v(Bo.$$.fragment,t),v(Mo.$$.fragment,t),v(jo.$$.fragment,t),v(dt.$$.fragment,t),v(Po.$$.fragment,t),v(Co.$$.fragment,t),v(Ao.$$.fragment,t),v(Io.$$.fragment,t),v(pt.$$.fragment,t),v(Oo.$$.fragment,t),Pr=!1},d(t){o(h),t&&o(y),t&&o(m),w(g),t&&o(Ys),t&&o(_e),w(mt),t&&o(er),t&&o(Oe),t&&o(tr),t&&o(Ro),t&&o(or),t&&o(Uo),t&&o(nr),t&&o(Vo),t&&o(sr),t&&o(Y),t&&o(rr),t&&o(He),t&&o(ar),t&&o(be),w(Qt),t&&o(ir),t&&o(x),t&&o(lr),t&&o(Ue),t&&o(dr),t&&o(Jo),t&&o(cr),w(Tt,t),t&&o(pr),t&&o(ke),w(yt),t&&o(hr),t&&o(Go),t&&o(ur),w(qt,t),t&&o(mr),t&&o(Qe),w($t),t&&o(fr),t&&o(te),t&&o(gr),w(Bt,t),t&&o(_r),t&&o(ve),w(Mt),t&&o(br),t&&o(F),w(Et),w(Ft),t&&o(kr),t&&o(ye),w(jt),t&&o(Qr),t&&o(z),w(Pt),w(It),w(Ke),w(Ot),t&&o(vr),t&&o($e),w(Wt),t&&o(wr),t&&o(j),w(Ht),w(Jt),w(Ye),w(Gt),t&&o(Tr),t&&o(ze),w(Kt),t&&o(yr),t&&o(P),w(Zt),w(no),w(tt),w(so),t&&o(qr),t&&o(Me),w(ro),t&&o($r),t&&o(C),w(ao),w(po),w(nt),w(ho),w(uo),t&&o(Dr),t&&o(xe),w(mo),t&&o(zr),t&&o(A),w(fo),w(Qo),w(rt),w(vo),t&&o(Br),t&&o(je),w(wo),t&&o(Mr),t&&o(N),w(To),w(Do),w(it),w(zo),t&&o(Er),t&&o(Ce),w(Bo),t&&o(xr),t&&o(S),w(Mo),w(jo),w(dt),w(Po),t&&o(Fr),t&&o(Ne),w(Co),t&&o(jr),t&&o(L),w(Ao),w(Io),w(pt),w(Oo)}}}const lm={local:"qdqbert",sections:[{local:"overview",sections:[{local:"set-default-quantizers",title:"Set default quantizers"},{local:"calibration",title:"Calibration"},{local:"export-to-onnx",title:"Export to ONNX"}],title:"Overview"},{local:"transformers.QDQBertConfig",title:"QDQBertConfig"},{local:"transformers.QDQBertModel",title:"QDQBertModel"},{local:"transformers.QDQBertLMHeadModel",title:"QDQBertLMHeadModel"},{local:"transformers.QDQBertForMaskedLM",title:"QDQBertForMaskedLM"},{local:"transformers.QDQBertForSequenceClassification",title:"QDQBertForSequenceClassification"},{local:"transformers.QDQBertForNextSentencePrediction",title:"QDQBertForNextSentencePrediction"},{local:"transformers.QDQBertForMultipleChoice",title:"QDQBertForMultipleChoice"},{local:"transformers.QDQBertForTokenClassification",title:"QDQBertForTokenClassification"},{local:"transformers.QDQBertForQuestionAnswering",title:"QDQBertForQuestionAnswering"}],title:"QDQBERT"};function dm(D,h,y){let{fw:m}=h;return D.$$set=T=>{"fw"in T&&y(0,m=T.fw)},[m]}class gm extends Ju{constructor(h){super();Gu(this,h,dm,im,Ku,{fw:0})}}export{gm as default,lm as metadata};
