import{S as xc,i as Wc,s as Zc,e as r,k as h,w as y,t as a,M as Ic,c as i,d as o,m,a as l,x as w,h as s,b as u,G as e,g as M,y as v,q as T,o as k,B as $,v as qc,L as ve}from"../../chunks/vendor-hf-doc-builder.js";import{T as ho}from"../../chunks/Tip-hf-doc-builder.js";import{D as B}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Te}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as te}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as we}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Bc(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME1lZ2FDb25maWclMkMlMjBNZWdhTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwTWVnYSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwTWVnYUNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBNZWdhTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MegaConfig, MegaModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Mega configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = MegaConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){d=r("p"),b=a("Examples:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Examples:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Gc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Ac(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhTW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaModel.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=r("p"),b=a("Example:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Nc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Xc(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhRm9yQ2F1c2FsTE0lMkMlMjBBdXRvQ29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJtbmF5bG9yJTJGbWVnYS1iYXNlLXdpa2l0ZXh0JTIyKSUwQWNvbmZpZyUyMCUzRCUyMEF1dG9Db25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBY29uZmlnLmlzX2RlY29kZXIlMjAlM0QlMjBUcnVlJTBBY29uZmlnLmJpZGlyZWN0aW9uYWwlMjAlM0QlMjBGYWxzZSUwQW1vZGVsJTIwJTNEJTIwTWVnYUZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJtbmF5bG9yJTJGbWVnYS1iYXNlLXdpa2l0ZXh0JTIyJTJDJTIwY29uZmlnJTNEY29uZmlnJTJDJTIwaWdub3JlX21pc21hdGNoZWRfc2l6ZXMlM0RUcnVlJTBBKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBcHJlZGljdGlvbl9sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForCausalLM, AutoConfig
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>config.is_decoder = <span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config.bidirectional = <span class="hljs-literal">False</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForCausalLM.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>, config=config, ignore_mismatched_sizes=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>prediction_logits = outputs.logits`}}),{c(){d=r("p"),b=a("Example:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Rc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Vc(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhRm9yTWFza2VkTE0lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoZSUyMGNhcGl0YWwlMjBvZiUyMEZyYW5jZSUyMGlzJTIwJTNDbWFzayUzRS4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBJTIzJTIwcmV0cmlldmUlMjBpbmRleCUyMG9mJTIwJTNDbWFzayUzRSUwQW1hc2tfdG9rZW5faW5kZXglMjAlM0QlMjAoaW5wdXRzLmlucHV0X2lkcyUyMCUzRCUzRCUyMHRva2VuaXplci5tYXNrX3Rva2VuX2lkKSU1QjAlNUQubm9uemVybyhhc190dXBsZSUzRFRydWUpJTVCMCU1RCUwQSUwQXByZWRpY3RlZF90b2tlbl9pZCUyMCUzRCUyMGxvZ2l0cyU1QjAlMkMlMjBtYXNrX3Rva2VuX2luZGV4JTVELmFyZ21heChheGlzJTNELTEpJTBBdG9rZW5pemVyLmRlY29kZShwcmVkaWN0ZWRfdG9rZW5faWQpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoZSUyMGNhcGl0YWwlMjBvZiUyMEZyYW5jZSUyMGlzJTIwUGFyaXMuJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEElMjMlMjBtYXNrJTIwbGFiZWxzJTIwb2YlMjBub24tJTNDbWFzayUzRSUyMHRva2VucyUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLndoZXJlKGlucHV0cy5pbnB1dF9pZHMlMjAlM0QlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCUyQyUyMGxhYmVscyUyQyUyMC0xMDApJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKSUwQXJvdW5kKG91dHB1dHMubG9zcy5pdGVtKCklMkMlMjAyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForMaskedLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForMaskedLM.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;The capital of France is &lt;mask&gt;.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># retrieve index of &lt;mask&gt;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[<span class="hljs-number">0</span>].nonzero(as_tuple=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_id = logits[<span class="hljs-number">0</span>, mask_token_index].argmax(axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(predicted_token_id)
<span class="hljs-string">&#x27; Paris&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;The capital of France is Paris.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># mask labels of non-&lt;mask&gt; tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.where(inputs.input_ids == tokenizer.mask_token_id, labels, -<span class="hljs-number">100</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">round</span>(outputs.loss.item(), <span class="hljs-number">2</span>)
<span class="hljs-number">0.1</span>`}}),{c(){d=r("p"),b=a("Example:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Sc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Lc(j){let d,b,g,p,_;return p=new Te({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyME1lZ2FGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybW5heWxvciUyRm1lZ2EtYmFzZS13aWtpdGV4dCUyMiklMEFtb2RlbCUyMCUzRCUyME1lZ2FGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtbmF5bG9yJTJGbWVnYS1iYXNlLXdpa2l0ZXh0JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoKS5pdGVtKCklMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBNZWdhRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybW5heWxvciUyRm1lZ2EtYmFzZS13aWtpdGV4dCUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxJTVEKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = logits.argmax().item()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>, num_labels=num_labels)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=r("p"),b=a("Example of single-label classification:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example of single-label classification:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Pc(j){let d,b,g,p,_;return p=new Te({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyME1lZ2FGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybW5heWxvciUyRm1lZ2EtYmFzZS13aWtpdGV4dCUyMiklMEFtb2RlbCUyMCUzRCUyME1lZ2FGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtbmF5bG9yJTJGbWVnYS1iYXNlLXdpa2l0ZXh0JTIyJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX2NsYXNzX2lkcyUyMCUzRCUyMHRvcmNoLmFyYW5nZSgwJTJDJTIwbG9naXRzLnNoYXBlJTVCLTElNUQpJTVCdG9yY2guc2lnbW9pZChsb2dpdHMpLnNxdWVlemUoZGltJTNEMCklMjAlM0UlMjAwLjUlNUQlMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBNZWdhRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybW5heWxvciUyRm1lZ2EtYmFzZS13aWtpdGV4dCUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIlMEEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2guc3VtKCUwQSUyMCUyMCUyMCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwub25lX2hvdChwcmVkaWN0ZWRfY2xhc3NfaWRzJTVCTm9uZSUyQyUyMCUzQSU1RC5jbG9uZSgpJTJDJTIwbnVtX2NsYXNzZXMlM0RudW1fbGFiZWxzKSUyQyUyMGRpbSUzRDElMEEpLnRvKHRvcmNoLmZsb2F0KSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_ids = torch.arange(<span class="hljs-number">0</span>, logits.shape[-<span class="hljs-number">1</span>])[torch.sigmoid(logits).squeeze(dim=<span class="hljs-number">0</span>) &gt; <span class="hljs-number">0.5</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>, num_labels=num_labels, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.<span class="hljs-built_in">sum</span>(
<span class="hljs-meta">... </span>    torch.nn.functional.one_hot(predicted_class_ids[<span class="hljs-literal">None</span>, :].clone(), num_classes=num_labels), dim=<span class="hljs-number">1</span>
<span class="hljs-meta">... </span>).to(torch.<span class="hljs-built_in">float</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=r("p"),b=a("Example of multi-label classification:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example of multi-label classification:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Qc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Yc(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhRm9yTXVsdGlwbGVDaG9pY2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhRm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIySW4lMjBJdGFseSUyQyUyMHBpenphJTIwc2VydmVkJTIwaW4lMjBmb3JtYWwlMjBzZXR0aW5ncyUyQyUyMHN1Y2glMjBhcyUyMGF0JTIwYSUyMHJlc3RhdXJhbnQlMkMlMjBpcyUyMHByZXNlbnRlZCUyMHVuc2xpY2VkLiUyMiUwQWNob2ljZTAlMjAlM0QlMjAlMjJJdCUyMGlzJTIwZWF0ZW4lMjB3aXRoJTIwYSUyMGZvcmslMjBhbmQlMjBhJTIwa25pZmUuJTIyJTBBY2hvaWNlMSUyMCUzRCUyMCUyMkl0JTIwaXMlMjBlYXRlbiUyMHdoaWxlJTIwaGVsZCUyMGluJTIwdGhlJTIwaGFuZC4lMjIlMEFsYWJlbHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoMCkudW5zcXVlZXplKDApJTIwJTIwJTIzJTIwY2hvaWNlMCUyMGlzJTIwY29ycmVjdCUyMChhY2NvcmRpbmclMjB0byUyMFdpa2lwZWRpYSUyMCUzQikpJTJDJTIwYmF0Y2glMjBzaXplJTIwMSUwQSUwQWVuY29kaW5nJTIwJTNEJTIwdG9rZW5pemVyKCU1QnByb21wdCUyQyUyMHByb21wdCU1RCUyQyUyMCU1QmNob2ljZTAlMkMlMjBjaG9pY2UxJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKiU3QmslM0ElMjB2LnVuc3F1ZWV6ZSgwKSUyMGZvciUyMGslMkMlMjB2JTIwaW4lMjBlbmNvZGluZy5pdGVtcygpJTdEJTJDJTIwbGFiZWxzJTNEbGFiZWxzKSUyMCUyMCUyMyUyMGJhdGNoJTIwc2l6ZSUyMGlzJTIwMSUwQSUwQSUyMyUyMHRoZSUyMGxpbmVhciUyMGNsYXNzaWZpZXIlMjBzdGlsbCUyMG5lZWRzJTIwdG8lMjBiZSUyMHRyYWluZWQlMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForMultipleChoice
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the linear classifier still needs to be trained</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=r("p"),b=a("Example:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Oc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Hc(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybW5heWxvciUyRm1lZ2EtYmFzZS13aWtpdGV4dCUyMiklMEFtb2RlbCUyMCUzRCUyME1lZ2FGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtbmF5bG9yJTJGbWVnYS1iYXNlLXdpa2l0ZXh0JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJIdWdnaW5nRmFjZSUyMGlzJTIwYSUyMGNvbXBhbnklMjBiYXNlZCUyMGluJTIwUGFyaXMlMjBhbmQlMjBOZXclMjBZb3JrJTIyJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNERmFsc2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTBBKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpJTBBJTBBJTIzJTIwTm90ZSUyMHRoYXQlMjB0b2tlbnMlMjBhcmUlMjBjbGFzc2lmaWVkJTIwcmF0aGVyJTIwdGhlbiUyMGlucHV0JTIwd29yZHMlMjB3aGljaCUyMG1lYW5zJTIwdGhhdCUwQSUyMyUyMHRoZXJlJTIwbWlnaHQlMjBiZSUyMG1vcmUlMjBwcmVkaWN0ZWQlMjB0b2tlbiUyMGNsYXNzZXMlMjB0aGFuJTIwd29yZHMuJTBBJTIzJTIwTXVsdGlwbGUlMjB0b2tlbiUyMGNsYXNzZXMlMjBtaWdodCUyMGFjY291bnQlMjBmb3IlMjB0aGUlMjBzYW1lJTIwd29yZCUwQXByZWRpY3RlZF90b2tlbnNfY2xhc3NlcyUyMCUzRCUyMCU1Qm1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnQuaXRlbSgpJTVEJTIwZm9yJTIwdCUyMGluJTIwcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyU1QjAlNUQlNUQlMEElMEFsYWJlbHMlMjAlM0QlMjBwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKS5sb3Nz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForTokenClassification.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;HuggingFace is a company based in Paris and New York&quot;</span>, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class_ids = logits.argmax(-<span class="hljs-number">1</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Note that tokens are classified rather then input words which means that</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># there might be more predicted token classes than words.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Multiple token classes might account for the same word</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes = [model.config.id2label[t.item()] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predicted_token_class_ids[<span class="hljs-number">0</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = predicted_token_class_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=r("p"),b=a("Example:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function Dc(j){let d,b,g,p,_;return{c(){d=r("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=r("code"),p=a("Module"),_=a(`
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(n){d=i(n,"P",{});var c=l(d);b=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=i(c,"CODE",{});var C=l(g);p=s(C,"Module"),C.forEach(o),_=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){M(n,d,c),e(d,b),e(d,g),e(g,p),e(d,_)},d(n){n&&o(d)}}}function Kc(j){let d,b,g,p,_;return p=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhRm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMm1uYXlsb3IlMkZtZWdhLWJhc2Utd2lraXRleHQlMjIpJTBBJTBBcXVlc3Rpb24lMkMlMjB0ZXh0JTIwJTNEJTIwJTIyV2hvJTIwd2FzJTIwSmltJTIwSGVuc29uJTNGJTIyJTJDJTIwJTIySmltJTIwSGVuc29uJTIwd2FzJTIwYSUyMG5pY2UlMjBwdXBwZXQlMjIlMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocXVlc3Rpb24lMkMlMjB0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWFuc3dlcl9zdGFydF9pbmRleCUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzLmFyZ21heCgpJTBBYW5zd2VyX2VuZF9pbmRleCUyMCUzRCUyMG91dHB1dHMuZW5kX2xvZ2l0cy5hcmdtYXgoKSUwQSUwQXByZWRpY3RfYW5zd2VyX3Rva2VucyUyMCUzRCUyMGlucHV0cy5pbnB1dF9pZHMlNUIwJTJDJTIwYW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNBJTIwYW5zd2VyX2VuZF9pbmRleCUyMCUyQiUyMDElNUQlMEElMEElMjMlMjB0YXJnZXQlMjBpcyUyMCUyMm5pY2UlMjBwdXBwZXQlMjIlMEF0YXJnZXRfc3RhcnRfaW5kZXglMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCMTQlNUQpJTBBdGFyZ2V0X2VuZF9pbmRleCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxNSU1RCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBzdGFydF9wb3NpdGlvbnMlM0R0YXJnZXRfc3RhcnRfaW5kZXglMkMlMjBlbmRfcG9zaXRpb25zJTNEdGFyZ2V0X2VuZF9pbmRleCklMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3Nz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegaForQuestionAnswering
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegaForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;mnaylor/mega-base-wikitext&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>question, text = <span class="hljs-string">&quot;Who was Jim Henson?&quot;</span>, <span class="hljs-string">&quot;Jim Henson was a nice puppet&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>answer_start_index = outputs.start_logits.argmax()
<span class="hljs-meta">&gt;&gt;&gt; </span>answer_end_index = outputs.end_logits.argmax()

<span class="hljs-meta">&gt;&gt;&gt; </span>predict_answer_tokens = inputs.input_ids[<span class="hljs-number">0</span>, answer_start_index : answer_end_index + <span class="hljs-number">1</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># target is &quot;nice puppet&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>target_start_index = torch.tensor([<span class="hljs-number">14</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>target_end_index = torch.tensor([<span class="hljs-number">15</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){d=r("p"),b=a("Example:"),g=h(),y(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=s(c,"Example:"),c.forEach(o),g=m(n),w(p.$$.fragment,n)},m(n,c){M(n,d,c),e(d,b),M(n,g,c),v(p,n,c),_=!0},p:ve,i(n){_||(T(p.$$.fragment,n),_=!0)},o(n){k(p.$$.fragment,n),_=!1},d(n){n&&o(d),n&&o(g),$(p,n)}}}function ep(j){let d,b,g,p,_,n,c,C,Ha,Kn,oe,ke,So,rt,Da,Lo,Ka,ea,$e,es,it,ts,os,ta,mo,ns,oa,uo,Po,as,na,go,ss,aa,je,lt,rs,Qo,is,ls,ds,Yo,cs,sa,P,ps,dt,hs,ms,ct,us,gs,ra,fo,fs,ia,Ce,Oo,_s,Ms,Ho,bs,la,ne,ze,Do,pt,ys,Ko,ws,da,A,ht,vs,ae,Ts,_o,ks,$s,mt,js,Cs,zs,se,Js,Mo,Fs,Es,bo,Us,xs,Ws,Je,ca,re,Fe,en,ut,Zs,tn,Is,pa,J,gt,qs,on,Bs,Gs,ft,As,yo,Ns,Xs,Rs,_t,Vs,Mt,Ss,Ls,Ps,bt,Qs,nn,Ys,Os,Hs,z,Ds,an,Ks,er,sn,tr,or,rn,nr,ar,ln,sr,rr,dn,ir,lr,cn,dr,cr,pn,pr,hr,hn,mr,ur,mn,gr,fr,_r,Ee,Mr,un,br,yr,yt,wr,vr,N,wt,Tr,ie,kr,wo,$r,jr,gn,Cr,zr,Jr,Ue,Fr,xe,ha,le,We,fn,vt,Er,_n,Ur,ma,U,Tt,xr,kt,Wr,Mn,Zr,Ir,qr,$t,Br,vo,Gr,Ar,Nr,jt,Xr,Ct,Rr,Vr,Sr,X,zt,Lr,de,Pr,To,Qr,Yr,bn,Or,Hr,Dr,Ze,Kr,Ie,ua,ce,qe,yn,Jt,ei,wn,ti,ga,x,Ft,oi,Et,ni,vn,ai,si,ri,Ut,ii,ko,li,di,ci,xt,pi,Wt,hi,mi,ui,R,Zt,gi,pe,fi,$o,_i,Mi,Tn,bi,yi,wi,Be,vi,Ge,fa,he,Ae,kn,It,Ti,$n,ki,_a,W,qt,$i,jn,ji,Ci,Bt,zi,jo,Ji,Fi,Ei,Gt,Ui,At,xi,Wi,Zi,G,Nt,Ii,me,qi,Co,Bi,Gi,Cn,Ai,Ni,Xi,Ne,Ri,Xe,Vi,Re,Ma,ue,Ve,zn,Xt,Si,Jn,Li,ba,Z,Rt,Pi,Fn,Qi,Yi,Vt,Oi,zo,Hi,Di,Ki,St,el,Lt,tl,ol,nl,V,Pt,al,ge,sl,Jo,rl,il,En,ll,dl,cl,Se,pl,Le,ya,fe,Pe,Un,Qt,hl,xn,ml,wa,I,Yt,ul,Wn,gl,fl,Ot,_l,Fo,Ml,bl,yl,Ht,wl,Dt,vl,Tl,kl,S,Kt,$l,_e,jl,Eo,Cl,zl,Zn,Jl,Fl,El,Qe,Ul,Ye,va,Me,Oe,In,eo,xl,qn,Wl,Ta,q,to,Zl,be,Il,Bn,ql,Bl,Gn,Gl,Al,Nl,oo,Xl,Uo,Rl,Vl,Sl,no,Ll,ao,Pl,Ql,Yl,L,so,Ol,ye,Hl,xo,Dl,Kl,An,ed,td,od,He,nd,De,ka;return n=new te({}),rt=new te({}),pt=new te({}),ht=new B({props:{name:"class transformers.MegaConfig",anchor:"transformers.MegaConfig",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 128"},{name:"num_hidden_layers",val:" = 4"},{name:"intermediate_size",val:" = 256"},{name:"ema_projection_size",val:" = 16"},{name:"bidirectional",val:" = True"},{name:"shared_representation_size",val:" = 64"},{name:"use_chunking",val:" = False"},{name:"chunk_size",val:" = -1"},{name:"truncation",val:" = None"},{name:"normalize_before_mega",val:" = True"},{name:"normalization_type",val:" = 'scalenorm'"},{name:"norm_affine",val:" = True"},{name:"activation",val:" = 'silu'"},{name:"attention_activation",val:" = 'softmax'"},{name:"dropout_prob",val:" = 0.1"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"use_feature_dropout",val:" = False"},{name:"use_normalized_ffn",val:" = True"},{name:"nffn_hidden_size",val:" = 256"},{name:"normalize_before_ffn",val:" = True"},{name:"nffn_activation_dropout_prob",val:" = 0.1"},{name:"max_positions",val:" = 2048"},{name:"add_token_type_embeddings",val:" = False"},{name:"type_vocab_size",val:" = 2"},{name:"initializer_range",val:" = 0.02"},{name:"ema_delta_alpha_range",val:" = 0.2"},{name:"ema_beta_range",val:" = 0.02"},{name:"ema_gamma_omega_range",val:" = 1.0"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"relative_positional_bias",val:" = 'rotary'"},{name:"classifier_dropout",val:" = None"},{name:"use_cache",val:" = True"},{name:"add_lm_hidden_dense_layer",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MegaConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the Mega model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaModel">MegaModel</a>.`,name:"vocab_size"},{anchor:"transformers.MegaConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.MegaConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Number of hidden layers in the Mega encoder.`,name:"num_hidden_layers"},{anchor:"transformers.MegaConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Dimensionality of the hidden size (self-attention value projection) within the Mega encoder`,name:"intermediate_size"},{anchor:"transformers.MegaConfig.ema_projection_size",description:`<strong>ema_projection_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Dimensionality of the MegaMultiDimensionDampedEma`,name:"ema_projection_size"},{anchor:"transformers.MegaConfig.bidirectional",description:`<strong>bidirectional</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the MegaMultiDimensionDampedEma used in Mega&#x2019;s self-attention should work bidirectionally (<code>True</code>)
or unidirectionally (<code>False</code>). Bidirectional EMA is incompatible with causal decoding, so this should be
False if you intend to use the model as a decoder.`,name:"bidirectional"},{anchor:"transformers.MegaConfig.shared_representation_size",description:`<strong>shared_representation_size</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Dimensionality of the linear projection for shared representation of self-attention queries and keys`,name:"shared_representation_size"},{anchor:"transformers.MegaConfig.use_chunking",description:`<strong>use_chunking</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to chunk inputs for linear self-attention complexity (described as Mega-chunk in the paper)`,name:"use_chunking"},{anchor:"transformers.MegaConfig.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
If <code>use_chunking</code> is set to <code>True</code>, determines the size of the chunks to apply to the input sequence. If
chunking is used, input sequences must be padded to a multiple of <code>chunk_size</code>`,name:"chunk_size"},{anchor:"transformers.MegaConfig.truncation",description:`<strong>truncation</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If specified, the sequence length for which to truncate MegaMultiDimensionDampedEma`,name:"truncation"},{anchor:"transformers.MegaConfig.normalize_before_mega",description:`<strong>normalize_before_mega</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize before (<code>True</code>) or after (<code>False</code>) passing through Mega encoder blocks`,name:"normalize_before_mega"},{anchor:"transformers.MegaConfig.normalization_type",description:`<strong>normalization_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;scalenorm&quot;</code>) &#x2014;
Type of normalization to use in Mega encoder blocks. Choose one of <code>&quot;scalenorm&quot;</code>, <code>&quot;layernorm&quot;</code>,
<code>&quot;rmsnorm&quot;</code>, <code>&quot;batchnorm&quot;</code>, or <code>&quot;syncbatchnorm&quot;</code> (GPU required for syncbatchnorm)`,name:"normalization_type"},{anchor:"transformers.MegaConfig.norm_affine",description:`<strong>norm_affine</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, applies a parameterized affine transformation to inputs during normalization`,name:"norm_affine"},{anchor:"transformers.MegaConfig.activation",description:`<strong>activation</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
Activation function to apply within Mega encoder blocks. Choose one of <code>&quot;silu&quot;</code>, <code>&quot;relu&quot;</code>, <code>&quot;linear&quot;</code>,
<code>&quot;gelu&quot;</code>, or <code>&quot;gelu_accurate&quot;</code>`,name:"activation"},{anchor:"transformers.MegaConfig.attention_activation",description:`<strong>attention_activation</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;softmax&quot;</code>) &#x2014;
Activation function to apply for single-headed self-attention (a la Transformer). Choose one of
<code>&quot;softmax&quot;</code>, <code>&quot;laplace&quot;</code>, or <code>&quot;relu2&quot;</code>`,name:"attention_activation"},{anchor:"transformers.MegaConfig.dropout_prob",description:`<strong>dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for EMA self-attention`,name:"dropout_prob"},{anchor:"transformers.MegaConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.MegaConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.MegaConfig.use_feature_dropout",description:`<strong>use_feature_dropout</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use feature-based (<code>True</code>) or standard dropout (<code>False</code>)`,name:"use_feature_dropout"},{anchor:"transformers.MegaConfig.use_normalized_ffn",description:`<strong>use_normalized_ffn</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use the normalized feed-forward sub-layer in Mega blocks (<code>True</code>) or pass Mega encoder output
as-is (<code>False</code>)`,name:"use_normalized_ffn"},{anchor:"transformers.MegaConfig.nffn_hidden_size",description:`<strong>nffn_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
If using the normalized feed-forward network (NFFN) layer within Mega (<code>use_normalized_ffn = True</code>), this
is the hidden size of the NFFN`,name:"nffn_hidden_size"},{anchor:"transformers.MegaConfig.normalize_before_ffn",description:`<strong>normalize_before_ffn</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize before (<code>True</code>) or after (<code>False</code>) the feed-forward portion of NFFN`,name:"normalize_before_ffn"},{anchor:"transformers.MegaConfig.nffn_activation_dropout_prob",description:`<strong>nffn_activation_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the NFFN component.`,name:"nffn_activation_dropout_prob"},{anchor:"transformers.MegaConfig.max_positions",description:`<strong>max_positions</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
The maximum sequence length to use for positional representations. For <code>&quot;simple&quot;</code> relative positional bias,
this is a hard limit on input length; <code>&quot;rotary&quot;</code> relative positional bias will extrapolate to longer
sequences`,name:"max_positions"},{anchor:"transformers.MegaConfig.add_token_type_embeddings",description:`<strong>add_token_type_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to account for token types in embeddings. Left as optional to maintain compatibility with original
implementation while adding support for token types.`,name:"add_token_type_embeddings"},{anchor:"transformers.MegaConfig.type_vocab_size",description:`<strong>type_vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The vocabulary size of the <code>token_type_ids</code> passed when calling <a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaModel">MegaModel</a>. Only used if
<code>add_token_type_embeddings = True</code>`,name:"type_vocab_size"},{anchor:"transformers.MegaConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.MegaConfig.ema_delta_alpha_range",description:`<strong>ema_delta_alpha_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.2) &#x2014;
The standard deviation for initializing the delta (damping factor) and alpha (decay factor) parameters in
MegaMultiDimensionDampedEma.`,name:"ema_delta_alpha_range"},{anchor:"transformers.MegaConfig.ema_beta_range",description:`<strong>ema_beta_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation for initializing the beta parameter (expansion matrix) in
MegaMultiDimensionDampedEma.`,name:"ema_beta_range"},{anchor:"transformers.MegaConfig.ema_gamma_omega_range",description:`<strong>ema_gamma_omega_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The standard deviation for initializing the gamma (projection matrix) and omega (residual weight)
parameters in MultiDimensionEMA.`,name:"ema_gamma_omega_range"},{anchor:"transformers.MegaConfig.relative_positional_bias",description:`<strong>relative_positional_bias</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;rotary&quot;</code>) &#x2014;
Type of relative positional encoding. Choose one of <code>&quot;rotary&quot;</code> or <code>&quot;simple&quot;</code>. If <code>&quot;simple&quot;</code> is selected,
<code>max_positions</code> is used as a limit on input size, while <code>&quot;rotary&quot;</code> extrapolates beyond <code>max_positions</code>.`,name:"relative_positional_bias"},{anchor:"transformers.MegaConfig.is_decoder",description:`<strong>is_decoder</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the model is used as a decoder or not. If <code>False</code>, the model is used as an encoder.`,name:"is_decoder"},{anchor:"transformers.MegaConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"},{anchor:"transformers.MegaConfig.classifier_dropout",description:`<strong>classifier_dropout</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The dropout ratio for the classification head.`,name:"classifier_dropout"},{anchor:"transformers.MegaConfig.add_lm_hidden_dense_layer",description:`<strong>add_lm_hidden_dense_layer</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to include a hidden layer for projection between encoder outputs and LM heads (<code>True</code>) or pass
hidden states directly to LM head (<code>False</code>). Remains optional for compatibility with original
implementation`,name:"add_lm_hidden_dense_layer"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/configuration_mega.py#L31"}}),Je=new we({props:{anchor:"transformers.MegaConfig.example",$$slots:{default:[Bc]},$$scope:{ctx:j}}}),ut=new te({}),gt=new B({props:{name:"class transformers.MegaModel",anchor:"transformers.MegaModel",parameters:[{name:"config",val:": MegaConfig"},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.MegaModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1451"}}),wt=new B({props:{name:"forward",anchor:"transformers.MegaModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = 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:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaModel.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.MegaModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaModel.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.MegaModel.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.MegaModel.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.MegaModel.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.MegaModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.MegaModel.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.MegaModel.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"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1486",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ue=new ho({props:{$$slots:{default:[Gc]},$$scope:{ctx:j}}}),xe=new we({props:{anchor:"transformers.MegaModel.forward.example",$$slots:{default:[Ac]},$$scope:{ctx:j}}}),vt=new te({}),Tt=new B({props:{name:"class transformers.MegaForCausalLM",anchor:"transformers.MegaForCausalLM",parameters:[{name:"config",val:": MegaConfig"}],parametersDescription:[{anchor:"transformers.MegaForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1648"}}),zt=new B({props:{name:"forward",anchor:"transformers.MegaForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Tuple[typing.Tuple[torch.FloatTensor]] = 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:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaForCausalLM.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.MegaForCausalLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaForCausalLM.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.MegaForCausalLM.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.MegaForCausalLM.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.MegaForCausalLM.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaForCausalLM.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.MegaForCausalLM.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.MegaForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
<code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are
ignored (masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.MegaForCausalLM.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.MegaForCausalLM.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"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1677",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ze=new ho({props:{$$slots:{default:[Nc]},$$scope:{ctx:j}}}),Ie=new we({props:{anchor:"transformers.MegaForCausalLM.forward.example",$$slots:{default:[Xc]},$$scope:{ctx:j}}}),Jt=new te({}),Ft=new B({props:{name:"class transformers.MegaForMaskedLM",anchor:"transformers.MegaForMaskedLM",parameters:[{name:"config",val:": MegaConfig"}],parametersDescription:[{anchor:"transformers.MegaForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1807"}}),Zt=new B({props:{name:"forward",anchor:"transformers.MegaForMaskedLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaForMaskedLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaForMaskedLM.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.MegaForMaskedLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaForMaskedLM.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.MegaForMaskedLM.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.MegaForMaskedLM.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.MegaForMaskedLM.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaForMaskedLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.MegaForMaskedLM.forward.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, any]</code>, optional, defaults to <em>{}</em>) &#x2014;
Used to hide legacy arguments that have been deprecated.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1838",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Masked language modeling (MLM) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Be=new ho({props:{$$slots:{default:[Rc]},$$scope:{ctx:j}}}),Ge=new we({props:{anchor:"transformers.MegaForMaskedLM.forward.example",$$slots:{default:[Vc]},$$scope:{ctx:j}}}),It=new te({}),qt=new B({props:{name:"class transformers.MegaForSequenceClassification",anchor:"transformers.MegaForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegaForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1911"}}),Nt=new B({props:{name:"forward",anchor:"transformers.MegaForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaForSequenceClassification.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.MegaForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaForSequenceClassification.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.MegaForSequenceClassification.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.MegaForSequenceClassification.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.MegaForSequenceClassification.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L1923",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ne=new ho({props:{$$slots:{default:[Sc]},$$scope:{ctx:j}}}),Xe=new we({props:{anchor:"transformers.MegaForSequenceClassification.forward.example",$$slots:{default:[Lc]},$$scope:{ctx:j}}}),Re=new we({props:{anchor:"transformers.MegaForSequenceClassification.forward.example-2",$$slots:{default:[Pc]},$$scope:{ctx:j}}}),Xt=new te({}),Rt=new B({props:{name:"class transformers.MegaForMultipleChoice",anchor:"transformers.MegaForMultipleChoice",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegaForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L2002"}}),Pt=new B({props:{name:"forward",anchor:"transformers.MegaForMultipleChoice.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = 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:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaForMultipleChoice.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaForMultipleChoice.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.MegaForMultipleChoice.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaForMultipleChoice.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegaForMultipleChoice.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.MegaForMultipleChoice.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.MegaForMultipleChoice.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaForMultipleChoice.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the multiple choice classification loss. Indices should be in <code>[0, ..., num_choices-1]</code> where <code>num_choices</code> is the size of the second dimension of the input tensors. (See
<code>input_ids</code> above)`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L2013",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <em>(1,)</em>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 <em>num_choices</em> is the second dimension of the input tensors. (see <em>input_ids</em> above).</p>
<p>Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Se=new ho({props:{$$slots:{default:[Qc]},$$scope:{ctx:j}}}),Le=new we({props:{anchor:"transformers.MegaForMultipleChoice.forward.example",$$slots:{default:[Yc]},$$scope:{ctx:j}}}),Qt=new te({}),Yt=new B({props:{name:"class transformers.MegaForTokenClassification",anchor:"transformers.MegaForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegaForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L2087"}}),Kt=new B({props:{name:"forward",anchor:"transformers.MegaForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaForTokenClassification.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.MegaForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaForTokenClassification.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.MegaForTokenClassification.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.MegaForTokenClassification.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.MegaForTokenClassification.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaForTokenClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the token classification loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L2102",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided)  \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Qe=new ho({props:{$$slots:{default:[Oc]},$$scope:{ctx:j}}}),Ye=new we({props:{anchor:"transformers.MegaForTokenClassification.forward.example",$$slots:{default:[Hc]},$$scope:{ctx:j}}}),eo=new te({}),to=new B({props:{name:"class transformers.MegaForQuestionAnswering",anchor:"transformers.MegaForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegaForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig">MegaConfig</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/v4.32.0/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/v4.32.0/src/transformers/models/mega/modeling_mega.py#L2187"}}),so=new B({props:{name:"forward",anchor:"transformers.MegaForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegaForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegaForQuestionAnswering.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.MegaForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0,1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.
This parameter can only be used when the model is initialized with <code>add_token_type_embeddings</code> parameter
set to <code>True</code>. All the value in this tensor should be always &lt; config.type_vocab_size.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegaForQuestionAnswering.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.MegaForQuestionAnswering.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.MegaForQuestionAnswering.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.MegaForQuestionAnswering.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/v4.32.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegaForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.MegaForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/mega/modeling_mega.py#L2198",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaConfig"
>MegaConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),He=new ho({props:{$$slots:{default:[Dc]},$$scope:{ctx:j}}}),De=new we({props:{anchor:"transformers.MegaForQuestionAnswering.forward.example",$$slots:{default:[Kc]},$$scope:{ctx:j}}}),{c(){d=r("meta"),b=h(),g=r("h1"),p=r("a"),_=r("span"),y(n.$$.fragment),c=h(),C=r("span"),Ha=a("MEGA"),Kn=h(),oe=r("h2"),ke=r("a"),So=r("span"),y(rt.$$.fragment),Da=h(),Lo=r("span"),Ka=a("Overview"),ea=h(),$e=r("p"),es=a("The MEGA model was proposed in "),it=r("a"),ts=a("Mega: Moving Average Equipped Gated Attention"),os=a(` by Xuezhe Ma, Chunting Zhou, Xiang Kong, Junxian He, Liangke Gui, Graham Neubig, Jonathan May, and Luke Zettlemoyer.
MEGA proposes a new approach to self-attention with each encoder layer having a multi-headed exponential moving average in addition to a single head of standard dot-product attention, giving the attention mechanism
stronger positional biases. This allows MEGA to perform competitively to Transformers on standard benchmarks including LRA
while also having significantly fewer parameters. MEGA\u2019s compute efficiency allows it to scale to very long sequences, making it an
attractive option for long-document NLP tasks.`),ta=h(),mo=r("p"),ns=a("The abstract from the paper is the following:"),oa=h(),uo=r("p"),Po=r("em"),as=a("The design choices in the Transformer attention mechanism, including weak inductive bias and quadratic computational complexity, have limited its application for modeling long sequences. In this paper, we introduce Mega, a simple, theoretically grounded, single-head gated attention mechanism equipped with (exponential) moving average to incorporate inductive bias of position-aware local dependencies into the position-agnostic attention mechanism. We further propose a variant of Mega that offers linear time and space complexity yet yields only minimal quality loss, by efficiently splitting the whole sequence into multiple chunks with fixed length. Extensive experiments on a wide range of sequence modeling benchmarks, including the Long Range Arena, neural machine translation, auto-regressive language modeling, and image and speech classification, show that Mega achieves significant improvements over other sequence models, including variants of Transformers and recent state space models."),na=h(),go=r("p"),ss=a("Tips:"),aa=h(),je=r("ul"),lt=r("li"),rs=a("MEGA can perform quite well with relatively few parameters. See Appendix D in the MEGA paper for examples of architectural specs which perform well in various settings. If using MEGA as a decoder, be sure to set "),Qo=r("code"),is=a("bidirectional=False"),ls=a(" to avoid errors with default bidirectional."),ds=h(),Yo=r("li"),cs=a("Mega-chunk is a variant of mega that reduces time and spaces complexity from quadratic to linear. Utilize chunking with MegaConfig.use_chunking and control chunk size with MegaConfig.chunk_size"),sa=h(),P=r("p"),ps=a("This model was contributed by "),dt=r("a"),hs=a("mnaylor"),ms=a(`.
The original code can be found `),ct=r("a"),us=a("here"),gs=a("."),ra=h(),fo=r("p"),fs=a("Implementation Notes:"),ia=h(),Ce=r("ul"),Oo=r("li"),_s=a("The original implementation of MEGA had an inconsistent expectation of attention masks for padding and causal self-attention between the softmax attention and Laplace/squared ReLU method. This implementation addresses that inconsistency."),Ms=h(),Ho=r("li"),bs=a("The original implementation did not include token type embeddings; this implementation adds support for these, with the option controlled by MegaConfig.add_token_type_embeddings"),la=h(),ne=r("h2"),ze=r("a"),Do=r("span"),y(pt.$$.fragment),ys=h(),Ko=r("span"),ws=a("MegaConfig"),da=h(),A=r("div"),y(ht.$$.fragment),vs=h(),ae=r("p"),Ts=a("This is the configuration class to store the configuration of a "),_o=r("a"),ks=a("MegaModel"),$s=a(`. It is used to instantiate a Mega
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 Mega
`),mt=r("a"),js=a("mnaylor/mega-base-wikitext"),Cs=a(" architecture."),zs=h(),se=r("p"),Js=a("Configuration objects inherit from "),Mo=r("a"),Fs=a("PretrainedConfig"),Es=a(` and can be used to control the model outputs. Read the
documentation from `),bo=r("a"),Us=a("PretrainedConfig"),xs=a(" for more information."),Ws=h(),y(Je.$$.fragment),ca=h(),re=r("h2"),Fe=r("a"),en=r("span"),y(ut.$$.fragment),Zs=h(),tn=r("span"),Is=a("MegaModel"),pa=h(),J=r("div"),y(gt.$$.fragment),qs=h(),on=r("p"),Bs=a("The bare MEGA Model transformer outputting raw hidden-states without any specific head on top."),Gs=h(),ft=r("p"),As=a("This model inherits from "),yo=r("a"),Ns=a("PreTrainedModel"),Xs=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Rs=h(),_t=r("p"),Vs=a("This model is also a PyTorch "),Mt=r("a"),Ss=a("torch.nn.Module"),Ls=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ps=h(),bt=r("p"),Qs=a(`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added after self-attention, following the architecture described in `),nn=r("em"),Ys=a(`Mega: Moving Average
Equipped Gated Attention`),Os=a(`_ by Xuezhe Ma, Chunting Zhou, Xiang Kong, Junxian He, Liangke Gui, Graham Neubig,
Jonathan May, and Luke Zettlemoyer`),Hs=h(),z=r("p"),Ds=a("To behave as a decoder the model needs to be initialized with the "),an=r("code"),Ks=a("is_decoder"),er=a(` argument of the configuration set to
`),sn=r("code"),tr=a("True"),or=a(" and "),rn=r("code"),nr=a("bidirectional"),ar=a(" set to "),ln=r("code"),sr=a("False"),rr=a(`. To be used in a Seq2Seq model, the model needs to initialized with both
`),dn=r("code"),ir=a("is_decoder=True"),lr=a(" and "),cn=r("code"),dr=a("bidirectional=False"),cr=a(" argument as well as "),pn=r("code"),pr=a("add_cross_attention"),hr=a(" set to "),hn=r("code"),mr=a("True"),ur=a(`; an
`),mn=r("code"),gr=a("encoder_hidden_states"),fr=a(" is then expected as an input to the forward pass."),_r=h(),Ee=r("p"),Mr=a(".. _"),un=r("em"),br=a("Mega: Moving Average Equipped Gated Attention"),yr=a(": "),yt=r("a"),wr=a("https://arxiv.org/abs/2209.10655"),vr=h(),N=r("div"),y(wt.$$.fragment),Tr=h(),ie=r("p"),kr=a("The "),wo=r("a"),$r=a("MegaModel"),jr=a(" forward method, overrides the "),gn=r("code"),Cr=a("__call__"),zr=a(" special method."),Jr=h(),y(Ue.$$.fragment),Fr=h(),y(xe.$$.fragment),ha=h(),le=r("h2"),We=r("a"),fn=r("span"),y(vt.$$.fragment),Er=h(),_n=r("span"),Ur=a("MegaForCausalLM"),ma=h(),U=r("div"),y(Tt.$$.fragment),xr=h(),kt=r("p"),Wr=a("MEGA Model with a "),Mn=r("code"),Zr=a("language modeling"),Ir=a(" head on top for CLM fine-tuning."),qr=h(),$t=r("p"),Br=a("This model inherits from "),vo=r("a"),Gr=a("PreTrainedModel"),Ar=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Nr=h(),jt=r("p"),Xr=a("This model is also a PyTorch "),Ct=r("a"),Rr=a("torch.nn.Module"),Vr=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Sr=h(),X=r("div"),y(zt.$$.fragment),Lr=h(),de=r("p"),Pr=a("The "),To=r("a"),Qr=a("MegaForCausalLM"),Yr=a(" forward method, overrides the "),bn=r("code"),Or=a("__call__"),Hr=a(" special method."),Dr=h(),y(Ze.$$.fragment),Kr=h(),y(Ie.$$.fragment),ua=h(),ce=r("h2"),qe=r("a"),yn=r("span"),y(Jt.$$.fragment),ei=h(),wn=r("span"),ti=a("MegaForMaskedLM"),ga=h(),x=r("div"),y(Ft.$$.fragment),oi=h(),Et=r("p"),ni=a("MEGA Model with a "),vn=r("code"),ai=a("language modeling"),si=a(" head on top."),ri=h(),Ut=r("p"),ii=a("This model inherits from "),ko=r("a"),li=a("PreTrainedModel"),di=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ci=h(),xt=r("p"),pi=a("This model is also a PyTorch "),Wt=r("a"),hi=a("torch.nn.Module"),mi=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ui=h(),R=r("div"),y(Zt.$$.fragment),gi=h(),pe=r("p"),fi=a("The "),$o=r("a"),_i=a("MegaForMaskedLM"),Mi=a(" forward method, overrides the "),Tn=r("code"),bi=a("__call__"),yi=a(" special method."),wi=h(),y(Be.$$.fragment),vi=h(),y(Ge.$$.fragment),fa=h(),he=r("h2"),Ae=r("a"),kn=r("span"),y(It.$$.fragment),Ti=h(),$n=r("span"),ki=a("MegaForSequenceClassification"),_a=h(),W=r("div"),y(qt.$$.fragment),$i=h(),jn=r("p"),ji=a(`MEGA Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled
output) e.g. for GLUE tasks.`),Ci=h(),Bt=r("p"),zi=a("This model inherits from "),jo=r("a"),Ji=a("PreTrainedModel"),Fi=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ei=h(),Gt=r("p"),Ui=a("This model is also a PyTorch "),At=r("a"),xi=a("torch.nn.Module"),Wi=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Zi=h(),G=r("div"),y(Nt.$$.fragment),Ii=h(),me=r("p"),qi=a("The "),Co=r("a"),Bi=a("MegaForSequenceClassification"),Gi=a(" forward method, overrides the "),Cn=r("code"),Ai=a("__call__"),Ni=a(" special method."),Xi=h(),y(Ne.$$.fragment),Ri=h(),y(Xe.$$.fragment),Vi=h(),y(Re.$$.fragment),Ma=h(),ue=r("h2"),Ve=r("a"),zn=r("span"),y(Xt.$$.fragment),Si=h(),Jn=r("span"),Li=a("MegaForMultipleChoice"),ba=h(),Z=r("div"),y(Rt.$$.fragment),Pi=h(),Fn=r("p"),Qi=a(`MEGA Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
softmax) e.g. for RocStories/SWAG tasks.`),Yi=h(),Vt=r("p"),Oi=a("This model inherits from "),zo=r("a"),Hi=a("PreTrainedModel"),Di=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ki=h(),St=r("p"),el=a("This model is also a PyTorch "),Lt=r("a"),tl=a("torch.nn.Module"),ol=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),nl=h(),V=r("div"),y(Pt.$$.fragment),al=h(),ge=r("p"),sl=a("The "),Jo=r("a"),rl=a("MegaForMultipleChoice"),il=a(" forward method, overrides the "),En=r("code"),ll=a("__call__"),dl=a(" special method."),cl=h(),y(Se.$$.fragment),pl=h(),y(Le.$$.fragment),ya=h(),fe=r("h2"),Pe=r("a"),Un=r("span"),y(Qt.$$.fragment),hl=h(),xn=r("span"),ml=a("MegaForTokenClassification"),wa=h(),I=r("div"),y(Yt.$$.fragment),ul=h(),Wn=r("p"),gl=a(`MEGA Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),fl=h(),Ot=r("p"),_l=a("This model inherits from "),Fo=r("a"),Ml=a("PreTrainedModel"),bl=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),yl=h(),Ht=r("p"),wl=a("This model is also a PyTorch "),Dt=r("a"),vl=a("torch.nn.Module"),Tl=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),kl=h(),S=r("div"),y(Kt.$$.fragment),$l=h(),_e=r("p"),jl=a("The "),Eo=r("a"),Cl=a("MegaForTokenClassification"),zl=a(" forward method, overrides the "),Zn=r("code"),Jl=a("__call__"),Fl=a(" special method."),El=h(),y(Qe.$$.fragment),Ul=h(),y(Ye.$$.fragment),va=h(),Me=r("h2"),Oe=r("a"),In=r("span"),y(eo.$$.fragment),xl=h(),qn=r("span"),Wl=a("MegaForQuestionAnswering"),Ta=h(),q=r("div"),y(to.$$.fragment),Zl=h(),be=r("p"),Il=a(`MEGA Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `),Bn=r("code"),ql=a("span start logits"),Bl=a(" and "),Gn=r("code"),Gl=a("span end logits"),Al=a(")."),Nl=h(),oo=r("p"),Xl=a("This model inherits from "),Uo=r("a"),Rl=a("PreTrainedModel"),Vl=a(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Sl=h(),no=r("p"),Ll=a("This model is also a PyTorch "),ao=r("a"),Pl=a("torch.nn.Module"),Ql=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Yl=h(),L=r("div"),y(so.$$.fragment),Ol=h(),ye=r("p"),Hl=a("The "),xo=r("a"),Dl=a("MegaForQuestionAnswering"),Kl=a(" forward method, overrides the "),An=r("code"),ed=a("__call__"),td=a(" special method."),od=h(),y(He.$$.fragment),nd=h(),y(De.$$.fragment),this.h()},l(t){const f=Ic('[data-svelte="svelte-1phssyn"]',document.head);d=i(f,"META",{name:!0,content:!0}),f.forEach(o),b=m(t),g=i(t,"H1",{class:!0});var ro=l(g);p=i(ro,"A",{id:!0,class:!0,href:!0});var Nn=l(p);_=i(Nn,"SPAN",{});var Xn=l(_);w(n.$$.fragment,Xn),Xn.forEach(o),Nn.forEach(o),c=m(ro),C=i(ro,"SPAN",{});var Rn=l(C);Ha=s(Rn,"MEGA"),Rn.forEach(o),ro.forEach(o),Kn=m(t),oe=i(t,"H2",{class:!0});var io=l(oe);ke=i(io,"A",{id:!0,class:!0,href:!0});var Vn=l(ke);So=i(Vn,"SPAN",{});var Sn=l(So);w(rt.$$.fragment,Sn),Sn.forEach(o),Vn.forEach(o),Da=m(io),Lo=i(io,"SPAN",{});var Ln=l(Lo);Ka=s(Ln,"Overview"),Ln.forEach(o),io.forEach(o),ea=m(t),$e=i(t,"P",{});var lo=l($e);es=s(lo,"The MEGA model was proposed in "),it=i(lo,"A",{href:!0,rel:!0});var Pn=l(it);ts=s(Pn,"Mega: Moving Average Equipped Gated Attention"),Pn.forEach(o),os=s(lo,` by Xuezhe Ma, Chunting Zhou, Xiang Kong, Junxian He, Liangke Gui, Graham Neubig, Jonathan May, and Luke Zettlemoyer.
MEGA proposes a new approach to self-attention with each encoder layer having a multi-headed exponential moving average in addition to a single head of standard dot-product attention, giving the attention mechanism
stronger positional biases. This allows MEGA to perform competitively to Transformers on standard benchmarks including LRA
while also having significantly fewer parameters. MEGA\u2019s compute efficiency allows it to scale to very long sequences, making it an
attractive option for long-document NLP tasks.`),lo.forEach(o),ta=m(t),mo=i(t,"P",{});var Qn=l(mo);ns=s(Qn,"The abstract from the paper is the following:"),Qn.forEach(o),oa=m(t),uo=i(t,"P",{});var Yn=l(uo);Po=i(Yn,"EM",{});var On=l(Po);as=s(On,"The design choices in the Transformer attention mechanism, including weak inductive bias and quadratic computational complexity, have limited its application for modeling long sequences. In this paper, we introduce Mega, a simple, theoretically grounded, single-head gated attention mechanism equipped with (exponential) moving average to incorporate inductive bias of position-aware local dependencies into the position-agnostic attention mechanism. We further propose a variant of Mega that offers linear time and space complexity yet yields only minimal quality loss, by efficiently splitting the whole sequence into multiple chunks with fixed length. Extensive experiments on a wide range of sequence modeling benchmarks, including the Long Range Arena, neural machine translation, auto-regressive language modeling, and image and speech classification, show that Mega achieves significant improvements over other sequence models, including variants of Transformers and recent state space models."),On.forEach(o),Yn.forEach(o),na=m(t),go=i(t,"P",{});var Hn=l(go);ss=s(Hn,"Tips:"),Hn.forEach(o),aa=m(t),je=i(t,"UL",{});var co=l(je);lt=i(co,"LI",{});var po=l(lt);rs=s(po,"MEGA can perform quite well with relatively few parameters. See Appendix D in the MEGA paper for examples of architectural specs which perform well in various settings. If using MEGA as a decoder, be sure to set "),Qo=i(po,"CODE",{});var ad=l(Qo);is=s(ad,"bidirectional=False"),ad.forEach(o),ls=s(po," to avoid errors with default bidirectional."),po.forEach(o),ds=m(co),Yo=i(co,"LI",{});var sd=l(Yo);cs=s(sd,"Mega-chunk is a variant of mega that reduces time and spaces complexity from quadratic to linear. Utilize chunking with MegaConfig.use_chunking and control chunk size with MegaConfig.chunk_size"),sd.forEach(o),co.forEach(o),sa=m(t),P=i(t,"P",{});var Wo=l(P);ps=s(Wo,"This model was contributed by "),dt=i(Wo,"A",{href:!0,rel:!0});var rd=l(dt);hs=s(rd,"mnaylor"),rd.forEach(o),ms=s(Wo,`.
The original code can be found `),ct=i(Wo,"A",{href:!0,rel:!0});var id=l(ct);us=s(id,"here"),id.forEach(o),gs=s(Wo,"."),Wo.forEach(o),ra=m(t),fo=i(t,"P",{});var ld=l(fo);fs=s(ld,"Implementation Notes:"),ld.forEach(o),ia=m(t),Ce=i(t,"UL",{});var $a=l(Ce);Oo=i($a,"LI",{});var dd=l(Oo);_s=s(dd,"The original implementation of MEGA had an inconsistent expectation of attention masks for padding and causal self-attention between the softmax attention and Laplace/squared ReLU method. This implementation addresses that inconsistency."),dd.forEach(o),Ms=m($a),Ho=i($a,"LI",{});var cd=l(Ho);bs=s(cd,"The original implementation did not include token type embeddings; this implementation adds support for these, with the option controlled by MegaConfig.add_token_type_embeddings"),cd.forEach(o),$a.forEach(o),la=m(t),ne=i(t,"H2",{class:!0});var ja=l(ne);ze=i(ja,"A",{id:!0,class:!0,href:!0});var pd=l(ze);Do=i(pd,"SPAN",{});var hd=l(Do);w(pt.$$.fragment,hd),hd.forEach(o),pd.forEach(o),ys=m(ja),Ko=i(ja,"SPAN",{});var md=l(Ko);ws=s(md,"MegaConfig"),md.forEach(o),ja.forEach(o),da=m(t),A=i(t,"DIV",{class:!0});var Ke=l(A);w(ht.$$.fragment,Ke),vs=m(Ke),ae=i(Ke,"P",{});var Zo=l(ae);Ts=s(Zo,"This is the configuration class to store the configuration of a "),_o=i(Zo,"A",{href:!0});var ud=l(_o);ks=s(ud,"MegaModel"),ud.forEach(o),$s=s(Zo,`. It is used to instantiate a Mega
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 Mega
`),mt=i(Zo,"A",{href:!0,rel:!0});var gd=l(mt);js=s(gd,"mnaylor/mega-base-wikitext"),gd.forEach(o),Cs=s(Zo," architecture."),Zo.forEach(o),zs=m(Ke),se=i(Ke,"P",{});var Io=l(se);Js=s(Io,"Configuration objects inherit from "),Mo=i(Io,"A",{href:!0});var fd=l(Mo);Fs=s(fd,"PretrainedConfig"),fd.forEach(o),Es=s(Io,` and can be used to control the model outputs. Read the
documentation from `),bo=i(Io,"A",{href:!0});var _d=l(bo);Us=s(_d,"PretrainedConfig"),_d.forEach(o),xs=s(Io," for more information."),Io.forEach(o),Ws=m(Ke),w(Je.$$.fragment,Ke),Ke.forEach(o),ca=m(t),re=i(t,"H2",{class:!0});var Ca=l(re);Fe=i(Ca,"A",{id:!0,class:!0,href:!0});var Md=l(Fe);en=i(Md,"SPAN",{});var bd=l(en);w(ut.$$.fragment,bd),bd.forEach(o),Md.forEach(o),Zs=m(Ca),tn=i(Ca,"SPAN",{});var yd=l(tn);Is=s(yd,"MegaModel"),yd.forEach(o),Ca.forEach(o),pa=m(t),J=i(t,"DIV",{class:!0});var E=l(J);w(gt.$$.fragment,E),qs=m(E),on=i(E,"P",{});var wd=l(on);Bs=s(wd,"The bare MEGA Model transformer outputting raw hidden-states without any specific head on top."),wd.forEach(o),Gs=m(E),ft=i(E,"P",{});var za=l(ft);As=s(za,"This model inherits from "),yo=i(za,"A",{href:!0});var vd=l(yo);Ns=s(vd,"PreTrainedModel"),vd.forEach(o),Xs=s(za,`. 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.)`),za.forEach(o),Rs=m(E),_t=i(E,"P",{});var Ja=l(_t);Vs=s(Ja,"This model is also a PyTorch "),Mt=i(Ja,"A",{href:!0,rel:!0});var Td=l(Mt);Ss=s(Td,"torch.nn.Module"),Td.forEach(o),Ls=s(Ja,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ja.forEach(o),Ps=m(E),bt=i(E,"P",{});var Fa=l(bt);Qs=s(Fa,`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added after self-attention, following the architecture described in `),nn=i(Fa,"EM",{});var kd=l(nn);Ys=s(kd,`Mega: Moving Average
Equipped Gated Attention`),kd.forEach(o),Os=s(Fa,`_ by Xuezhe Ma, Chunting Zhou, Xiang Kong, Junxian He, Liangke Gui, Graham Neubig,
Jonathan May, and Luke Zettlemoyer`),Fa.forEach(o),Hs=m(E),z=i(E,"P",{});var F=l(z);Ds=s(F,"To behave as a decoder the model needs to be initialized with the "),an=i(F,"CODE",{});var $d=l(an);Ks=s($d,"is_decoder"),$d.forEach(o),er=s(F,` argument of the configuration set to
`),sn=i(F,"CODE",{});var jd=l(sn);tr=s(jd,"True"),jd.forEach(o),or=s(F," and "),rn=i(F,"CODE",{});var Cd=l(rn);nr=s(Cd,"bidirectional"),Cd.forEach(o),ar=s(F," set to "),ln=i(F,"CODE",{});var zd=l(ln);sr=s(zd,"False"),zd.forEach(o),rr=s(F,`. To be used in a Seq2Seq model, the model needs to initialized with both
`),dn=i(F,"CODE",{});var Jd=l(dn);ir=s(Jd,"is_decoder=True"),Jd.forEach(o),lr=s(F," and "),cn=i(F,"CODE",{});var Fd=l(cn);dr=s(Fd,"bidirectional=False"),Fd.forEach(o),cr=s(F," argument as well as "),pn=i(F,"CODE",{});var Ed=l(pn);pr=s(Ed,"add_cross_attention"),Ed.forEach(o),hr=s(F," set to "),hn=i(F,"CODE",{});var Ud=l(hn);mr=s(Ud,"True"),Ud.forEach(o),ur=s(F,`; an
`),mn=i(F,"CODE",{});var xd=l(mn);gr=s(xd,"encoder_hidden_states"),xd.forEach(o),fr=s(F," is then expected as an input to the forward pass."),F.forEach(o),_r=m(E),Ee=i(E,"P",{});var Dn=l(Ee);Mr=s(Dn,".. _"),un=i(Dn,"EM",{});var Wd=l(un);br=s(Wd,"Mega: Moving Average Equipped Gated Attention"),Wd.forEach(o),yr=s(Dn,": "),yt=i(Dn,"A",{href:!0,rel:!0});var Zd=l(yt);wr=s(Zd,"https://arxiv.org/abs/2209.10655"),Zd.forEach(o),Dn.forEach(o),vr=m(E),N=i(E,"DIV",{class:!0});var et=l(N);w(wt.$$.fragment,et),Tr=m(et),ie=i(et,"P",{});var qo=l(ie);kr=s(qo,"The "),wo=i(qo,"A",{href:!0});var Id=l(wo);$r=s(Id,"MegaModel"),Id.forEach(o),jr=s(qo," forward method, overrides the "),gn=i(qo,"CODE",{});var qd=l(gn);Cr=s(qd,"__call__"),qd.forEach(o),zr=s(qo," special method."),qo.forEach(o),Jr=m(et),w(Ue.$$.fragment,et),Fr=m(et),w(xe.$$.fragment,et),et.forEach(o),E.forEach(o),ha=m(t),le=i(t,"H2",{class:!0});var Ea=l(le);We=i(Ea,"A",{id:!0,class:!0,href:!0});var Bd=l(We);fn=i(Bd,"SPAN",{});var Gd=l(fn);w(vt.$$.fragment,Gd),Gd.forEach(o),Bd.forEach(o),Er=m(Ea),_n=i(Ea,"SPAN",{});var Ad=l(_n);Ur=s(Ad,"MegaForCausalLM"),Ad.forEach(o),Ea.forEach(o),ma=m(t),U=i(t,"DIV",{class:!0});var Q=l(U);w(Tt.$$.fragment,Q),xr=m(Q),kt=i(Q,"P",{});var Ua=l(kt);Wr=s(Ua,"MEGA Model with a "),Mn=i(Ua,"CODE",{});var Nd=l(Mn);Zr=s(Nd,"language modeling"),Nd.forEach(o),Ir=s(Ua," head on top for CLM fine-tuning."),Ua.forEach(o),qr=m(Q),$t=i(Q,"P",{});var xa=l($t);Br=s(xa,"This model inherits from "),vo=i(xa,"A",{href:!0});var Xd=l(vo);Gr=s(Xd,"PreTrainedModel"),Xd.forEach(o),Ar=s(xa,`. 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.)`),xa.forEach(o),Nr=m(Q),jt=i(Q,"P",{});var Wa=l(jt);Xr=s(Wa,"This model is also a PyTorch "),Ct=i(Wa,"A",{href:!0,rel:!0});var Rd=l(Ct);Rr=s(Rd,"torch.nn.Module"),Rd.forEach(o),Vr=s(Wa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Wa.forEach(o),Sr=m(Q),X=i(Q,"DIV",{class:!0});var tt=l(X);w(zt.$$.fragment,tt),Lr=m(tt),de=i(tt,"P",{});var Bo=l(de);Pr=s(Bo,"The "),To=i(Bo,"A",{href:!0});var Vd=l(To);Qr=s(Vd,"MegaForCausalLM"),Vd.forEach(o),Yr=s(Bo," forward method, overrides the "),bn=i(Bo,"CODE",{});var Sd=l(bn);Or=s(Sd,"__call__"),Sd.forEach(o),Hr=s(Bo," special method."),Bo.forEach(o),Dr=m(tt),w(Ze.$$.fragment,tt),Kr=m(tt),w(Ie.$$.fragment,tt),tt.forEach(o),Q.forEach(o),ua=m(t),ce=i(t,"H2",{class:!0});var Za=l(ce);qe=i(Za,"A",{id:!0,class:!0,href:!0});var Ld=l(qe);yn=i(Ld,"SPAN",{});var Pd=l(yn);w(Jt.$$.fragment,Pd),Pd.forEach(o),Ld.forEach(o),ei=m(Za),wn=i(Za,"SPAN",{});var Qd=l(wn);ti=s(Qd,"MegaForMaskedLM"),Qd.forEach(o),Za.forEach(o),ga=m(t),x=i(t,"DIV",{class:!0});var Y=l(x);w(Ft.$$.fragment,Y),oi=m(Y),Et=i(Y,"P",{});var Ia=l(Et);ni=s(Ia,"MEGA Model with a "),vn=i(Ia,"CODE",{});var Yd=l(vn);ai=s(Yd,"language modeling"),Yd.forEach(o),si=s(Ia," head on top."),Ia.forEach(o),ri=m(Y),Ut=i(Y,"P",{});var qa=l(Ut);ii=s(qa,"This model inherits from "),ko=i(qa,"A",{href:!0});var Od=l(ko);li=s(Od,"PreTrainedModel"),Od.forEach(o),di=s(qa,`. 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.)`),qa.forEach(o),ci=m(Y),xt=i(Y,"P",{});var Ba=l(xt);pi=s(Ba,"This model is also a PyTorch "),Wt=i(Ba,"A",{href:!0,rel:!0});var Hd=l(Wt);hi=s(Hd,"torch.nn.Module"),Hd.forEach(o),mi=s(Ba,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ba.forEach(o),ui=m(Y),R=i(Y,"DIV",{class:!0});var ot=l(R);w(Zt.$$.fragment,ot),gi=m(ot),pe=i(ot,"P",{});var Go=l(pe);fi=s(Go,"The "),$o=i(Go,"A",{href:!0});var Dd=l($o);_i=s(Dd,"MegaForMaskedLM"),Dd.forEach(o),Mi=s(Go," forward method, overrides the "),Tn=i(Go,"CODE",{});var Kd=l(Tn);bi=s(Kd,"__call__"),Kd.forEach(o),yi=s(Go," special method."),Go.forEach(o),wi=m(ot),w(Be.$$.fragment,ot),vi=m(ot),w(Ge.$$.fragment,ot),ot.forEach(o),Y.forEach(o),fa=m(t),he=i(t,"H2",{class:!0});var Ga=l(he);Ae=i(Ga,"A",{id:!0,class:!0,href:!0});var ec=l(Ae);kn=i(ec,"SPAN",{});var tc=l(kn);w(It.$$.fragment,tc),tc.forEach(o),ec.forEach(o),Ti=m(Ga),$n=i(Ga,"SPAN",{});var oc=l($n);ki=s(oc,"MegaForSequenceClassification"),oc.forEach(o),Ga.forEach(o),_a=m(t),W=i(t,"DIV",{class:!0});var O=l(W);w(qt.$$.fragment,O),$i=m(O),jn=i(O,"P",{});var nc=l(jn);ji=s(nc,`MEGA Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled
output) e.g. for GLUE tasks.`),nc.forEach(o),Ci=m(O),Bt=i(O,"P",{});var Aa=l(Bt);zi=s(Aa,"This model inherits from "),jo=i(Aa,"A",{href:!0});var ac=l(jo);Ji=s(ac,"PreTrainedModel"),ac.forEach(o),Fi=s(Aa,`. 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.)`),Aa.forEach(o),Ei=m(O),Gt=i(O,"P",{});var Na=l(Gt);Ui=s(Na,"This model is also a PyTorch "),At=i(Na,"A",{href:!0,rel:!0});var sc=l(At);xi=s(sc,"torch.nn.Module"),sc.forEach(o),Wi=s(Na,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Na.forEach(o),Zi=m(O),G=i(O,"DIV",{class:!0});var H=l(G);w(Nt.$$.fragment,H),Ii=m(H),me=i(H,"P",{});var Ao=l(me);qi=s(Ao,"The "),Co=i(Ao,"A",{href:!0});var rc=l(Co);Bi=s(rc,"MegaForSequenceClassification"),rc.forEach(o),Gi=s(Ao," forward method, overrides the "),Cn=i(Ao,"CODE",{});var ic=l(Cn);Ai=s(ic,"__call__"),ic.forEach(o),Ni=s(Ao," special method."),Ao.forEach(o),Xi=m(H),w(Ne.$$.fragment,H),Ri=m(H),w(Xe.$$.fragment,H),Vi=m(H),w(Re.$$.fragment,H),H.forEach(o),O.forEach(o),Ma=m(t),ue=i(t,"H2",{class:!0});var Xa=l(ue);Ve=i(Xa,"A",{id:!0,class:!0,href:!0});var lc=l(Ve);zn=i(lc,"SPAN",{});var dc=l(zn);w(Xt.$$.fragment,dc),dc.forEach(o),lc.forEach(o),Si=m(Xa),Jn=i(Xa,"SPAN",{});var cc=l(Jn);Li=s(cc,"MegaForMultipleChoice"),cc.forEach(o),Xa.forEach(o),ba=m(t),Z=i(t,"DIV",{class:!0});var D=l(Z);w(Rt.$$.fragment,D),Pi=m(D),Fn=i(D,"P",{});var pc=l(Fn);Qi=s(pc,`MEGA Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
softmax) e.g. for RocStories/SWAG tasks.`),pc.forEach(o),Yi=m(D),Vt=i(D,"P",{});var Ra=l(Vt);Oi=s(Ra,"This model inherits from "),zo=i(Ra,"A",{href:!0});var hc=l(zo);Hi=s(hc,"PreTrainedModel"),hc.forEach(o),Di=s(Ra,`. 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.)`),Ra.forEach(o),Ki=m(D),St=i(D,"P",{});var Va=l(St);el=s(Va,"This model is also a PyTorch "),Lt=i(Va,"A",{href:!0,rel:!0});var mc=l(Lt);tl=s(mc,"torch.nn.Module"),mc.forEach(o),ol=s(Va,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Va.forEach(o),nl=m(D),V=i(D,"DIV",{class:!0});var nt=l(V);w(Pt.$$.fragment,nt),al=m(nt),ge=i(nt,"P",{});var No=l(ge);sl=s(No,"The "),Jo=i(No,"A",{href:!0});var uc=l(Jo);rl=s(uc,"MegaForMultipleChoice"),uc.forEach(o),il=s(No," forward method, overrides the "),En=i(No,"CODE",{});var gc=l(En);ll=s(gc,"__call__"),gc.forEach(o),dl=s(No," special method."),No.forEach(o),cl=m(nt),w(Se.$$.fragment,nt),pl=m(nt),w(Le.$$.fragment,nt),nt.forEach(o),D.forEach(o),ya=m(t),fe=i(t,"H2",{class:!0});var Sa=l(fe);Pe=i(Sa,"A",{id:!0,class:!0,href:!0});var fc=l(Pe);Un=i(fc,"SPAN",{});var _c=l(Un);w(Qt.$$.fragment,_c),_c.forEach(o),fc.forEach(o),hl=m(Sa),xn=i(Sa,"SPAN",{});var Mc=l(xn);ml=s(Mc,"MegaForTokenClassification"),Mc.forEach(o),Sa.forEach(o),wa=m(t),I=i(t,"DIV",{class:!0});var K=l(I);w(Yt.$$.fragment,K),ul=m(K),Wn=i(K,"P",{});var bc=l(Wn);gl=s(bc,`MEGA Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),bc.forEach(o),fl=m(K),Ot=i(K,"P",{});var La=l(Ot);_l=s(La,"This model inherits from "),Fo=i(La,"A",{href:!0});var yc=l(Fo);Ml=s(yc,"PreTrainedModel"),yc.forEach(o),bl=s(La,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),La.forEach(o),yl=m(K),Ht=i(K,"P",{});var Pa=l(Ht);wl=s(Pa,"This model is also a PyTorch "),Dt=i(Pa,"A",{href:!0,rel:!0});var wc=l(Dt);vl=s(wc,"torch.nn.Module"),wc.forEach(o),Tl=s(Pa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Pa.forEach(o),kl=m(K),S=i(K,"DIV",{class:!0});var at=l(S);w(Kt.$$.fragment,at),$l=m(at),_e=i(at,"P",{});var Xo=l(_e);jl=s(Xo,"The "),Eo=i(Xo,"A",{href:!0});var vc=l(Eo);Cl=s(vc,"MegaForTokenClassification"),vc.forEach(o),zl=s(Xo," forward method, overrides the "),Zn=i(Xo,"CODE",{});var Tc=l(Zn);Jl=s(Tc,"__call__"),Tc.forEach(o),Fl=s(Xo," special method."),Xo.forEach(o),El=m(at),w(Qe.$$.fragment,at),Ul=m(at),w(Ye.$$.fragment,at),at.forEach(o),K.forEach(o),va=m(t),Me=i(t,"H2",{class:!0});var Qa=l(Me);Oe=i(Qa,"A",{id:!0,class:!0,href:!0});var kc=l(Oe);In=i(kc,"SPAN",{});var $c=l(In);w(eo.$$.fragment,$c),$c.forEach(o),kc.forEach(o),xl=m(Qa),qn=i(Qa,"SPAN",{});var jc=l(qn);Wl=s(jc,"MegaForQuestionAnswering"),jc.forEach(o),Qa.forEach(o),Ta=m(t),q=i(t,"DIV",{class:!0});var ee=l(q);w(to.$$.fragment,ee),Zl=m(ee),be=i(ee,"P",{});var Ro=l(be);Il=s(Ro,`MEGA Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `),Bn=i(Ro,"CODE",{});var Cc=l(Bn);ql=s(Cc,"span start logits"),Cc.forEach(o),Bl=s(Ro," and "),Gn=i(Ro,"CODE",{});var zc=l(Gn);Gl=s(zc,"span end logits"),zc.forEach(o),Al=s(Ro,")."),Ro.forEach(o),Nl=m(ee),oo=i(ee,"P",{});var Ya=l(oo);Xl=s(Ya,"This model inherits from "),Uo=i(Ya,"A",{href:!0});var Jc=l(Uo);Rl=s(Jc,"PreTrainedModel"),Jc.forEach(o),Vl=s(Ya,`. 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.)`),Ya.forEach(o),Sl=m(ee),no=i(ee,"P",{});var Oa=l(no);Ll=s(Oa,"This model is also a PyTorch "),ao=i(Oa,"A",{href:!0,rel:!0});var Fc=l(ao);Pl=s(Fc,"torch.nn.Module"),Fc.forEach(o),Ql=s(Oa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Oa.forEach(o),Yl=m(ee),L=i(ee,"DIV",{class:!0});var st=l(L);w(so.$$.fragment,st),Ol=m(st),ye=i(st,"P",{});var Vo=l(ye);Hl=s(Vo,"The "),xo=i(Vo,"A",{href:!0});var Ec=l(xo);Dl=s(Ec,"MegaForQuestionAnswering"),Ec.forEach(o),Kl=s(Vo," forward method, overrides the "),An=i(Vo,"CODE",{});var Uc=l(An);ed=s(Uc,"__call__"),Uc.forEach(o),td=s(Vo," special method."),Vo.forEach(o),od=m(st),w(He.$$.fragment,st),nd=m(st),w(De.$$.fragment,st),st.forEach(o),ee.forEach(o),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(tp)),u(p,"id","mega"),u(p,"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"),u(p,"href","#mega"),u(g,"class","relative group"),u(ke,"id","overview"),u(ke,"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"),u(ke,"href","#overview"),u(oe,"class","relative group"),u(it,"href","https://arxiv.org/abs/2209.10655"),u(it,"rel","nofollow"),u(dt,"href","https://huggingface.co/mnaylor"),u(dt,"rel","nofollow"),u(ct,"href","https://github.com/facebookresearch/mega"),u(ct,"rel","nofollow"),u(ze,"id","transformers.MegaConfig"),u(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(ze,"href","#transformers.MegaConfig"),u(ne,"class","relative group"),u(_o,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaModel"),u(mt,"href","https://huggingface.co/mnaylor/mega-base-wikitext"),u(mt,"rel","nofollow"),u(Mo,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),u(bo,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),u(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Fe,"id","transformers.MegaModel"),u(Fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Fe,"href","#transformers.MegaModel"),u(re,"class","relative group"),u(yo,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(Mt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Mt,"rel","nofollow"),u(yt,"href","https://arxiv.org/abs/2209.10655"),u(yt,"rel","nofollow"),u(wo,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaModel"),u(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(We,"id","transformers.MegaForCausalLM"),u(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"),u(We,"href","#transformers.MegaForCausalLM"),u(le,"class","relative group"),u(vo,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(Ct,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Ct,"rel","nofollow"),u(To,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaForCausalLM"),u(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(qe,"id","transformers.MegaForMaskedLM"),u(qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(qe,"href","#transformers.MegaForMaskedLM"),u(ce,"class","relative group"),u(ko,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(Wt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Wt,"rel","nofollow"),u($o,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaForMaskedLM"),u(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ae,"id","transformers.MegaForSequenceClassification"),u(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ae,"href","#transformers.MegaForSequenceClassification"),u(he,"class","relative group"),u(jo,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(At,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(At,"rel","nofollow"),u(Co,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaForSequenceClassification"),u(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ve,"id","transformers.MegaForMultipleChoice"),u(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"),u(Ve,"href","#transformers.MegaForMultipleChoice"),u(ue,"class","relative group"),u(zo,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(Lt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Lt,"rel","nofollow"),u(Jo,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaForMultipleChoice"),u(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Pe,"id","transformers.MegaForTokenClassification"),u(Pe,"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"),u(Pe,"href","#transformers.MegaForTokenClassification"),u(fe,"class","relative group"),u(Fo,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(Dt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Dt,"rel","nofollow"),u(Eo,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaForTokenClassification"),u(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Oe,"id","transformers.MegaForQuestionAnswering"),u(Oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Oe,"href","#transformers.MegaForQuestionAnswering"),u(Me,"class","relative group"),u(Uo,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),u(ao,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(ao,"rel","nofollow"),u(xo,"href","/docs/transformers/v4.32.0/en/model_doc/mega#transformers.MegaForQuestionAnswering"),u(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(q,"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,f){e(document.head,d),M(t,b,f),M(t,g,f),e(g,p),e(p,_),v(n,_,null),e(g,c),e(g,C),e(C,Ha),M(t,Kn,f),M(t,oe,f),e(oe,ke),e(ke,So),v(rt,So,null),e(oe,Da),e(oe,Lo),e(Lo,Ka),M(t,ea,f),M(t,$e,f),e($e,es),e($e,it),e(it,ts),e($e,os),M(t,ta,f),M(t,mo,f),e(mo,ns),M(t,oa,f),M(t,uo,f),e(uo,Po),e(Po,as),M(t,na,f),M(t,go,f),e(go,ss),M(t,aa,f),M(t,je,f),e(je,lt),e(lt,rs),e(lt,Qo),e(Qo,is),e(lt,ls),e(je,ds),e(je,Yo),e(Yo,cs),M(t,sa,f),M(t,P,f),e(P,ps),e(P,dt),e(dt,hs),e(P,ms),e(P,ct),e(ct,us),e(P,gs),M(t,ra,f),M(t,fo,f),e(fo,fs),M(t,ia,f),M(t,Ce,f),e(Ce,Oo),e(Oo,_s),e(Ce,Ms),e(Ce,Ho),e(Ho,bs),M(t,la,f),M(t,ne,f),e(ne,ze),e(ze,Do),v(pt,Do,null),e(ne,ys),e(ne,Ko),e(Ko,ws),M(t,da,f),M(t,A,f),v(ht,A,null),e(A,vs),e(A,ae),e(ae,Ts),e(ae,_o),e(_o,ks),e(ae,$s),e(ae,mt),e(mt,js),e(ae,Cs),e(A,zs),e(A,se),e(se,Js),e(se,Mo),e(Mo,Fs),e(se,Es),e(se,bo),e(bo,Us),e(se,xs),e(A,Ws),v(Je,A,null),M(t,ca,f),M(t,re,f),e(re,Fe),e(Fe,en),v(ut,en,null),e(re,Zs),e(re,tn),e(tn,Is),M(t,pa,f),M(t,J,f),v(gt,J,null),e(J,qs),e(J,on),e(on,Bs),e(J,Gs),e(J,ft),e(ft,As),e(ft,yo),e(yo,Ns),e(ft,Xs),e(J,Rs),e(J,_t),e(_t,Vs),e(_t,Mt),e(Mt,Ss),e(_t,Ls),e(J,Ps),e(J,bt),e(bt,Qs),e(bt,nn),e(nn,Ys),e(bt,Os),e(J,Hs),e(J,z),e(z,Ds),e(z,an),e(an,Ks),e(z,er),e(z,sn),e(sn,tr),e(z,or),e(z,rn),e(rn,nr),e(z,ar),e(z,ln),e(ln,sr),e(z,rr),e(z,dn),e(dn,ir),e(z,lr),e(z,cn),e(cn,dr),e(z,cr),e(z,pn),e(pn,pr),e(z,hr),e(z,hn),e(hn,mr),e(z,ur),e(z,mn),e(mn,gr),e(z,fr),e(J,_r),e(J,Ee),e(Ee,Mr),e(Ee,un),e(un,br),e(Ee,yr),e(Ee,yt),e(yt,wr),e(J,vr),e(J,N),v(wt,N,null),e(N,Tr),e(N,ie),e(ie,kr),e(ie,wo),e(wo,$r),e(ie,jr),e(ie,gn),e(gn,Cr),e(ie,zr),e(N,Jr),v(Ue,N,null),e(N,Fr),v(xe,N,null),M(t,ha,f),M(t,le,f),e(le,We),e(We,fn),v(vt,fn,null),e(le,Er),e(le,_n),e(_n,Ur),M(t,ma,f),M(t,U,f),v(Tt,U,null),e(U,xr),e(U,kt),e(kt,Wr),e(kt,Mn),e(Mn,Zr),e(kt,Ir),e(U,qr),e(U,$t),e($t,Br),e($t,vo),e(vo,Gr),e($t,Ar),e(U,Nr),e(U,jt),e(jt,Xr),e(jt,Ct),e(Ct,Rr),e(jt,Vr),e(U,Sr),e(U,X),v(zt,X,null),e(X,Lr),e(X,de),e(de,Pr),e(de,To),e(To,Qr),e(de,Yr),e(de,bn),e(bn,Or),e(de,Hr),e(X,Dr),v(Ze,X,null),e(X,Kr),v(Ie,X,null),M(t,ua,f),M(t,ce,f),e(ce,qe),e(qe,yn),v(Jt,yn,null),e(ce,ei),e(ce,wn),e(wn,ti),M(t,ga,f),M(t,x,f),v(Ft,x,null),e(x,oi),e(x,Et),e(Et,ni),e(Et,vn),e(vn,ai),e(Et,si),e(x,ri),e(x,Ut),e(Ut,ii),e(Ut,ko),e(ko,li),e(Ut,di),e(x,ci),e(x,xt),e(xt,pi),e(xt,Wt),e(Wt,hi),e(xt,mi),e(x,ui),e(x,R),v(Zt,R,null),e(R,gi),e(R,pe),e(pe,fi),e(pe,$o),e($o,_i),e(pe,Mi),e(pe,Tn),e(Tn,bi),e(pe,yi),e(R,wi),v(Be,R,null),e(R,vi),v(Ge,R,null),M(t,fa,f),M(t,he,f),e(he,Ae),e(Ae,kn),v(It,kn,null),e(he,Ti),e(he,$n),e($n,ki),M(t,_a,f),M(t,W,f),v(qt,W,null),e(W,$i),e(W,jn),e(jn,ji),e(W,Ci),e(W,Bt),e(Bt,zi),e(Bt,jo),e(jo,Ji),e(Bt,Fi),e(W,Ei),e(W,Gt),e(Gt,Ui),e(Gt,At),e(At,xi),e(Gt,Wi),e(W,Zi),e(W,G),v(Nt,G,null),e(G,Ii),e(G,me),e(me,qi),e(me,Co),e(Co,Bi),e(me,Gi),e(me,Cn),e(Cn,Ai),e(me,Ni),e(G,Xi),v(Ne,G,null),e(G,Ri),v(Xe,G,null),e(G,Vi),v(Re,G,null),M(t,Ma,f),M(t,ue,f),e(ue,Ve),e(Ve,zn),v(Xt,zn,null),e(ue,Si),e(ue,Jn),e(Jn,Li),M(t,ba,f),M(t,Z,f),v(Rt,Z,null),e(Z,Pi),e(Z,Fn),e(Fn,Qi),e(Z,Yi),e(Z,Vt),e(Vt,Oi),e(Vt,zo),e(zo,Hi),e(Vt,Di),e(Z,Ki),e(Z,St),e(St,el),e(St,Lt),e(Lt,tl),e(St,ol),e(Z,nl),e(Z,V),v(Pt,V,null),e(V,al),e(V,ge),e(ge,sl),e(ge,Jo),e(Jo,rl),e(ge,il),e(ge,En),e(En,ll),e(ge,dl),e(V,cl),v(Se,V,null),e(V,pl),v(Le,V,null),M(t,ya,f),M(t,fe,f),e(fe,Pe),e(Pe,Un),v(Qt,Un,null),e(fe,hl),e(fe,xn),e(xn,ml),M(t,wa,f),M(t,I,f),v(Yt,I,null),e(I,ul),e(I,Wn),e(Wn,gl),e(I,fl),e(I,Ot),e(Ot,_l),e(Ot,Fo),e(Fo,Ml),e(Ot,bl),e(I,yl),e(I,Ht),e(Ht,wl),e(Ht,Dt),e(Dt,vl),e(Ht,Tl),e(I,kl),e(I,S),v(Kt,S,null),e(S,$l),e(S,_e),e(_e,jl),e(_e,Eo),e(Eo,Cl),e(_e,zl),e(_e,Zn),e(Zn,Jl),e(_e,Fl),e(S,El),v(Qe,S,null),e(S,Ul),v(Ye,S,null),M(t,va,f),M(t,Me,f),e(Me,Oe),e(Oe,In),v(eo,In,null),e(Me,xl),e(Me,qn),e(qn,Wl),M(t,Ta,f),M(t,q,f),v(to,q,null),e(q,Zl),e(q,be),e(be,Il),e(be,Bn),e(Bn,ql),e(be,Bl),e(be,Gn),e(Gn,Gl),e(be,Al),e(q,Nl),e(q,oo),e(oo,Xl),e(oo,Uo),e(Uo,Rl),e(oo,Vl),e(q,Sl),e(q,no),e(no,Ll),e(no,ao),e(ao,Pl),e(no,Ql),e(q,Yl),e(q,L),v(so,L,null),e(L,Ol),e(L,ye),e(ye,Hl),e(ye,xo),e(xo,Dl),e(ye,Kl),e(ye,An),e(An,ed),e(ye,td),e(L,od),v(He,L,null),e(L,nd),v(De,L,null),ka=!0},p(t,[f]){const ro={};f&2&&(ro.$$scope={dirty:f,ctx:t}),Je.$set(ro);const Nn={};f&2&&(Nn.$$scope={dirty:f,ctx:t}),Ue.$set(Nn);const Xn={};f&2&&(Xn.$$scope={dirty:f,ctx:t}),xe.$set(Xn);const Rn={};f&2&&(Rn.$$scope={dirty:f,ctx:t}),Ze.$set(Rn);const io={};f&2&&(io.$$scope={dirty:f,ctx:t}),Ie.$set(io);const Vn={};f&2&&(Vn.$$scope={dirty:f,ctx:t}),Be.$set(Vn);const Sn={};f&2&&(Sn.$$scope={dirty:f,ctx:t}),Ge.$set(Sn);const Ln={};f&2&&(Ln.$$scope={dirty:f,ctx:t}),Ne.$set(Ln);const lo={};f&2&&(lo.$$scope={dirty:f,ctx:t}),Xe.$set(lo);const Pn={};f&2&&(Pn.$$scope={dirty:f,ctx:t}),Re.$set(Pn);const Qn={};f&2&&(Qn.$$scope={dirty:f,ctx:t}),Se.$set(Qn);const Yn={};f&2&&(Yn.$$scope={dirty:f,ctx:t}),Le.$set(Yn);const On={};f&2&&(On.$$scope={dirty:f,ctx:t}),Qe.$set(On);const Hn={};f&2&&(Hn.$$scope={dirty:f,ctx:t}),Ye.$set(Hn);const co={};f&2&&(co.$$scope={dirty:f,ctx:t}),He.$set(co);const po={};f&2&&(po.$$scope={dirty:f,ctx:t}),De.$set(po)},i(t){ka||(T(n.$$.fragment,t),T(rt.$$.fragment,t),T(pt.$$.fragment,t),T(ht.$$.fragment,t),T(Je.$$.fragment,t),T(ut.$$.fragment,t),T(gt.$$.fragment,t),T(wt.$$.fragment,t),T(Ue.$$.fragment,t),T(xe.$$.fragment,t),T(vt.$$.fragment,t),T(Tt.$$.fragment,t),T(zt.$$.fragment,t),T(Ze.$$.fragment,t),T(Ie.$$.fragment,t),T(Jt.$$.fragment,t),T(Ft.$$.fragment,t),T(Zt.$$.fragment,t),T(Be.$$.fragment,t),T(Ge.$$.fragment,t),T(It.$$.fragment,t),T(qt.$$.fragment,t),T(Nt.$$.fragment,t),T(Ne.$$.fragment,t),T(Xe.$$.fragment,t),T(Re.$$.fragment,t),T(Xt.$$.fragment,t),T(Rt.$$.fragment,t),T(Pt.$$.fragment,t),T(Se.$$.fragment,t),T(Le.$$.fragment,t),T(Qt.$$.fragment,t),T(Yt.$$.fragment,t),T(Kt.$$.fragment,t),T(Qe.$$.fragment,t),T(Ye.$$.fragment,t),T(eo.$$.fragment,t),T(to.$$.fragment,t),T(so.$$.fragment,t),T(He.$$.fragment,t),T(De.$$.fragment,t),ka=!0)},o(t){k(n.$$.fragment,t),k(rt.$$.fragment,t),k(pt.$$.fragment,t),k(ht.$$.fragment,t),k(Je.$$.fragment,t),k(ut.$$.fragment,t),k(gt.$$.fragment,t),k(wt.$$.fragment,t),k(Ue.$$.fragment,t),k(xe.$$.fragment,t),k(vt.$$.fragment,t),k(Tt.$$.fragment,t),k(zt.$$.fragment,t),k(Ze.$$.fragment,t),k(Ie.$$.fragment,t),k(Jt.$$.fragment,t),k(Ft.$$.fragment,t),k(Zt.$$.fragment,t),k(Be.$$.fragment,t),k(Ge.$$.fragment,t),k(It.$$.fragment,t),k(qt.$$.fragment,t),k(Nt.$$.fragment,t),k(Ne.$$.fragment,t),k(Xe.$$.fragment,t),k(Re.$$.fragment,t),k(Xt.$$.fragment,t),k(Rt.$$.fragment,t),k(Pt.$$.fragment,t),k(Se.$$.fragment,t),k(Le.$$.fragment,t),k(Qt.$$.fragment,t),k(Yt.$$.fragment,t),k(Kt.$$.fragment,t),k(Qe.$$.fragment,t),k(Ye.$$.fragment,t),k(eo.$$.fragment,t),k(to.$$.fragment,t),k(so.$$.fragment,t),k(He.$$.fragment,t),k(De.$$.fragment,t),ka=!1},d(t){o(d),t&&o(b),t&&o(g),$(n),t&&o(Kn),t&&o(oe),$(rt),t&&o(ea),t&&o($e),t&&o(ta),t&&o(mo),t&&o(oa),t&&o(uo),t&&o(na),t&&o(go),t&&o(aa),t&&o(je),t&&o(sa),t&&o(P),t&&o(ra),t&&o(fo),t&&o(ia),t&&o(Ce),t&&o(la),t&&o(ne),$(pt),t&&o(da),t&&o(A),$(ht),$(Je),t&&o(ca),t&&o(re),$(ut),t&&o(pa),t&&o(J),$(gt),$(wt),$(Ue),$(xe),t&&o(ha),t&&o(le),$(vt),t&&o(ma),t&&o(U),$(Tt),$(zt),$(Ze),$(Ie),t&&o(ua),t&&o(ce),$(Jt),t&&o(ga),t&&o(x),$(Ft),$(Zt),$(Be),$(Ge),t&&o(fa),t&&o(he),$(It),t&&o(_a),t&&o(W),$(qt),$(Nt),$(Ne),$(Xe),$(Re),t&&o(Ma),t&&o(ue),$(Xt),t&&o(ba),t&&o(Z),$(Rt),$(Pt),$(Se),$(Le),t&&o(ya),t&&o(fe),$(Qt),t&&o(wa),t&&o(I),$(Yt),$(Kt),$(Qe),$(Ye),t&&o(va),t&&o(Me),$(eo),t&&o(Ta),t&&o(q),$(to),$(so),$(He),$(De)}}}const tp={local:"mega",sections:[{local:"overview",title:"Overview"},{local:"transformers.MegaConfig",title:"MegaConfig"},{local:"transformers.MegaModel",title:"MegaModel"},{local:"transformers.MegaForCausalLM",title:"MegaForCausalLM"},{local:"transformers.MegaForMaskedLM",title:"MegaForMaskedLM"},{local:"transformers.MegaForSequenceClassification",title:"MegaForSequenceClassification"},{local:"transformers.MegaForMultipleChoice",title:"MegaForMultipleChoice"},{local:"transformers.MegaForTokenClassification",title:"MegaForTokenClassification"},{local:"transformers.MegaForQuestionAnswering",title:"MegaForQuestionAnswering"}],title:"MEGA"};function op(j){return qc(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class dp extends xc{constructor(d){super();Wc(this,d,op,ep,Zc,{})}}export{dp as default,tp as metadata};
