import{S as Md,i as zd,s as Cd,e as s,k as c,w as T,t as r,M as Fd,c as a,d as o,m as h,a as i,x as b,h as n,b as d,G as e,g as m,y as v,q as y,o as k,B as S,v as qd,L as ti}from"../../chunks/vendor-hf-doc-builder.js";import{T as Qa}from"../../chunks/Tip-hf-doc-builder.js";import{D as G}from"../../chunks/Docstring-hf-doc-builder.js";import{C as oi}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ne}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ei}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Pd(C){let u,x,g,_,w;return{c(){u=s("p"),x=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s("code"),_=r("Module"),w=r(`
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(l){u=a(l,"P",{});var f=i(u);x=n(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a(f,"CODE",{});var F=i(g);_=n(F,"Module"),F.forEach(o),w=n(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(l,f){m(l,u,f),e(u,x),e(u,g),e(g,_),e(u,w)},d(l){l&&o(u)}}}function Ad(C){let u,x,g,_,w;return _=new oi({props:{code:`from transformers import AutoTokenizer, SwitchTransformersModel

tokenizer = AutoTokenizer.from_pretrained("google/switch-base-8")
model = SwitchTransformersModel.from_pretrained("google/switch-base-8")

input_ids = tokenizer(
    "Studies have been shown that owning a dog is good for you", return_tensors="pt"
).input_ids  # Batch size 1
decoder_input_ids = tokenizer("Studies show that", return_tensors="pt").input_ids  # Batch size 1

# preprocess: Prepend decoder_input_ids with start token which is pad token for SwitchTransformersModel.
# This is not needed for torch's SwitchTransformersForConditionalGeneration as it does this internally using labels arg.
decoder_input_ids = model._shift_right(decoder_input_ids)

# forward pass
outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
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> AutoTokenizer, SwitchTransformersModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/switch-base-8&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwitchTransformersModel.from_pretrained(<span class="hljs-string">&quot;google/switch-base-8&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Studies have been shown that owning a dog is good for you&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>).input_ids  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = tokenizer(<span class="hljs-string">&quot;Studies show that&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids  <span class="hljs-comment"># Batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># preprocess: Prepend decoder_input_ids with start token which is pad token for SwitchTransformersModel.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># This is not needed for torch&#x27;s SwitchTransformersForConditionalGeneration as it does this internally using labels arg.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = model._shift_right(decoder_input_ids)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){u=s("p"),x=r("Example:"),g=c(),T(_.$$.fragment)},l(l){u=a(l,"P",{});var f=i(u);x=n(f,"Example:"),f.forEach(o),g=h(l),b(_.$$.fragment,l)},m(l,f){m(l,u,f),e(u,x),m(l,g,f),v(_,l,f),w=!0},p:ti,i(l){w||(y(_.$$.fragment,l),w=!0)},o(l){k(_.$$.fragment,l),w=!1},d(l){l&&o(u),l&&o(g),S(_,l)}}}function Od(C){let u,x,g,_,w;return{c(){u=s("p"),x=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s("code"),_=r("Module"),w=r(`
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(l){u=a(l,"P",{});var f=i(u);x=n(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a(f,"CODE",{});var F=i(g);_=n(F,"Module"),F.forEach(o),w=n(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(l,f){m(l,u,f),e(u,x),e(u,g),e(g,_),e(u,w)},d(l){l&&o(u)}}}function Rd(C){let u,x,g,_,w;return _=new oi({props:{code:`from transformers import AutoTokenizer, SwitchTransformersForConditionalGeneration

tokenizer = AutoTokenizer.from_pretrained("google/switch-base-8")
model = SwitchTransformersForConditionalGeneration.from_pretrained("google/switch-base-8")

# training
input_ids = tokenizer("The <extra_id_0> walks in <extra_id_1> park", return_tensors="pt").input_ids
labels = tokenizer("<extra_id_0> cute dog <extra_id_1> the <extra_id_2>", return_tensors="pt").input_ids
outputs = model(input_ids=input_ids, labels=labels)
loss = outputs.loss
logits = outputs.logits

# inference
input_ids = tokenizer(
    "summarize: studies have shown that owning a dog is good for you", return_tensors="pt"
).input_ids  # Batch size 1
outputs = model.generate(input_ids)
# . To, let\u2019s say you have a dog. To summarize:
# Since the model has been trained on MLM, this will output gibberish`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, SwitchTransformersForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/switch-base-8&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwitchTransformersForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;google/switch-base-8&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># training</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(<span class="hljs-string">&quot;The &lt;extra_id_0&gt; walks in &lt;extra_id_1&gt; park&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;&lt;extra_id_0&gt; cute dog &lt;extra_id_1&gt; the &lt;extra_id_2&gt;&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, 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-comment"># inference</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;summarize: studies have shown that owning a dog is good for you&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>).input_ids  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># . To, let\u2019s say you have a dog. To summarize:</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Since the model has been trained on MLM, this will output gibberish</span>`}}),{c(){u=s("p"),x=r("Examples:"),g=c(),T(_.$$.fragment)},l(l){u=a(l,"P",{});var f=i(u);x=n(f,"Examples:"),f.forEach(o),g=h(l),b(_.$$.fragment,l)},m(l,f){m(l,u,f),e(u,x),m(l,g,f),v(_,l,f),w=!0},p:ti,i(l){w||(y(_.$$.fragment,l),w=!0)},o(l){k(_.$$.fragment,l),w=!1},d(l){l&&o(u),l&&o(g),S(_,l)}}}function Nd(C){let u,x,g,_,w;return{c(){u=s("p"),x=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s("code"),_=r("Module"),w=r(`
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(l){u=a(l,"P",{});var f=i(u);x=n(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a(f,"CODE",{});var F=i(g);_=n(F,"Module"),F.forEach(o),w=n(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(l,f){m(l,u,f),e(u,x),e(u,g),e(g,_),e(u,w)},d(l){l&&o(u)}}}function Id(C){let u,x,g,_,w;return _=new oi({props:{code:`from transformers import AutoTokenizer, SwitchTransformersEncoderModel

tokenizer = AutoTokenizer.from_pretrained("google/switch-base-8")
model = SwitchTransformersEncoderModel.from_pretrained("google/switch-base-8")
input_ids = tokenizer(
    "Studies have been shown that owning a dog is good for you", return_tensors="pt"
).input_ids  # Batch size 1
outputs = model(input_ids=input_ids)
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> AutoTokenizer, SwitchTransformersEncoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/switch-base-8&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwitchTransformersEncoderModel.from_pretrained(<span class="hljs-string">&quot;google/switch-base-8&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Studies have been shown that owning a dog is good for you&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>).input_ids  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){u=s("p"),x=r("Example:"),g=c(),T(_.$$.fragment)},l(l){u=a(l,"P",{});var f=i(u);x=n(f,"Example:"),f.forEach(o),g=h(l),b(_.$$.fragment,l)},m(l,f){m(l,u,f),e(u,x),m(l,g,f),v(_,l,f),w=!0},p:ti,i(l){w||(y(_.$$.fragment,l),w=!0)},o(l){k(_.$$.fragment,l),w=!1},d(l){l&&o(u),l&&o(g),S(_,l)}}}function jd(C){let u,x,g,_,w,l,f,F,qr,Zo,te,me,ao,Ie,Pr,io,Ar,Uo,fe,Or,je,Rr,Nr,Xo,Nt,Ir,Yo,It,jr,Jo,jt,lo,Wr,Ko,Wt,Dr,Qo,_e,We,Lr,Dt,Br,Gr,Hr,De,Vr,Le,Zr,Ur,er,R,Xr,Be,Yr,Jr,Ge,Kr,Qr,He,en,tn,tr,oe,ge,co,Ve,on,ho,rn,or,H,Ze,nn,re,sn,Lt,an,dn,Ue,ln,cn,hn,ne,pn,Bt,un,mn,Gt,fn,_n,rr,se,we,po,Xe,gn,uo,wn,nr,z,Ye,Tn,mo,bn,vn,V,yn,Je,kn,Sn,Ke,xn,$n,fo,En,Mn,zn,Te,Qe,Cn,_o,Fn,qn,X,et,Pn,ae,An,go,On,Rn,wo,Nn,In,jn,q,Wn,To,Dn,Ln,bo,Bn,Gn,vo,Hn,Vn,yo,Zn,Un,sr,ie,be,ko,tt,Xn,So,Yn,ar,Z,ot,Jn,xo,Kn,Qn,N,rt,es,$o,ts,os,U,rs,Eo,ns,ss,Mo,as,is,zo,ds,ls,cs,Co,hs,ir,de,ve,Fo,nt,ps,qo,us,dr,$,st,ms,Po,fs,_s,P,gs,at,ws,Ts,it,bs,vs,dt,ys,ks,lt,Ss,xs,$s,ct,Es,Ht,Ms,zs,Cs,ht,Fs,pt,qs,Ps,As,I,ut,Os,le,Rs,Vt,Ns,Is,Ao,js,Ws,Ds,ye,Ls,ke,lr,ce,Se,Oo,mt,Bs,Ro,Gs,cr,E,ft,Hs,_t,Vs,No,Zs,Us,Xs,A,Ys,gt,Js,Ks,wt,Qs,ea,Tt,ta,oa,bt,ra,na,sa,vt,aa,Zt,ia,da,la,yt,ca,kt,ha,pa,ua,j,St,ma,he,fa,Ut,_a,ga,Io,wa,Ta,ba,xe,va,$e,hr,pe,Ee,jo,xt,ya,Wo,ka,pr,M,$t,Sa,Do,xa,$a,O,Ea,Et,Ma,za,Mt,Ca,Fa,zt,qa,Pa,Ct,Aa,Oa,Ra,Ft,Na,Xt,Ia,ja,Wa,qt,Da,Pt,La,Ba,Ga,W,At,Ha,ue,Va,Yt,Za,Ua,Lo,Xa,Ya,Ja,Me,Ka,ze,ur;return l=new Ne({}),Ie=new Ne({}),Ve=new Ne({}),Ze=new G({props:{name:"class transformers.SwitchTransformersConfig",anchor:"transformers.SwitchTransformersConfig",parameters:[{name:"vocab_size",val:" = 32128"},{name:"d_model",val:" = 768"},{name:"d_kv",val:" = 64"},{name:"d_ff",val:" = 2048"},{name:"expert_capacity",val:" = 64"},{name:"num_layers",val:" = 12"},{name:"num_sparse_encoder_layers",val:" = 3"},{name:"num_decoder_layers",val:" = 12"},{name:"num_sparse_decoder_layers",val:" = 3"},{name:"num_heads",val:" = 12"},{name:"num_experts",val:" = 8"},{name:"router_type",val:" = 'tokens_masked'"},{name:"router_bias",val:" = False"},{name:"router_jitter_noise",val:" = 0.01"},{name:"router_dtype",val:" = 'float32'"},{name:"router_ignore_padding_tokens",val:" = False"},{name:"relative_attention_num_buckets",val:" = 32"},{name:"relative_attention_max_distance",val:" = 128"},{name:"dropout_rate",val:" = 0.1"},{name:"layer_norm_epsilon",val:" = 1e-06"},{name:"router_z_loss_coef",val:" = 0.001"},{name:"router_aux_loss_coef",val:" = 0.001"},{name:"initializer_factor",val:" = 1.0"},{name:"feed_forward_proj",val:" = 'relu'"},{name:"is_encoder_decoder",val:" = True"},{name:"add_router_probs",val:" = False"},{name:"use_cache",val:" = True"},{name:"pad_token_id",val:" = 0"},{name:"eos_token_id",val:" = 1"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SwitchTransformersConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 32128) &#x2014;
Vocabulary size of the SwitchTransformers model. Defines the number of different tokens that can be
represented by the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersModel">SwitchTransformersModel</a>.`,name:"vocab_size"},{anchor:"transformers.SwitchTransformersConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
Size of the encoder layers and the pooler layer.`,name:"d_model"},{anchor:"transformers.SwitchTransformersConfig.d_kv",description:`<strong>d_kv</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Size of the key, query, value projections per attention head. <code>d_kv</code> has to be equal to <code>d_model // num_heads</code>.`,name:"d_kv"},{anchor:"transformers.SwitchTransformersConfig.d_ff",description:`<strong>d_ff</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Size of the intermediate feed forward layer in each <code>SwitchTransformersBlock</code>.`,name:"d_ff"},{anchor:"transformers.SwitchTransformersConfig.expert_capacity",description:`<strong>expert_capacity</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Number of tokens that can be stored in each expert. If set to 1, the model will behave like a regular
Transformer.`,name:"expert_capacity"},{anchor:"transformers.SwitchTransformersConfig.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of dense hidden layers in the Transformer encoder layer.`,name:"num_layers"},{anchor:"transformers.SwitchTransformersConfig.num_sparse_encoder_layers",description:`<strong>num_sparse_encoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 6) &#x2014;
Number of sparse (MoE) dense hidden layers in the Transformer encoder layer.`,name:"num_sparse_encoder_layers"},{anchor:"transformers.SwitchTransformersConfig.num_decoder_layers",description:`<strong>num_decoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer decoder. Will use the same value as <code>num_layers</code> if not set.`,name:"num_decoder_layers"},{anchor:"transformers.SwitchTransformersConfig.num_sparse_decoder_layers",description:`<strong>num_sparse_decoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of sparse (MoE) dense hidden layers in the Transformer decoder layer.`,name:"num_sparse_decoder_layers"},{anchor:"transformers.SwitchTransformersConfig.num_heads",description:`<strong>num_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.SwitchTransformersConfig.num_experts",description:`<strong>num_experts</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
Number of experts for each SwitchTransformer layer.`,name:"num_experts"},{anchor:"transformers.SwitchTransformersConfig.router_type",description:"<strong>router_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;tokens_masked&quot;</code>) &#x2014;\nRouter type - choose between <code>&quot;tokens_masked&quot;, </code>&#x201C;tokens_scatter&#x201D;<code>and</code>&#x201C;experts_masked&#x201D;`.",name:"router_type"},{anchor:"transformers.SwitchTransformersConfig.router_bias",description:`<strong>router_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a bias to the router.`,name:"router_bias"},{anchor:"transformers.SwitchTransformersConfig.router_jitter_noise",description:`<strong>router_jitter_noise</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Amount of noise to add to the router.`,name:"router_jitter_noise"},{anchor:"transformers.SwitchTransformersConfig.router_dtype",description:`<strong>router_dtype</strong> (<code>str</code>, <em>optional</em>, default to <code>&quot;float32&quot;</code>) &#x2014;
The <code>dtype</code> used for the routers. It is preferable to keep the <code>dtype</code> to <code>&quot;float32&quot;</code> as specified in the
<em>selective precision</em> discussion in <a href="https://arxiv.org/abs/2101.03961" rel="nofollow">the paper</a>.`,name:"router_dtype"},{anchor:"transformers.SwitchTransformersConfig.router_ignore_padding_tokens",description:`<strong>router_ignore_padding_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to ignore padding tokens when routing.`,name:"router_ignore_padding_tokens"},{anchor:"transformers.SwitchTransformersConfig.relative_attention_num_buckets",description:`<strong>relative_attention_num_buckets</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of buckets to use for each attention layer.`,name:"relative_attention_num_buckets"},{anchor:"transformers.SwitchTransformersConfig.relative_attention_max_distance",description:`<strong>relative_attention_max_distance</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The maximum distance of the longer sequences for the bucket separation.`,name:"relative_attention_max_distance"},{anchor:"transformers.SwitchTransformersConfig.dropout_rate",description:`<strong>dropout_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The ratio for all dropout layers.`,name:"dropout_rate"},{anchor:"transformers.SwitchTransformersConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.SwitchTransformersConfig.router_z_loss_coef",description:`<strong>router_z_loss_coef</strong> (<code>float</code>, <em>optional</em>, defaults to 0.001) &#x2014;
The z loss factor for the total loss.`,name:"router_z_loss_coef"},{anchor:"transformers.SwitchTransformersConfig.router_aux_loss_coef",description:`<strong>router_aux_loss_coef</strong> (<code>float</code>, <em>optional</em>, defaults to 0.001) &#x2014;
The aux loss factor for the total loss.`,name:"router_aux_loss_coef"},{anchor:"transformers.SwitchTransformersConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 1) &#x2014;
A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
testing).`,name:"initializer_factor"},{anchor:"transformers.SwitchTransformersConfig.feed_forward_proj",description:`<strong>feed_forward_proj</strong> (<code>string</code>, <em>optional</em>, defaults to <code>&quot;relu&quot;</code>) &#x2014;
Type of feed forward layer to be used. Should be one of <code>&quot;relu&quot;</code> or <code>&quot;gated-gelu&quot;</code>. SwitchTransformersv1.1
uses the <code>&quot;gated-gelu&quot;</code> feed forward projection. Original SwitchTransformers uses <code>&quot;relu&quot;</code>.`,name:"feed_forward_proj"},{anchor:"transformers.SwitchTransformersConfig.add_router_probs",description:`<strong>add_router_probs</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to output router probabilities to compute router auxiliary loss.`,name:"add_router_probs"},{anchor:"transformers.SwitchTransformersConfig.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).`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/configuration_switch_transformers.py#L27"}}),Xe=new Ne({}),Ye=new G({props:{name:"class transformers.SwitchTransformersTop1Router",anchor:"transformers.SwitchTransformersTop1Router",parameters:[{name:"config",val:": SwitchTransformersConfig"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L131"}}),Qe=new G({props:{name:"_compute_router_probabilities",anchor:"transformers.SwitchTransformersTop1Router._compute_router_probabilities",parameters:[{name:"hidden_states",val:": Tensor"}],parametersDescription:[{anchor:"transformers.SwitchTransformersTop1Router._compute_router_probabilities.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
(batch_size, sequence_length, hidden_dim) from which router probabilities are computed.`,name:"hidden_states"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L151",returnDescription:`
<p>Tensor of shape (batch_size, sequence_length, num_experts) corresponding to the probabilities for each
token and expert. Used for routing tokens to experts.
router_logits (<code>torch.Tensor</code>):
Logits tensor of shape (batch_size, sequence_length, num_experts) corresponding to raw router logits.
This is used later for computing router z-loss.</p>
`,returnType:`
<p>router_probabilities (<code>torch.Tensor</code>)</p>
`}}),et=new G({props:{name:"forward",anchor:"transformers.SwitchTransformersTop1Router.forward",parameters:[{name:"hidden_states",val:": Tensor"}],parametersDescription:[{anchor:"transformers.SwitchTransformersTop1Router.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code>)  &#x2014;
[num_groups, tokens_per_group, hidden_dim] inputs to send to experts.`,name:"hidden_states"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L201",returnDescription:`
<p>Tuple[<code>torch.Tensor</code>, <code>torch.Tensor</code>, <code>torch.Tensor</code>] Tuple containing the expert index, the router probs
and the router logits. The router probabilities and logits are required to compute the loss.</p>
`}}),tt=new Ne({}),ot=new G({props:{name:"class transformers.SwitchTransformersSparseMLP",anchor:"transformers.SwitchTransformersSparseMLP",parameters:[{name:"config",val:": SwitchTransformersConfig"},{name:"expert_class",val:": Module = <class 'transformers.models.switch_transformers.modeling_switch_transformers.SwitchTransformersDenseActDense'>"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L301"}}),rt=new G({props:{name:"forward",anchor:"transformers.SwitchTransformersSparseMLP.forward",parameters:[{name:"hidden_states",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L316"}}),nt=new Ne({}),st=new G({props:{name:"class transformers.SwitchTransformersModel",anchor:"transformers.SwitchTransformersModel",parameters:[{name:"config",val:": SwitchTransformersConfig"}],parametersDescription:[{anchor:"transformers.SwitchTransformersModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersConfig">SwitchTransformersConfig</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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L1336"}}),ut=new G({props:{name:"forward",anchor:"transformers.SwitchTransformersModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.SwitchTransformersModel.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. SWITCH_TRANSFORMERS is a model with relative position
embeddings so you should be able to pad the inputs on both the right and the left.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for detail.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>To know more on how to prepare <code>input_ids</code> for pretraining take a look a <a href="./switch_transformers#training">SWITCH_TRANSFORMERS
Training</a>.`,name:"input_ids"},{anchor:"transformers.SwitchTransformersModel.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.SwitchTransformersModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>SWITCH_TRANSFORMERS uses the <code>pad_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. If
<code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>To know more on how to prepare <code>decoder_input_ids</code> for pretraining take a look at <a href="./switch_transformers#training">SWITCH_TRANSFORMERS
Training</a>.`,name:"decoder_input_ids"},{anchor:"transformers.SwitchTransformersModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.SwitchTransformersModel.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 in the encoder. 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.SwitchTransformersModel.forward.decoder_head_mask",description:`<strong>decoder_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 in the decoder. 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:"decoder_head_mask"},{anchor:"transformers.SwitchTransformersModel.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</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 cross-attention modules in the decoder. 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:"cross_attn_head_mask"},{anchor:"transformers.SwitchTransformersModel.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>last_hidden_state</code>, <code>optional</code>: <em>hidden_states</em>, <code>optional</code>: <em>attentions</em>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code> is a sequence of hidden states at
the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.SwitchTransformersModel.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.SwitchTransformersModel.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.SwitchTransformersModel.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>decoder_input_ids</code> and <code>decoder_inputs_embeds</code> are both unset, <code>decoder_inputs_embeds</code> takes the value
of <code>inputs_embeds</code>.`,name:"decoder_inputs_embeds"},{anchor:"transformers.SwitchTransformersModel.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"},{anchor:"transformers.SwitchTransformersModel.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.SwitchTransformersModel.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.SwitchTransformersModel.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the logits of all the routers. They are useful for computing the router loss, and
should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.SwitchTransformersModel.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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L1382",returnDescription:`
<p>A <code>transformers.modeling_outputs.Seq2SeqMoEModelOutput</code> 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/main/en/model_doc/switch_transformers#transformers.SwitchTransformersConfig"
>SwitchTransformersConfig</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 decoder of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</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 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 in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_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, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_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 of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>decoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_router_probs=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p>
<p>Router logits of the decoder model, useful to compute the auxiliary loss for Mixture of Experts models.</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>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>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_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, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_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 of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>encoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_router_probs=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p>
<p>Router logits of the encoder model, useful to compute the auxiliary loss and the z_loss for the sparse
modules.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.modeling_outputs.Seq2SeqMoEModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ye=new Qa({props:{$$slots:{default:[Pd]},$$scope:{ctx:C}}}),ke=new ei({props:{anchor:"transformers.SwitchTransformersModel.forward.example",$$slots:{default:[Ad]},$$scope:{ctx:C}}}),mt=new Ne({}),ft=new G({props:{name:"class transformers.SwitchTransformersForConditionalGeneration",anchor:"transformers.SwitchTransformersForConditionalGeneration",parameters:[{name:"config",val:": SwitchTransformersConfig"}],parametersDescription:[{anchor:"transformers.SwitchTransformersForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersConfig">SwitchTransformersConfig</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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L1504"}}),St=new G({props:{name:"forward",anchor:"transformers.SwitchTransformersForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = True"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.SwitchTransformersForConditionalGeneration.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. SWITCH_TRANSFORMERS is a model with relative position
embeddings so you should be able to pad the inputs on both the right and the left.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for detail.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>To know more on how to prepare <code>input_ids</code> for pretraining take a look a <a href="./switch_transformers#training">SWITCH_TRANSFORMERS
Training</a>.`,name:"input_ids"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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.SwitchTransformersForConditionalGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>SWITCH_TRANSFORMERS uses the <code>pad_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. If
<code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>To know more on how to prepare <code>decoder_input_ids</code> for pretraining take a look at <a href="./switch_transformers#training">SWITCH_TRANSFORMERS
Training</a>.`,name:"decoder_input_ids"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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 in the encoder. 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.SwitchTransformersForConditionalGeneration.forward.decoder_head_mask",description:`<strong>decoder_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 in the decoder. 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:"decoder_head_mask"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</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 cross-attention modules in the decoder. 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:"cross_attn_head_mask"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>last_hidden_state</code>, <code>optional</code>: <em>hidden_states</em>, <code>optional</code>: <em>attentions</em>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code> is a sequence of hidden states at
the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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.SwitchTransformersForConditionalGeneration.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.SwitchTransformersForConditionalGeneration.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>decoder_input_ids</code> and <code>decoder_inputs_embeds</code> are both unset, <code>decoder_inputs_embeds</code> takes the value
of <code>inputs_embeds</code>.`,name:"decoder_inputs_embeds"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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.SwitchTransformersForConditionalGeneration.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.SwitchTransformersForConditionalGeneration.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the logits of all the routers. They are useful for computing the router loss, and
should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.SwitchTransformersForConditionalGeneration.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>[-100, 0, ..., config.vocab_size - 1]</code>. All labels set to <code>-100</code> are ignored (masked), the loss is only computed for
labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L1560",returnDescription:`
<p>A <code>transformers.modeling_outputs.Seq2SeqMoEOutput</code> 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/main/en/model_doc/switch_transformers#transformers.SwitchTransformersConfig"
>SwitchTransformersConfig</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.</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>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 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 in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_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, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_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 of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>decoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_router_probs=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p>
<p>Router logits of the decoder model, useful to compute the auxiliary loss for Mixture of Experts models.</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>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>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_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, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_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 of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>encoder_router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_router_probs=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p>
<p>Router logits of the encoder model, useful to compute the auxiliary loss and z_loss for Mixture of Experts
models.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.modeling_outputs.Seq2SeqMoEOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),xe=new Qa({props:{$$slots:{default:[Od]},$$scope:{ctx:C}}}),$e=new ei({props:{anchor:"transformers.SwitchTransformersForConditionalGeneration.forward.example",$$slots:{default:[Rd]},$$scope:{ctx:C}}}),xt=new Ne({}),$t=new G({props:{name:"class transformers.SwitchTransformersEncoderModel",anchor:"transformers.SwitchTransformersEncoderModel",parameters:[{name:"config",val:": SwitchTransformersConfig"}],parametersDescription:[{anchor:"transformers.SwitchTransformersEncoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersConfig">SwitchTransformersConfig</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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L1820"}}),At=new G({props:{name:"forward",anchor:"transformers.SwitchTransformersEncoderModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = True"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.SwitchTransformersEncoderModel.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. SWITCH_TRANSFORMERS is a model with relative position
embeddings so you should be able to pad the inputs on both the right and the left.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for detail.</p>
<p>To know more on how to prepare <code>input_ids</code> for pretraining take a look a <a href="./switch_transformers#training">SWITCH_TRANSFORMERS
Training</a>.`,name:"input_ids"},{anchor:"transformers.SwitchTransformersEncoderModel.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.SwitchTransformersEncoderModel.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.SwitchTransformersEncoderModel.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.SwitchTransformersEncoderModel.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.SwitchTransformersEncoderModel.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.SwitchTransformersEncoderModel.forward.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the logits of all the routers. They are useful for computing the router loss, and
should not be returned during inference.`,name:"output_router_logits"},{anchor:"transformers.SwitchTransformersEncoderModel.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/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/switch_transformers/modeling_switch_transformers.py#L1856",returnDescription:`
<p>A <code>transformers.modeling_outputs.MoEModelOutput</code> 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/main/en/model_doc/switch_transformers#transformers.SwitchTransformersConfig"
>SwitchTransformersConfig</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>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, if the model has an embedding layer, +
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 optional 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>router_probs</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_probs=True</code> and <code>config.add_router_probs=True</code> is passed or when <code>config.output_router_probs=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.</p>
<p>Raw router probabilities that are computed by MoE routers, these terms are used to compute the auxiliary
loss and the z_loss for Mixture of Experts models.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.modeling_outputs.MoEModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Me=new Qa({props:{$$slots:{default:[Nd]},$$scope:{ctx:C}}}),ze=new ei({props:{anchor:"transformers.SwitchTransformersEncoderModel.forward.example",$$slots:{default:[Id]},$$scope:{ctx:C}}}),{c(){u=s("meta"),x=c(),g=s("h1"),_=s("a"),w=s("span"),T(l.$$.fragment),f=c(),F=s("span"),qr=r("SwitchTransformers"),Zo=c(),te=s("h2"),me=s("a"),ao=s("span"),T(Ie.$$.fragment),Pr=c(),io=s("span"),Ar=r("Overview"),Uo=c(),fe=s("p"),Or=r("The SwitchTransformers model was proposed in "),je=s("a"),Rr=r("Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity"),Nr=r(" by William Fedus, Barret Zoph, Noam Shazeer."),Xo=c(),Nt=s("p"),Ir=r(`The Switch Transformer model uses a sparse T5 encoder-decoder architecure, where the MLP are replaced by a Mixture of Experts (MoE). A routing mechanism (top 1 in this case) associates each token to one of the expert, where each expert is a dense MLP. While switch transformers have a lot more weights than their equivalent dense models, the sparsity allows better scaling and better finetuning performance at scale.
During a forward pass, only a fraction of the weights are used. The routing mecanism allows the model to select relevant weights on the fly which increases the model capacity without increasing the number of operations.`),Yo=c(),It=s("p"),jr=r("The abstract from the paper is the following:"),Jo=c(),jt=s("p"),lo=s("em"),Wr=r("In deep learning, models typically reuse the same parameters for all inputs. Mixture of Experts (MoE) defies this and instead selects different parameters for each incoming example. The result is a sparsely-activated model \u2014 with outrageous numbers of parameters \u2014 but a constant computational cost. However, despite several notable successes of MoE, widespread adoption has been hindered by complexity, communication costs and training instability \u2014 we address these with the Switch Transformer. We simplify the MoE routing algorithm and design intuitive improved models with reduced communication and computational costs. Our proposed training techniques help wrangle the instabilities and we show large sparse models may be trained, for the first time, with lower precision (bfloat16) formats. We design models based off T5-Base and T5-Large to obtain up to 7x increases in pre-training speed with the same computational resources. These improvements extend into multilingual settings where we measure gains over the mT5-Base version across all 101 languages. Finally, we advance the current scale of language models by pre-training up to trillion parameter models on the \u201CColossal Clean Crawled Corpus\u201D and achieve a 4x speedup over the T5-XXL model."),Ko=c(),Wt=s("p"),Dr=r("Tips:"),Qo=c(),_e=s("ul"),We=s("li"),Lr=r("SwitchTransformers uses the "),Dt=s("a"),Br=r("T5Tokenizer"),Gr=r(", which can be loaded directly from each model\u2019s repository."),Hr=c(),De=s("li"),Vr=r("The released weights are pretrained on English "),Le=s("a"),Zr=r("Masked Language Modeling"),Ur=r(" task, and should be finetuned."),er=c(),R=s("p"),Xr=r("This model was contributed by "),Be=s("a"),Yr=r("Younes Belkada"),Jr=r(" and "),Ge=s("a"),Kr=r("Arthur Zucker"),Qr=r(` .
The original code can be found `),He=s("a"),en=r("here"),tn=r("."),tr=c(),oe=s("h2"),ge=s("a"),co=s("span"),T(Ve.$$.fragment),on=c(),ho=s("span"),rn=r("SwitchTransformersConfig"),or=c(),H=s("div"),T(Ze.$$.fragment),nn=c(),re=s("p"),sn=r("This is the configuration class to store the configuration of a "),Lt=s("a"),an=r("SwitchTransformersModel"),dn=r(`. It is used to
instantiate a SwitchTransformers 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
SwitchTransformers `),Ue=s("a"),ln=r("google/switch-base-8"),cn=r(" architecture."),hn=c(),ne=s("p"),pn=r("Configuration objects inherit from "),Bt=s("a"),un=r("PretrainedConfig"),mn=r(` and can be used to control the model outputs. Read the
documentation from `),Gt=s("a"),fn=r("PretrainedConfig"),_n=r(" for more information."),rr=c(),se=s("h2"),we=s("a"),po=s("span"),T(Xe.$$.fragment),gn=c(),uo=s("span"),wn=r("SwitchTransformersTop1Router"),nr=c(),z=s("div"),T(Ye.$$.fragment),Tn=c(),mo=s("p"),bn=r("Router using tokens choose top-1 experts assignment."),vn=c(),V=s("p"),yn=r("This router uses the same mechanism as in Switch Transformer ("),Je=s("a"),kn=r("https://arxiv.org/abs/2101.03961"),Sn=r(`) and V-MoE
(`),Ke=s("a"),xn=r("https://arxiv.org/abs/2106.05974"),$n=r(`): tokens choose their top experts. Items are sorted by router_probs and then
routed to their choice of expert until the expert\u2019s expert_capacity is reached. `),fo=s("strong"),En=r(`There is no guarantee that each
token is processed by an expert`),Mn=r(", or that each expert receives at least one token."),zn=c(),Te=s("div"),T(Qe.$$.fragment),Cn=c(),_o=s("p"),Fn=r("Computes router probabilities from input hidden states."),qn=c(),X=s("div"),T(et.$$.fragment),Pn=c(),ae=s("p"),An=r(`Generic forward function for every Router class. Each Router expects to have the same input hidden states
(`),go=s("code"),On=r("hidden_states"),Rn=r(") corresponding to the hidden states for each token, the "),wo=s("code"),Nn=r("expert_capacity"),In=r(` corresponding to the
number of tokens the Router will send to each expert, some Routers can send up to few tokens to each expert.`),jn=c(),q=s("p"),Wn=r("Each Router works as the following: it expects the hidden states for each token, gets the "),To=s("code"),Dn=r("router_probs"),Ln=r(` and
`),bo=s("code"),Bn=r("router_logits"),Gn=r(" from the "),vo=s("code"),Hn=r("router_weights"),Vn=r(`. This will assign for each token, the raw probability to be assigned
to an expert. Then each Router class will have to define its own `),yo=s("code"),Zn=r("_compute_routing_instructions"),Un=r("."),sr=c(),ie=s("h2"),be=s("a"),ko=s("span"),T(tt.$$.fragment),Xn=c(),So=s("span"),Yn=r("SwitchTransformersSparseMLP"),ar=c(),Z=s("div"),T(ot.$$.fragment),Jn=c(),xo=s("p"),Kn=r("Implementation of the Switch Transformers Sparse MLP module."),Qn=c(),N=s("div"),T(rt.$$.fragment),es=c(),$o=s("p"),ts=r("Hold on, this will be slightly tricky to understand In the correct order, a MoE layer does the following:"),os=c(),U=s("p"),rs=r("1- Gets the "),Eo=s("code"),ns=r("router_mask"),ss=r(" from the router. The shape of the mask is "),Mo=s("code"),as=r("(batch_size, sequence_length, num_expert)"),is=r(`
and corresponds to the argmax of the `),zo=s("code"),ds=r("router_probs"),ls=r(`. The probabilities are needed in the computation of the
hidden states : they are broadcasted to the hidden states values (can be interpreted as a scaling factor).`),cs=c(),Co=s("p"),hs=r(`2- Dispatch the tokens to its associated experts. We do a classic for loop over the experts and assign for each
expert the corresponding hidden states.`),ir=c(),de=s("h2"),ve=s("a"),Fo=s("span"),T(nt.$$.fragment),ps=c(),qo=s("span"),us=r("SwitchTransformersModel"),dr=c(),$=s("div"),T(st.$$.fragment),ms=c(),Po=s("p"),fs=r("The bare SWITCH_TRANSFORMERS Model transformer outputting raw hidden-states without any specific head on top."),_s=c(),P=s("p"),gs=r("The SWITCH_TRANSFORMERS model was proposed in "),at=s("a"),ws=r(`Switch Transformers: Scaling to Trillion Parameter Models with
Simple and Efficient Sparsity`),Ts=r(" by "),it=s("a"),bs=r(`William
Fedus`),vs=r(", "),dt=s("a"),ys=r(`Barret
Zoph`),ks=r(", and "),lt=s("a"),Ss=r(`Noam
Shazeer`),xs=r(`. It\u2019s an encoder-decoder T5-like model
with sparse Feed Forward that stands for Mixture of Experts (MoE) architecture.`),$s=c(),ct=s("p"),Es=r("This model inherits from "),Ht=s("a"),Ms=r("PreTrainedModel"),zs=r(`. 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.)`),Cs=c(),ht=s("p"),Fs=r("This model is also a PyTorch "),pt=s("a"),qs=r("torch.nn.Module"),Ps=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),As=c(),I=s("div"),T(ut.$$.fragment),Os=c(),le=s("p"),Rs=r("The "),Vt=s("a"),Ns=r("SwitchTransformersModel"),Is=r(" forward method, overrides the "),Ao=s("code"),js=r("__call__"),Ws=r(" special method."),Ds=c(),T(ye.$$.fragment),Ls=c(),T(ke.$$.fragment),lr=c(),ce=s("h2"),Se=s("a"),Oo=s("span"),T(mt.$$.fragment),Bs=c(),Ro=s("span"),Gs=r("SwitchTransformersForConditionalGeneration"),cr=c(),E=s("div"),T(ft.$$.fragment),Hs=c(),_t=s("p"),Vs=r("SWITCH_TRANSFORMERS Model with a "),No=s("code"),Zs=r("language modeling"),Us=r(" head on top."),Xs=c(),A=s("p"),Ys=r("The SWITCH_TRANSFORMERS model was proposed in "),gt=s("a"),Js=r(`Switch Transformers: Scaling to Trillion Parameter Models with
Simple and Efficient Sparsity`),Ks=r(" by "),wt=s("a"),Qs=r(`William
Fedus`),ea=r(", "),Tt=s("a"),ta=r(`Barret
Zoph`),oa=r(", and "),bt=s("a"),ra=r(`Noam
Shazeer`),na=r(`. It\u2019s an encoder-decoder T5-like model
with sparse Feed Forward that stands for Mixture of Experts (MoE) architecture.`),sa=c(),vt=s("p"),aa=r("This model inherits from "),Zt=s("a"),ia=r("PreTrainedModel"),da=r(`. 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=c(),yt=s("p"),ca=r("This model is also a PyTorch "),kt=s("a"),ha=r("torch.nn.Module"),pa=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ua=c(),j=s("div"),T(St.$$.fragment),ma=c(),he=s("p"),fa=r("The "),Ut=s("a"),_a=r("SwitchTransformersForConditionalGeneration"),ga=r(" forward method, overrides the "),Io=s("code"),wa=r("__call__"),Ta=r(" special method."),ba=c(),T(xe.$$.fragment),va=c(),T($e.$$.fragment),hr=c(),pe=s("h2"),Ee=s("a"),jo=s("span"),T(xt.$$.fragment),ya=c(),Wo=s("span"),ka=r("SwitchTransformersEncoderModel"),pr=c(),M=s("div"),T($t.$$.fragment),Sa=c(),Do=s("p"),xa=r("The bare SWITCH_TRANSFORMERS Model transformer outputting encoder\u2019s raw hidden-states without any specific head on top."),$a=c(),O=s("p"),Ea=r("The SWITCH_TRANSFORMERS model was proposed in "),Et=s("a"),Ma=r(`Switch Transformers: Scaling to Trillion Parameter Models with
Simple and Efficient Sparsity`),za=r(" by "),Mt=s("a"),Ca=r(`William
Fedus`),Fa=r(", "),zt=s("a"),qa=r(`Barret
Zoph`),Pa=r(", and "),Ct=s("a"),Aa=r(`Noam
Shazeer`),Oa=r(`. It\u2019s an encoder-decoder T5-like model
with sparse Feed Forward that stands for Mixture of Experts (MoE) architecture.`),Ra=c(),Ft=s("p"),Na=r("This model inherits from "),Xt=s("a"),Ia=r("PreTrainedModel"),ja=r(`. 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.)`),Wa=c(),qt=s("p"),Da=r("This model is also a PyTorch "),Pt=s("a"),La=r("torch.nn.Module"),Ba=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ga=c(),W=s("div"),T(At.$$.fragment),Ha=c(),ue=s("p"),Va=r("The "),Yt=s("a"),Za=r("SwitchTransformersEncoderModel"),Ua=r(" forward method, overrides the "),Lo=s("code"),Xa=r("__call__"),Ya=r(" special method."),Ja=c(),T(Me.$$.fragment),Ka=c(),T(ze.$$.fragment),this.h()},l(t){const p=Fd('[data-svelte="svelte-1phssyn"]',document.head);u=a(p,"META",{name:!0,content:!0}),p.forEach(o),x=h(t),g=a(t,"H1",{class:!0});var Ot=i(g);_=a(Ot,"A",{id:!0,class:!0,href:!0});var Bo=i(_);w=a(Bo,"SPAN",{});var Go=i(w);b(l.$$.fragment,Go),Go.forEach(o),Bo.forEach(o),f=h(Ot),F=a(Ot,"SPAN",{});var Ho=i(F);qr=n(Ho,"SwitchTransformers"),Ho.forEach(o),Ot.forEach(o),Zo=h(t),te=a(t,"H2",{class:!0});var Rt=i(te);me=a(Rt,"A",{id:!0,class:!0,href:!0});var Vo=i(me);ao=a(Vo,"SPAN",{});var ri=i(ao);b(Ie.$$.fragment,ri),ri.forEach(o),Vo.forEach(o),Pr=h(Rt),io=a(Rt,"SPAN",{});var ni=i(io);Ar=n(ni,"Overview"),ni.forEach(o),Rt.forEach(o),Uo=h(t),fe=a(t,"P",{});var mr=i(fe);Or=n(mr,"The SwitchTransformers model was proposed in "),je=a(mr,"A",{href:!0,rel:!0});var si=i(je);Rr=n(si,"Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity"),si.forEach(o),Nr=n(mr," by William Fedus, Barret Zoph, Noam Shazeer."),mr.forEach(o),Xo=h(t),Nt=a(t,"P",{});var ai=i(Nt);Ir=n(ai,`The Switch Transformer model uses a sparse T5 encoder-decoder architecure, where the MLP are replaced by a Mixture of Experts (MoE). A routing mechanism (top 1 in this case) associates each token to one of the expert, where each expert is a dense MLP. While switch transformers have a lot more weights than their equivalent dense models, the sparsity allows better scaling and better finetuning performance at scale.
During a forward pass, only a fraction of the weights are used. The routing mecanism allows the model to select relevant weights on the fly which increases the model capacity without increasing the number of operations.`),ai.forEach(o),Yo=h(t),It=a(t,"P",{});var ii=i(It);jr=n(ii,"The abstract from the paper is the following:"),ii.forEach(o),Jo=h(t),jt=a(t,"P",{});var di=i(jt);lo=a(di,"EM",{});var li=i(lo);Wr=n(li,"In deep learning, models typically reuse the same parameters for all inputs. Mixture of Experts (MoE) defies this and instead selects different parameters for each incoming example. The result is a sparsely-activated model \u2014 with outrageous numbers of parameters \u2014 but a constant computational cost. However, despite several notable successes of MoE, widespread adoption has been hindered by complexity, communication costs and training instability \u2014 we address these with the Switch Transformer. We simplify the MoE routing algorithm and design intuitive improved models with reduced communication and computational costs. Our proposed training techniques help wrangle the instabilities and we show large sparse models may be trained, for the first time, with lower precision (bfloat16) formats. We design models based off T5-Base and T5-Large to obtain up to 7x increases in pre-training speed with the same computational resources. These improvements extend into multilingual settings where we measure gains over the mT5-Base version across all 101 languages. Finally, we advance the current scale of language models by pre-training up to trillion parameter models on the \u201CColossal Clean Crawled Corpus\u201D and achieve a 4x speedup over the T5-XXL model."),li.forEach(o),di.forEach(o),Ko=h(t),Wt=a(t,"P",{});var ci=i(Wt);Dr=n(ci,"Tips:"),ci.forEach(o),Qo=h(t),_e=a(t,"UL",{});var fr=i(_e);We=a(fr,"LI",{});var _r=i(We);Lr=n(_r,"SwitchTransformers uses the "),Dt=a(_r,"A",{href:!0});var hi=i(Dt);Br=n(hi,"T5Tokenizer"),hi.forEach(o),Gr=n(_r,", which can be loaded directly from each model\u2019s repository."),_r.forEach(o),Hr=h(fr),De=a(fr,"LI",{});var gr=i(De);Vr=n(gr,"The released weights are pretrained on English "),Le=a(gr,"A",{href:!0,rel:!0});var pi=i(Le);Zr=n(pi,"Masked Language Modeling"),pi.forEach(o),Ur=n(gr," task, and should be finetuned."),gr.forEach(o),fr.forEach(o),er=h(t),R=a(t,"P",{});var Ce=i(R);Xr=n(Ce,"This model was contributed by "),Be=a(Ce,"A",{href:!0,rel:!0});var ui=i(Be);Yr=n(ui,"Younes Belkada"),ui.forEach(o),Jr=n(Ce," and "),Ge=a(Ce,"A",{href:!0,rel:!0});var mi=i(Ge);Kr=n(mi,"Arthur Zucker"),mi.forEach(o),Qr=n(Ce,` .
The original code can be found `),He=a(Ce,"A",{href:!0,rel:!0});var fi=i(He);en=n(fi,"here"),fi.forEach(o),tn=n(Ce,"."),Ce.forEach(o),tr=h(t),oe=a(t,"H2",{class:!0});var wr=i(oe);ge=a(wr,"A",{id:!0,class:!0,href:!0});var _i=i(ge);co=a(_i,"SPAN",{});var gi=i(co);b(Ve.$$.fragment,gi),gi.forEach(o),_i.forEach(o),on=h(wr),ho=a(wr,"SPAN",{});var wi=i(ho);rn=n(wi,"SwitchTransformersConfig"),wi.forEach(o),wr.forEach(o),or=h(t),H=a(t,"DIV",{class:!0});var Jt=i(H);b(Ze.$$.fragment,Jt),nn=h(Jt),re=a(Jt,"P",{});var Kt=i(re);sn=n(Kt,"This is the configuration class to store the configuration of a "),Lt=a(Kt,"A",{href:!0});var Ti=i(Lt);an=n(Ti,"SwitchTransformersModel"),Ti.forEach(o),dn=n(Kt,`. It is used to
instantiate a SwitchTransformers 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
SwitchTransformers `),Ue=a(Kt,"A",{href:!0,rel:!0});var bi=i(Ue);ln=n(bi,"google/switch-base-8"),bi.forEach(o),cn=n(Kt," architecture."),Kt.forEach(o),hn=h(Jt),ne=a(Jt,"P",{});var Qt=i(ne);pn=n(Qt,"Configuration objects inherit from "),Bt=a(Qt,"A",{href:!0});var vi=i(Bt);un=n(vi,"PretrainedConfig"),vi.forEach(o),mn=n(Qt,` and can be used to control the model outputs. Read the
documentation from `),Gt=a(Qt,"A",{href:!0});var yi=i(Gt);fn=n(yi,"PretrainedConfig"),yi.forEach(o),_n=n(Qt," for more information."),Qt.forEach(o),Jt.forEach(o),rr=h(t),se=a(t,"H2",{class:!0});var Tr=i(se);we=a(Tr,"A",{id:!0,class:!0,href:!0});var ki=i(we);po=a(ki,"SPAN",{});var Si=i(po);b(Xe.$$.fragment,Si),Si.forEach(o),ki.forEach(o),gn=h(Tr),uo=a(Tr,"SPAN",{});var xi=i(uo);wn=n(xi,"SwitchTransformersTop1Router"),xi.forEach(o),Tr.forEach(o),nr=h(t),z=a(t,"DIV",{class:!0});var Y=i(z);b(Ye.$$.fragment,Y),Tn=h(Y),mo=a(Y,"P",{});var $i=i(mo);bn=n($i,"Router using tokens choose top-1 experts assignment."),$i.forEach(o),vn=h(Y),V=a(Y,"P",{});var Fe=i(V);yn=n(Fe,"This router uses the same mechanism as in Switch Transformer ("),Je=a(Fe,"A",{href:!0,rel:!0});var Ei=i(Je);kn=n(Ei,"https://arxiv.org/abs/2101.03961"),Ei.forEach(o),Sn=n(Fe,`) and V-MoE
(`),Ke=a(Fe,"A",{href:!0,rel:!0});var Mi=i(Ke);xn=n(Mi,"https://arxiv.org/abs/2106.05974"),Mi.forEach(o),$n=n(Fe,`): tokens choose their top experts. Items are sorted by router_probs and then
routed to their choice of expert until the expert\u2019s expert_capacity is reached. `),fo=a(Fe,"STRONG",{});var zi=i(fo);En=n(zi,`There is no guarantee that each
token is processed by an expert`),zi.forEach(o),Mn=n(Fe,", or that each expert receives at least one token."),Fe.forEach(o),zn=h(Y),Te=a(Y,"DIV",{class:!0});var br=i(Te);b(Qe.$$.fragment,br),Cn=h(br),_o=a(br,"P",{});var Ci=i(_o);Fn=n(Ci,"Computes router probabilities from input hidden states."),Ci.forEach(o),br.forEach(o),qn=h(Y),X=a(Y,"DIV",{class:!0});var eo=i(X);b(et.$$.fragment,eo),Pn=h(eo),ae=a(eo,"P",{});var to=i(ae);An=n(to,`Generic forward function for every Router class. Each Router expects to have the same input hidden states
(`),go=a(to,"CODE",{});var Fi=i(go);On=n(Fi,"hidden_states"),Fi.forEach(o),Rn=n(to,") corresponding to the hidden states for each token, the "),wo=a(to,"CODE",{});var qi=i(wo);Nn=n(qi,"expert_capacity"),qi.forEach(o),In=n(to,` corresponding to the
number of tokens the Router will send to each expert, some Routers can send up to few tokens to each expert.`),to.forEach(o),jn=h(eo),q=a(eo,"P",{});var J=i(q);Wn=n(J,"Each Router works as the following: it expects the hidden states for each token, gets the "),To=a(J,"CODE",{});var Pi=i(To);Dn=n(Pi,"router_probs"),Pi.forEach(o),Ln=n(J,` and
`),bo=a(J,"CODE",{});var Ai=i(bo);Bn=n(Ai,"router_logits"),Ai.forEach(o),Gn=n(J," from the "),vo=a(J,"CODE",{});var Oi=i(vo);Hn=n(Oi,"router_weights"),Oi.forEach(o),Vn=n(J,`. This will assign for each token, the raw probability to be assigned
to an expert. Then each Router class will have to define its own `),yo=a(J,"CODE",{});var Ri=i(yo);Zn=n(Ri,"_compute_routing_instructions"),Ri.forEach(o),Un=n(J,"."),J.forEach(o),eo.forEach(o),Y.forEach(o),sr=h(t),ie=a(t,"H2",{class:!0});var vr=i(ie);be=a(vr,"A",{id:!0,class:!0,href:!0});var Ni=i(be);ko=a(Ni,"SPAN",{});var Ii=i(ko);b(tt.$$.fragment,Ii),Ii.forEach(o),Ni.forEach(o),Xn=h(vr),So=a(vr,"SPAN",{});var ji=i(So);Yn=n(ji,"SwitchTransformersSparseMLP"),ji.forEach(o),vr.forEach(o),ar=h(t),Z=a(t,"DIV",{class:!0});var oo=i(Z);b(ot.$$.fragment,oo),Jn=h(oo),xo=a(oo,"P",{});var Wi=i(xo);Kn=n(Wi,"Implementation of the Switch Transformers Sparse MLP module."),Wi.forEach(o),Qn=h(oo),N=a(oo,"DIV",{class:!0});var qe=i(N);b(rt.$$.fragment,qe),es=h(qe),$o=a(qe,"P",{});var Di=i($o);ts=n(Di,"Hold on, this will be slightly tricky to understand In the correct order, a MoE layer does the following:"),Di.forEach(o),os=h(qe),U=a(qe,"P",{});var Pe=i(U);rs=n(Pe,"1- Gets the "),Eo=a(Pe,"CODE",{});var Li=i(Eo);ns=n(Li,"router_mask"),Li.forEach(o),ss=n(Pe," from the router. The shape of the mask is "),Mo=a(Pe,"CODE",{});var Bi=i(Mo);as=n(Bi,"(batch_size, sequence_length, num_expert)"),Bi.forEach(o),is=n(Pe,`
and corresponds to the argmax of the `),zo=a(Pe,"CODE",{});var Gi=i(zo);ds=n(Gi,"router_probs"),Gi.forEach(o),ls=n(Pe,`. The probabilities are needed in the computation of the
hidden states : they are broadcasted to the hidden states values (can be interpreted as a scaling factor).`),Pe.forEach(o),cs=h(qe),Co=a(qe,"P",{});var Hi=i(Co);hs=n(Hi,`2- Dispatch the tokens to its associated experts. We do a classic for loop over the experts and assign for each
expert the corresponding hidden states.`),Hi.forEach(o),qe.forEach(o),oo.forEach(o),ir=h(t),de=a(t,"H2",{class:!0});var yr=i(de);ve=a(yr,"A",{id:!0,class:!0,href:!0});var Vi=i(ve);Fo=a(Vi,"SPAN",{});var Zi=i(Fo);b(nt.$$.fragment,Zi),Zi.forEach(o),Vi.forEach(o),ps=h(yr),qo=a(yr,"SPAN",{});var Ui=i(qo);us=n(Ui,"SwitchTransformersModel"),Ui.forEach(o),yr.forEach(o),dr=h(t),$=a(t,"DIV",{class:!0});var D=i($);b(st.$$.fragment,D),ms=h(D),Po=a(D,"P",{});var Xi=i(Po);fs=n(Xi,"The bare SWITCH_TRANSFORMERS Model transformer outputting raw hidden-states without any specific head on top."),Xi.forEach(o),_s=h(D),P=a(D,"P",{});var K=i(P);gs=n(K,"The SWITCH_TRANSFORMERS model was proposed in "),at=a(K,"A",{href:!0,rel:!0});var Yi=i(at);ws=n(Yi,`Switch Transformers: Scaling to Trillion Parameter Models with
Simple and Efficient Sparsity`),Yi.forEach(o),Ts=n(K," by "),it=a(K,"A",{href:!0,rel:!0});var Ji=i(it);bs=n(Ji,`William
Fedus`),Ji.forEach(o),vs=n(K,", "),dt=a(K,"A",{href:!0,rel:!0});var Ki=i(dt);ys=n(Ki,`Barret
Zoph`),Ki.forEach(o),ks=n(K,", and "),lt=a(K,"A",{href:!0,rel:!0});var Qi=i(lt);Ss=n(Qi,`Noam
Shazeer`),Qi.forEach(o),xs=n(K,`. It\u2019s an encoder-decoder T5-like model
with sparse Feed Forward that stands for Mixture of Experts (MoE) architecture.`),K.forEach(o),$s=h(D),ct=a(D,"P",{});var kr=i(ct);Es=n(kr,"This model inherits from "),Ht=a(kr,"A",{href:!0});var ed=i(Ht);Ms=n(ed,"PreTrainedModel"),ed.forEach(o),zs=n(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),Cs=h(D),ht=a(D,"P",{});var Sr=i(ht);Fs=n(Sr,"This model is also a PyTorch "),pt=a(Sr,"A",{href:!0,rel:!0});var td=i(pt);qs=n(td,"torch.nn.Module"),td.forEach(o),Ps=n(Sr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Sr.forEach(o),As=h(D),I=a(D,"DIV",{class:!0});var Ae=i(I);b(ut.$$.fragment,Ae),Os=h(Ae),le=a(Ae,"P",{});var ro=i(le);Rs=n(ro,"The "),Vt=a(ro,"A",{href:!0});var od=i(Vt);Ns=n(od,"SwitchTransformersModel"),od.forEach(o),Is=n(ro," forward method, overrides the "),Ao=a(ro,"CODE",{});var rd=i(Ao);js=n(rd,"__call__"),rd.forEach(o),Ws=n(ro," special method."),ro.forEach(o),Ds=h(Ae),b(ye.$$.fragment,Ae),Ls=h(Ae),b(ke.$$.fragment,Ae),Ae.forEach(o),D.forEach(o),lr=h(t),ce=a(t,"H2",{class:!0});var xr=i(ce);Se=a(xr,"A",{id:!0,class:!0,href:!0});var nd=i(Se);Oo=a(nd,"SPAN",{});var sd=i(Oo);b(mt.$$.fragment,sd),sd.forEach(o),nd.forEach(o),Bs=h(xr),Ro=a(xr,"SPAN",{});var ad=i(Ro);Gs=n(ad,"SwitchTransformersForConditionalGeneration"),ad.forEach(o),xr.forEach(o),cr=h(t),E=a(t,"DIV",{class:!0});var L=i(E);b(ft.$$.fragment,L),Hs=h(L),_t=a(L,"P",{});var $r=i(_t);Vs=n($r,"SWITCH_TRANSFORMERS Model with a "),No=a($r,"CODE",{});var id=i(No);Zs=n(id,"language modeling"),id.forEach(o),Us=n($r," head on top."),$r.forEach(o),Xs=h(L),A=a(L,"P",{});var Q=i(A);Ys=n(Q,"The SWITCH_TRANSFORMERS model was proposed in "),gt=a(Q,"A",{href:!0,rel:!0});var dd=i(gt);Js=n(dd,`Switch Transformers: Scaling to Trillion Parameter Models with
Simple and Efficient Sparsity`),dd.forEach(o),Ks=n(Q," by "),wt=a(Q,"A",{href:!0,rel:!0});var ld=i(wt);Qs=n(ld,`William
Fedus`),ld.forEach(o),ea=n(Q,", "),Tt=a(Q,"A",{href:!0,rel:!0});var cd=i(Tt);ta=n(cd,`Barret
Zoph`),cd.forEach(o),oa=n(Q,", and "),bt=a(Q,"A",{href:!0,rel:!0});var hd=i(bt);ra=n(hd,`Noam
Shazeer`),hd.forEach(o),na=n(Q,`. It\u2019s an encoder-decoder T5-like model
with sparse Feed Forward that stands for Mixture of Experts (MoE) architecture.`),Q.forEach(o),sa=h(L),vt=a(L,"P",{});var Er=i(vt);aa=n(Er,"This model inherits from "),Zt=a(Er,"A",{href:!0});var pd=i(Zt);ia=n(pd,"PreTrainedModel"),pd.forEach(o),da=n(Er,`. 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.)`),Er.forEach(o),la=h(L),yt=a(L,"P",{});var Mr=i(yt);ca=n(Mr,"This model is also a PyTorch "),kt=a(Mr,"A",{href:!0,rel:!0});var ud=i(kt);ha=n(ud,"torch.nn.Module"),ud.forEach(o),pa=n(Mr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Mr.forEach(o),ua=h(L),j=a(L,"DIV",{class:!0});var Oe=i(j);b(St.$$.fragment,Oe),ma=h(Oe),he=a(Oe,"P",{});var no=i(he);fa=n(no,"The "),Ut=a(no,"A",{href:!0});var md=i(Ut);_a=n(md,"SwitchTransformersForConditionalGeneration"),md.forEach(o),ga=n(no," forward method, overrides the "),Io=a(no,"CODE",{});var fd=i(Io);wa=n(fd,"__call__"),fd.forEach(o),Ta=n(no," special method."),no.forEach(o),ba=h(Oe),b(xe.$$.fragment,Oe),va=h(Oe),b($e.$$.fragment,Oe),Oe.forEach(o),L.forEach(o),hr=h(t),pe=a(t,"H2",{class:!0});var zr=i(pe);Ee=a(zr,"A",{id:!0,class:!0,href:!0});var _d=i(Ee);jo=a(_d,"SPAN",{});var gd=i(jo);b(xt.$$.fragment,gd),gd.forEach(o),_d.forEach(o),ya=h(zr),Wo=a(zr,"SPAN",{});var wd=i(Wo);ka=n(wd,"SwitchTransformersEncoderModel"),wd.forEach(o),zr.forEach(o),pr=h(t),M=a(t,"DIV",{class:!0});var B=i(M);b($t.$$.fragment,B),Sa=h(B),Do=a(B,"P",{});var Td=i(Do);xa=n(Td,"The bare SWITCH_TRANSFORMERS Model transformer outputting encoder\u2019s raw hidden-states without any specific head on top."),Td.forEach(o),$a=h(B),O=a(B,"P",{});var ee=i(O);Ea=n(ee,"The SWITCH_TRANSFORMERS model was proposed in "),Et=a(ee,"A",{href:!0,rel:!0});var bd=i(Et);Ma=n(bd,`Switch Transformers: Scaling to Trillion Parameter Models with
Simple and Efficient Sparsity`),bd.forEach(o),za=n(ee," by "),Mt=a(ee,"A",{href:!0,rel:!0});var vd=i(Mt);Ca=n(vd,`William
Fedus`),vd.forEach(o),Fa=n(ee,", "),zt=a(ee,"A",{href:!0,rel:!0});var yd=i(zt);qa=n(yd,`Barret
Zoph`),yd.forEach(o),Pa=n(ee,", and "),Ct=a(ee,"A",{href:!0,rel:!0});var kd=i(Ct);Aa=n(kd,`Noam
Shazeer`),kd.forEach(o),Oa=n(ee,`. It\u2019s an encoder-decoder T5-like model
with sparse Feed Forward that stands for Mixture of Experts (MoE) architecture.`),ee.forEach(o),Ra=h(B),Ft=a(B,"P",{});var Cr=i(Ft);Na=n(Cr,"This model inherits from "),Xt=a(Cr,"A",{href:!0});var Sd=i(Xt);Ia=n(Sd,"PreTrainedModel"),Sd.forEach(o),ja=n(Cr,`. 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.)`),Cr.forEach(o),Wa=h(B),qt=a(B,"P",{});var Fr=i(qt);Da=n(Fr,"This model is also a PyTorch "),Pt=a(Fr,"A",{href:!0,rel:!0});var xd=i(Pt);La=n(xd,"torch.nn.Module"),xd.forEach(o),Ba=n(Fr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Fr.forEach(o),Ga=h(B),W=a(B,"DIV",{class:!0});var Re=i(W);b(At.$$.fragment,Re),Ha=h(Re),ue=a(Re,"P",{});var so=i(ue);Va=n(so,"The "),Yt=a(so,"A",{href:!0});var $d=i(Yt);Za=n($d,"SwitchTransformersEncoderModel"),$d.forEach(o),Ua=n(so," forward method, overrides the "),Lo=a(so,"CODE",{});var Ed=i(Lo);Xa=n(Ed,"__call__"),Ed.forEach(o),Ya=n(so," special method."),so.forEach(o),Ja=h(Re),b(Me.$$.fragment,Re),Ka=h(Re),b(ze.$$.fragment,Re),Re.forEach(o),B.forEach(o),this.h()},h(){d(u,"name","hf:doc:metadata"),d(u,"content",JSON.stringify(Wd)),d(_,"id","switchtransformers"),d(_,"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"),d(_,"href","#switchtransformers"),d(g,"class","relative group"),d(me,"id","overview"),d(me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(me,"href","#overview"),d(te,"class","relative group"),d(je,"href","https://arxiv.org/abs/2101.03961"),d(je,"rel","nofollow"),d(Dt,"href","/docs/transformers/main/en/model_doc/t5#transformers.T5Tokenizer"),d(Le,"href","https://moon-ci-docs.huggingface.co/docs/transformers/pr_19323/en/glossary#general-terms"),d(Le,"rel","nofollow"),d(Be,"href","https://huggingface.co/ybelkada"),d(Be,"rel","nofollow"),d(Ge,"href","https://huggingface.co/ArtZucker"),d(Ge,"rel","nofollow"),d(He,"href","https://github.com/google/flaxformer/tree/main/flaxformer/architectures/moe"),d(He,"rel","nofollow"),d(ge,"id","transformers.SwitchTransformersConfig"),d(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"),d(ge,"href","#transformers.SwitchTransformersConfig"),d(oe,"class","relative group"),d(Lt,"href","/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersModel"),d(Ue,"href","https://huggingface.co/google/switch-base-8"),d(Ue,"rel","nofollow"),d(Bt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),d(Gt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),d(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(we,"id","transformers.SwitchTransformersTop1Router"),d(we,"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"),d(we,"href","#transformers.SwitchTransformersTop1Router"),d(se,"class","relative group"),d(Je,"href","https://arxiv.org/abs/2101.03961"),d(Je,"rel","nofollow"),d(Ke,"href","https://arxiv.org/abs/2106.05974"),d(Ke,"rel","nofollow"),d(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(be,"id","transformers.SwitchTransformersSparseMLP"),d(be,"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"),d(be,"href","#transformers.SwitchTransformersSparseMLP"),d(ie,"class","relative group"),d(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ve,"id","transformers.SwitchTransformersModel"),d(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"),d(ve,"href","#transformers.SwitchTransformersModel"),d(de,"class","relative group"),d(at,"href","https://arxiv.org/abs/2101.03961"),d(at,"rel","nofollow"),d(it,"href","https://arxiv.org/search/cs?searchtype=author&query=Fedus%2C+W"),d(it,"rel","nofollow"),d(dt,"href","https://arxiv.org/search/cs?searchtype=author&query=Zoph%2C+B"),d(dt,"rel","nofollow"),d(lt,"href","https://arxiv.org/search/cs?searchtype=author&query=Shazeer%2C+N"),d(lt,"rel","nofollow"),d(Ht,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),d(pt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(pt,"rel","nofollow"),d(Vt,"href","/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersModel"),d(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Se,"id","transformers.SwitchTransformersForConditionalGeneration"),d(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Se,"href","#transformers.SwitchTransformersForConditionalGeneration"),d(ce,"class","relative group"),d(gt,"href","https://arxiv.org/abs/2101.03961"),d(gt,"rel","nofollow"),d(wt,"href","https://arxiv.org/search/cs?searchtype=author&query=Fedus%2C+W"),d(wt,"rel","nofollow"),d(Tt,"href","https://arxiv.org/search/cs?searchtype=author&query=Zoph%2C+B"),d(Tt,"rel","nofollow"),d(bt,"href","https://arxiv.org/search/cs?searchtype=author&query=Shazeer%2C+N"),d(bt,"rel","nofollow"),d(Zt,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),d(kt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(kt,"rel","nofollow"),d(Ut,"href","/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersForConditionalGeneration"),d(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Ee,"id","transformers.SwitchTransformersEncoderModel"),d(Ee,"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"),d(Ee,"href","#transformers.SwitchTransformersEncoderModel"),d(pe,"class","relative group"),d(Et,"href","https://arxiv.org/abs/2101.03961"),d(Et,"rel","nofollow"),d(Mt,"href","https://arxiv.org/search/cs?searchtype=author&query=Fedus%2C+W"),d(Mt,"rel","nofollow"),d(zt,"href","https://arxiv.org/search/cs?searchtype=author&query=Zoph%2C+B"),d(zt,"rel","nofollow"),d(Ct,"href","https://arxiv.org/search/cs?searchtype=author&query=Shazeer%2C+N"),d(Ct,"rel","nofollow"),d(Xt,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),d(Pt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(Pt,"rel","nofollow"),d(Yt,"href","/docs/transformers/main/en/model_doc/switch_transformers#transformers.SwitchTransformersEncoderModel"),d(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,p){e(document.head,u),m(t,x,p),m(t,g,p),e(g,_),e(_,w),v(l,w,null),e(g,f),e(g,F),e(F,qr),m(t,Zo,p),m(t,te,p),e(te,me),e(me,ao),v(Ie,ao,null),e(te,Pr),e(te,io),e(io,Ar),m(t,Uo,p),m(t,fe,p),e(fe,Or),e(fe,je),e(je,Rr),e(fe,Nr),m(t,Xo,p),m(t,Nt,p),e(Nt,Ir),m(t,Yo,p),m(t,It,p),e(It,jr),m(t,Jo,p),m(t,jt,p),e(jt,lo),e(lo,Wr),m(t,Ko,p),m(t,Wt,p),e(Wt,Dr),m(t,Qo,p),m(t,_e,p),e(_e,We),e(We,Lr),e(We,Dt),e(Dt,Br),e(We,Gr),e(_e,Hr),e(_e,De),e(De,Vr),e(De,Le),e(Le,Zr),e(De,Ur),m(t,er,p),m(t,R,p),e(R,Xr),e(R,Be),e(Be,Yr),e(R,Jr),e(R,Ge),e(Ge,Kr),e(R,Qr),e(R,He),e(He,en),e(R,tn),m(t,tr,p),m(t,oe,p),e(oe,ge),e(ge,co),v(Ve,co,null),e(oe,on),e(oe,ho),e(ho,rn),m(t,or,p),m(t,H,p),v(Ze,H,null),e(H,nn),e(H,re),e(re,sn),e(re,Lt),e(Lt,an),e(re,dn),e(re,Ue),e(Ue,ln),e(re,cn),e(H,hn),e(H,ne),e(ne,pn),e(ne,Bt),e(Bt,un),e(ne,mn),e(ne,Gt),e(Gt,fn),e(ne,_n),m(t,rr,p),m(t,se,p),e(se,we),e(we,po),v(Xe,po,null),e(se,gn),e(se,uo),e(uo,wn),m(t,nr,p),m(t,z,p),v(Ye,z,null),e(z,Tn),e(z,mo),e(mo,bn),e(z,vn),e(z,V),e(V,yn),e(V,Je),e(Je,kn),e(V,Sn),e(V,Ke),e(Ke,xn),e(V,$n),e(V,fo),e(fo,En),e(V,Mn),e(z,zn),e(z,Te),v(Qe,Te,null),e(Te,Cn),e(Te,_o),e(_o,Fn),e(z,qn),e(z,X),v(et,X,null),e(X,Pn),e(X,ae),e(ae,An),e(ae,go),e(go,On),e(ae,Rn),e(ae,wo),e(wo,Nn),e(ae,In),e(X,jn),e(X,q),e(q,Wn),e(q,To),e(To,Dn),e(q,Ln),e(q,bo),e(bo,Bn),e(q,Gn),e(q,vo),e(vo,Hn),e(q,Vn),e(q,yo),e(yo,Zn),e(q,Un),m(t,sr,p),m(t,ie,p),e(ie,be),e(be,ko),v(tt,ko,null),e(ie,Xn),e(ie,So),e(So,Yn),m(t,ar,p),m(t,Z,p),v(ot,Z,null),e(Z,Jn),e(Z,xo),e(xo,Kn),e(Z,Qn),e(Z,N),v(rt,N,null),e(N,es),e(N,$o),e($o,ts),e(N,os),e(N,U),e(U,rs),e(U,Eo),e(Eo,ns),e(U,ss),e(U,Mo),e(Mo,as),e(U,is),e(U,zo),e(zo,ds),e(U,ls),e(N,cs),e(N,Co),e(Co,hs),m(t,ir,p),m(t,de,p),e(de,ve),e(ve,Fo),v(nt,Fo,null),e(de,ps),e(de,qo),e(qo,us),m(t,dr,p),m(t,$,p),v(st,$,null),e($,ms),e($,Po),e(Po,fs),e($,_s),e($,P),e(P,gs),e(P,at),e(at,ws),e(P,Ts),e(P,it),e(it,bs),e(P,vs),e(P,dt),e(dt,ys),e(P,ks),e(P,lt),e(lt,Ss),e(P,xs),e($,$s),e($,ct),e(ct,Es),e(ct,Ht),e(Ht,Ms),e(ct,zs),e($,Cs),e($,ht),e(ht,Fs),e(ht,pt),e(pt,qs),e(ht,Ps),e($,As),e($,I),v(ut,I,null),e(I,Os),e(I,le),e(le,Rs),e(le,Vt),e(Vt,Ns),e(le,Is),e(le,Ao),e(Ao,js),e(le,Ws),e(I,Ds),v(ye,I,null),e(I,Ls),v(ke,I,null),m(t,lr,p),m(t,ce,p),e(ce,Se),e(Se,Oo),v(mt,Oo,null),e(ce,Bs),e(ce,Ro),e(Ro,Gs),m(t,cr,p),m(t,E,p),v(ft,E,null),e(E,Hs),e(E,_t),e(_t,Vs),e(_t,No),e(No,Zs),e(_t,Us),e(E,Xs),e(E,A),e(A,Ys),e(A,gt),e(gt,Js),e(A,Ks),e(A,wt),e(wt,Qs),e(A,ea),e(A,Tt),e(Tt,ta),e(A,oa),e(A,bt),e(bt,ra),e(A,na),e(E,sa),e(E,vt),e(vt,aa),e(vt,Zt),e(Zt,ia),e(vt,da),e(E,la),e(E,yt),e(yt,ca),e(yt,kt),e(kt,ha),e(yt,pa),e(E,ua),e(E,j),v(St,j,null),e(j,ma),e(j,he),e(he,fa),e(he,Ut),e(Ut,_a),e(he,ga),e(he,Io),e(Io,wa),e(he,Ta),e(j,ba),v(xe,j,null),e(j,va),v($e,j,null),m(t,hr,p),m(t,pe,p),e(pe,Ee),e(Ee,jo),v(xt,jo,null),e(pe,ya),e(pe,Wo),e(Wo,ka),m(t,pr,p),m(t,M,p),v($t,M,null),e(M,Sa),e(M,Do),e(Do,xa),e(M,$a),e(M,O),e(O,Ea),e(O,Et),e(Et,Ma),e(O,za),e(O,Mt),e(Mt,Ca),e(O,Fa),e(O,zt),e(zt,qa),e(O,Pa),e(O,Ct),e(Ct,Aa),e(O,Oa),e(M,Ra),e(M,Ft),e(Ft,Na),e(Ft,Xt),e(Xt,Ia),e(Ft,ja),e(M,Wa),e(M,qt),e(qt,Da),e(qt,Pt),e(Pt,La),e(qt,Ba),e(M,Ga),e(M,W),v(At,W,null),e(W,Ha),e(W,ue),e(ue,Va),e(ue,Yt),e(Yt,Za),e(ue,Ua),e(ue,Lo),e(Lo,Xa),e(ue,Ya),e(W,Ja),v(Me,W,null),e(W,Ka),v(ze,W,null),ur=!0},p(t,[p]){const Ot={};p&2&&(Ot.$$scope={dirty:p,ctx:t}),ye.$set(Ot);const Bo={};p&2&&(Bo.$$scope={dirty:p,ctx:t}),ke.$set(Bo);const Go={};p&2&&(Go.$$scope={dirty:p,ctx:t}),xe.$set(Go);const Ho={};p&2&&(Ho.$$scope={dirty:p,ctx:t}),$e.$set(Ho);const Rt={};p&2&&(Rt.$$scope={dirty:p,ctx:t}),Me.$set(Rt);const Vo={};p&2&&(Vo.$$scope={dirty:p,ctx:t}),ze.$set(Vo)},i(t){ur||(y(l.$$.fragment,t),y(Ie.$$.fragment,t),y(Ve.$$.fragment,t),y(Ze.$$.fragment,t),y(Xe.$$.fragment,t),y(Ye.$$.fragment,t),y(Qe.$$.fragment,t),y(et.$$.fragment,t),y(tt.$$.fragment,t),y(ot.$$.fragment,t),y(rt.$$.fragment,t),y(nt.$$.fragment,t),y(st.$$.fragment,t),y(ut.$$.fragment,t),y(ye.$$.fragment,t),y(ke.$$.fragment,t),y(mt.$$.fragment,t),y(ft.$$.fragment,t),y(St.$$.fragment,t),y(xe.$$.fragment,t),y($e.$$.fragment,t),y(xt.$$.fragment,t),y($t.$$.fragment,t),y(At.$$.fragment,t),y(Me.$$.fragment,t),y(ze.$$.fragment,t),ur=!0)},o(t){k(l.$$.fragment,t),k(Ie.$$.fragment,t),k(Ve.$$.fragment,t),k(Ze.$$.fragment,t),k(Xe.$$.fragment,t),k(Ye.$$.fragment,t),k(Qe.$$.fragment,t),k(et.$$.fragment,t),k(tt.$$.fragment,t),k(ot.$$.fragment,t),k(rt.$$.fragment,t),k(nt.$$.fragment,t),k(st.$$.fragment,t),k(ut.$$.fragment,t),k(ye.$$.fragment,t),k(ke.$$.fragment,t),k(mt.$$.fragment,t),k(ft.$$.fragment,t),k(St.$$.fragment,t),k(xe.$$.fragment,t),k($e.$$.fragment,t),k(xt.$$.fragment,t),k($t.$$.fragment,t),k(At.$$.fragment,t),k(Me.$$.fragment,t),k(ze.$$.fragment,t),ur=!1},d(t){o(u),t&&o(x),t&&o(g),S(l),t&&o(Zo),t&&o(te),S(Ie),t&&o(Uo),t&&o(fe),t&&o(Xo),t&&o(Nt),t&&o(Yo),t&&o(It),t&&o(Jo),t&&o(jt),t&&o(Ko),t&&o(Wt),t&&o(Qo),t&&o(_e),t&&o(er),t&&o(R),t&&o(tr),t&&o(oe),S(Ve),t&&o(or),t&&o(H),S(Ze),t&&o(rr),t&&o(se),S(Xe),t&&o(nr),t&&o(z),S(Ye),S(Qe),S(et),t&&o(sr),t&&o(ie),S(tt),t&&o(ar),t&&o(Z),S(ot),S(rt),t&&o(ir),t&&o(de),S(nt),t&&o(dr),t&&o($),S(st),S(ut),S(ye),S(ke),t&&o(lr),t&&o(ce),S(mt),t&&o(cr),t&&o(E),S(ft),S(St),S(xe),S($e),t&&o(hr),t&&o(pe),S(xt),t&&o(pr),t&&o(M),S($t),S(At),S(Me),S(ze)}}}const Wd={local:"switchtransformers",sections:[{local:"overview",title:"Overview"},{local:"transformers.SwitchTransformersConfig",title:"SwitchTransformersConfig"},{local:"transformers.SwitchTransformersTop1Router",title:"SwitchTransformersTop1Router"},{local:"transformers.SwitchTransformersSparseMLP",title:"SwitchTransformersSparseMLP"},{local:"transformers.SwitchTransformersModel",title:"SwitchTransformersModel"},{local:"transformers.SwitchTransformersForConditionalGeneration",title:"SwitchTransformersForConditionalGeneration"},{local:"transformers.SwitchTransformersEncoderModel",title:"SwitchTransformersEncoderModel"}],title:"SwitchTransformers"};function Dd(C){return qd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ud extends Md{constructor(u){super();zd(this,u,Dd,jd,Cd,{})}}export{Ud as default,Wd as metadata};
