import{S as Om,i as Ym,s as Dm,e as a,k as p,w as y,t as s,M as Km,c as i,d as o,m as h,a as l,x as T,h as r,b as m,G as e,g as _,y as v,q as w,o as k,B,v as eu,L as oe}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ge}from"../../chunks/Tip-hf-doc-builder.js";import{D as j}from"../../chunks/Docstring-hf-doc-builder.js";import{C as R}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as S}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as te}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function tu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME1lZ2F0cm9uQmVydENvbmZpZyUyQyUyME1lZ2F0cm9uQmVydE1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyME1FR0FUUk9OX0JFUlQlMjBiZXJ0LWJhc2UtdW5jYXNlZCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBNZWdhdHJvbkJlcnRDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwYmVydC1iYXNlLXVuY2FzZWQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyME1lZ2F0cm9uQmVydE1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MegatronBertConfig, MegatronBertModel

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the bert-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertModel(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=a("p"),b=s("Examples:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Examples:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function ou($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function nu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGbWVnYXRyb24tYmVydC1jYXNlZC0zNDVtJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWVnYXRyb25CZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertModel
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertModel.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function su($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function ru($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JNYXNrZWRMTSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGbWVnYXRyb24tYmVydC1jYXNlZC0zNDVtJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWVnYXRyb25CZXJ0Rm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyVGhlJTIwY2FwaXRhbCUyMG9mJTIwRnJhbmNlJTIwaXMlMjAlNUJNQVNLJTVELiUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMGxvZ2l0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEElMEElMjMlMjByZXRyaWV2ZSUyMGluZGV4JTIwb2YlMjAlNUJNQVNLJTVEJTBBbWFza190b2tlbl9pbmRleCUyMCUzRCUyMChpbnB1dHMuaW5wdXRfaWRzJTIwJTNEJTNEJTIwdG9rZW5pemVyLm1hc2tfdG9rZW5faWQpJTVCMCU1RC5ub256ZXJvKGFzX3R1cGxlJTNEVHJ1ZSklNUIwJTVEJTBBJTBBcHJlZGljdGVkX3Rva2VuX2lkJTIwJTNEJTIwbG9naXRzJTVCMCUyQyUyMG1hc2tfdG9rZW5faW5kZXglNUQuYXJnbWF4KGF4aXMlM0QtMSklMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyVGhlJTIwY2FwaXRhbCUyMG9mJTIwRnJhbmNlJTIwaXMlMjBQYXJpcy4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQSUyMyUyMG1hc2slMjBsYWJlbHMlMjBvZiUyMG5vbi0lNUJNQVNLJTVEJTIwdG9rZW5zJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2gud2hlcmUoaW5wdXRzLmlucHV0X2lkcyUyMCUzRCUzRCUyMHRva2VuaXplci5tYXNrX3Rva2VuX2lkJTJDJTIwbGFiZWxzJTJDJTIwLTEwMCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBsYWJlbHMlM0RsYWJlbHMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForMaskedLM
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span><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 [MASK]</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>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-[MASK] 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)`}}),{c(){d=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function au($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function iu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JDYXVzYWxMTSUyQyUyME1lZ2F0cm9uQmVydENvbmZpZyUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGbWVnYXRyb24tYmVydC1jYXNlZC0zNDVtJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWVnYXRyb25CZXJ0Rm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiUyQyUyMGlzX2RlY29kZXIlM0RUcnVlKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBcHJlZGljdGlvbl9sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForCausalLM, MegatronBertConfig
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForCausalLM.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>, is_decoder=<span class="hljs-literal">True</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=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function lu($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function du($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JOZXh0U2VudGVuY2VQcmVkaWN0aW9uJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhdHJvbkJlcnRGb3JOZXh0U2VudGVuY2VQcmVkaWN0aW9uLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIySW4lMjBJdGFseSUyQyUyMHBpenphJTIwc2VydmVkJTIwaW4lMjBmb3JtYWwlMjBzZXR0aW5ncyUyQyUyMHN1Y2glMjBhcyUyMGF0JTIwYSUyMHJlc3RhdXJhbnQlMkMlMjBpcyUyMHByZXNlbnRlZCUyMHVuc2xpY2VkLiUyMiUwQW5leHRfc2VudGVuY2UlMjAlM0QlMjAlMjJUaGUlMjBza3klMjBpcyUyMGJsdWUlMjBkdWUlMjB0byUyMHRoZSUyMHNob3J0ZXIlMjB3YXZlbGVuZ3RoJTIwb2YlMjBibHVlJTIwbGlnaHQuJTIyJTBBZW5jb2RpbmclMjAlM0QlMjB0b2tlbml6ZXIocHJvbXB0JTJDJTIwbmV4dF9zZW50ZW5jZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqZW5jb2RpbmclMkMlMjBsYWJlbHMlM0R0b3JjaC5Mb25nVGVuc29yKCU1QjElNUQpKSUwQWxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRzJTBBYXNzZXJ0JTIwbG9naXRzJTVCMCUyQyUyMDAlNUQlMjAlM0MlMjBsb2dpdHMlNUIwJTJDJTIwMSU1RCUyMCUyMCUyMyUyMG5leHQlMjBzZW50ZW5jZSUyMHdhcyUyMHJhbmRvbQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForNextSentencePrediction
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForNextSentencePrediction.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, labels=torch.LongTensor([<span class="hljs-number">1</span>]))
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">assert</span> logits[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>] &lt; logits[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]  <span class="hljs-comment"># next sentence was random</span>`}}),{c(){d=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function cu($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function pu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JQcmVUcmFpbmluZyUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGbWVnYXRyb24tYmVydC1jYXNlZC0zNDVtJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWVnYXRyb25CZXJ0Rm9yUHJlVHJhaW5pbmcuZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQXByZWRpY3Rpb25fbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5wcmVkaWN0aW9uX2xvZ2l0cyUwQXNlcV9yZWxhdGlvbnNoaXBfbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5zZXFfcmVsYXRpb25zaGlwX2xvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForPreTraining
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForPreTraining.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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>prediction_logits = outputs.prediction_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>seq_relationship_logits = outputs.seq_relationship_logits`}}),{c(){d=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function hu($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function mu($){let d,b,f,u,M;return u=new R({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyME1lZ2F0cm9uQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhdHJvbkJlcnRGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX2NsYXNzX2lkJTIwJTNEJTIwbG9naXRzLmFyZ21heCgpLml0ZW0oKSUwQSUwQSUyMyUyMFRvJTIwdHJhaW4lMjBhJTIwbW9kZWwlMjBvbiUyMCU2MG51bV9sYWJlbHMlNjAlMjBjbGFzc2VzJTJDJTIweW91JTIwY2FuJTIwcGFzcyUyMCU2MG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTYwJTIwdG8lMjAlNjAuZnJvbV9wcmV0cmFpbmVkKC4uLiklNjAlMEFudW1fbGFiZWxzJTIwJTNEJTIwbGVuKG1vZGVsLmNvbmZpZy5pZDJsYWJlbCklMEFtb2RlbCUyMCUzRCUyME1lZ2F0cm9uQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxJTVEKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",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, MegatronBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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 = MegatronBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),b=s("Example of single-label classification:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example of single-label classification:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function uu($){let d,b,f,u,M;return u=new R({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyME1lZ2F0cm9uQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhdHJvbkJlcnRGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIlMkMlMjBwcm9ibGVtX3R5cGUlM0QlMjJtdWx0aV9sYWJlbF9jbGFzc2lmaWNhdGlvbiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMGxvZ2l0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEElMEFwcmVkaWN0ZWRfY2xhc3NfaWRzJTIwJTNEJTIwdG9yY2guYXJhbmdlKDAlMkMlMjBsb2dpdHMuc2hhcGUlNUItMSU1RCklNUJ0b3JjaC5zaWdtb2lkKGxvZ2l0cykuc3F1ZWV6ZShkaW0lM0QwKSUyMCUzRSUyMDAuNSU1RCUwQSUwQSUyMyUyMFRvJTIwdHJhaW4lMjBhJTIwbW9kZWwlMjBvbiUyMCU2MG51bV9sYWJlbHMlNjAlMjBjbGFzc2VzJTJDJTIweW91JTIwY2FuJTIwcGFzcyUyMCU2MG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTYwJTIwdG8lMjAlNjAuZnJvbV9wcmV0cmFpbmVkKC4uLiklNjAlMEFudW1fbGFiZWxzJTIwJTNEJTIwbGVuKG1vZGVsLmNvbmZpZy5pZDJsYWJlbCklMEFtb2RlbCUyMCUzRCUyME1lZ2F0cm9uQmVydEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIlMEEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2guc3VtKCUwQSUyMCUyMCUyMCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwub25lX2hvdChwcmVkaWN0ZWRfY2xhc3NfaWRzJTVCTm9uZSUyQyUyMCUzQSU1RC5jbG9uZSgpJTJDJTIwbnVtX2NsYXNzZXMlM0RudW1fbGFiZWxzKSUyQyUyMGRpbSUzRDElMEEpLnRvKHRvcmNoLmZsb2F0KSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",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, MegatronBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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 = MegatronBertForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),b=s("Example of multi-label classification:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example of multi-label classification:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function gu($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function fu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JNdWx0aXBsZUNob2ljZSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGbWVnYXRyb24tYmVydC1jYXNlZC0zNDVtJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWVnYXRyb25CZXJ0Rm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJJbiUyMEl0YWx5JTJDJTIwcGl6emElMjBzZXJ2ZWQlMjBpbiUyMGZvcm1hbCUyMHNldHRpbmdzJTJDJTIwc3VjaCUyMGFzJTIwYXQlMjBhJTIwcmVzdGF1cmFudCUyQyUyMGlzJTIwcHJlc2VudGVkJTIwdW5zbGljZWQuJTIyJTBBY2hvaWNlMCUyMCUzRCUyMCUyMkl0JTIwaXMlMjBlYXRlbiUyMHdpdGglMjBhJTIwZm9yayUyMGFuZCUyMGElMjBrbmlmZS4lMjIlMEFjaG9pY2UxJTIwJTNEJTIwJTIySXQlMjBpcyUyMGVhdGVuJTIwd2hpbGUlMjBoZWxkJTIwaW4lMjB0aGUlMjBoYW5kLiUyMiUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvcigwKS51bnNxdWVlemUoMCklMjAlMjAlMjMlMjBjaG9pY2UwJTIwaXMlMjBjb3JyZWN0JTIwKGFjY29yZGluZyUyMHRvJTIwV2lraXBlZGlhJTIwJTNCKSklMkMlMjBiYXRjaCUyMHNpemUlMjAxJTBBJTBBZW5jb2RpbmclMjAlM0QlMjB0b2tlbml6ZXIoJTVCcHJvbXB0JTJDJTIwcHJvbXB0JTVEJTJDJTIwJTVCY2hvaWNlMCUyQyUyMGNob2ljZTElNUQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwcGFkZGluZyUzRFRydWUpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqJTdCayUzQSUyMHYudW5zcXVlZXplKDApJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGVuY29kaW5nLml0ZW1zKCklN0QlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTIwJTIwJTIzJTIwYmF0Y2glMjBzaXplJTIwaXMlMjAxJTBBJTBBJTIzJTIwdGhlJTIwbGluZWFyJTIwY2xhc3NpZmllciUyMHN0aWxsJTIwbmVlZHMlMjB0byUyMGJlJTIwdHJhaW5lZCUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3MlMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForMultipleChoice
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function _u($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function Mu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JUb2tlbkNsYXNzaWZpY2F0aW9uJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBbW9kZWwlMjAlM0QlMjBNZWdhdHJvbkJlcnRGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZtZWdhdHJvbi1iZXJ0LWNhc2VkLTM0NW0lMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUwQSUyMCUyMCUyMCUyMCUyMkh1Z2dpbmdGYWNlJTIwaXMlMjBhJTIwY29tcGFueSUyMGJhc2VkJTIwaW4lMjBQYXJpcyUyMGFuZCUyME5ldyUyMFlvcmslMjIlMkMlMjBhZGRfc3BlY2lhbF90b2tlbnMlM0RGYWxzZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMEEpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMGxvZ2l0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEElMEFwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTIwJTNEJTIwbG9naXRzLmFyZ21heCgtMSklMEElMEElMjMlMjBOb3RlJTIwdGhhdCUyMHRva2VucyUyMGFyZSUyMGNsYXNzaWZpZWQlMjByYXRoZXIlMjB0aGVuJTIwaW5wdXQlMjB3b3JkcyUyMHdoaWNoJTIwbWVhbnMlMjB0aGF0JTBBJTIzJTIwdGhlcmUlMjBtaWdodCUyMGJlJTIwbW9yZSUyMHByZWRpY3RlZCUyMHRva2VuJTIwY2xhc3NlcyUyMHRoYW4lMjB3b3Jkcy4lMEElMjMlMjBNdWx0aXBsZSUyMHRva2VuJTIwY2xhc3NlcyUyMG1pZ2h0JTIwYWNjb3VudCUyMGZvciUyMHRoZSUyMHNhbWUlMjB3b3JkJTBBcHJlZGljdGVkX3Rva2Vuc19jbGFzc2VzJTIwJTNEJTIwJTVCbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCdC5pdGVtKCklNUQlMjBmb3IlMjB0JTIwaW4lMjBwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTVCMCU1RCU1RCUwQSUwQWxhYmVscyUyMCUzRCUyMHByZWRpY3RlZF90b2tlbl9jbGFzc19pZHMlMEFsb3NzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpLmxvc3M=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForTokenClassification
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForTokenClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function bu($){let d,b,f,u,M;return{c(){d=a("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=s("Module"),M=s(`
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=r(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var J=l(f);u=r(J,"Module"),J.forEach(o),M=r(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){_(n,d,c),e(d,b),e(d,f),e(f,u),e(d,M)},d(n){n&&o(d)}}}function yu($){let d,b,f,u,M;return u=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBNZWdhdHJvbkJlcnRGb3JRdWVzdGlvbkFuc3dlcmluZyUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybnZpZGlhJTJGbWVnYXRyb24tYmVydC1jYXNlZC0zNDVtJTIyKSUwQW1vZGVsJTIwJTNEJTIwTWVnYXRyb25CZXJ0Rm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMm52aWRpYSUyRm1lZ2F0cm9uLWJlcnQtY2FzZWQtMzQ1bSUyMiklMEElMEFxdWVzdGlvbiUyQyUyMHRleHQlMjAlM0QlMjAlMjJXaG8lMjB3YXMlMjBKaW0lMjBIZW5zb24lM0YlMjIlMkMlMjAlMjJKaW0lMjBIZW5zb24lMjB3YXMlMjBhJTIwbmljZSUyMHB1cHBldCUyMiUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBYW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNEJTIwb3V0cHV0cy5zdGFydF9sb2dpdHMuYXJnbWF4KCklMEFhbnN3ZXJfZW5kX2luZGV4JTIwJTNEJTIwb3V0cHV0cy5lbmRfbG9naXRzLmFyZ21heCgpJTBBJTBBcHJlZGljdF9hbnN3ZXJfdG9rZW5zJTIwJTNEJTIwaW5wdXRzLmlucHV0X2lkcyU1QjAlMkMlMjBhbnN3ZXJfc3RhcnRfaW5kZXglMjAlM0ElMjBhbnN3ZXJfZW5kX2luZGV4JTIwJTJCJTIwMSU1RCUwQSUwQSUyMyUyMHRhcmdldCUyMGlzJTIwJTIybmljZSUyMHB1cHBldCUyMiUwQXRhcmdldF9zdGFydF9pbmRleCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxNCU1RCklMEF0YXJnZXRfZW5kX2luZGV4JTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QjE1JTVEKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMHN0YXJ0X3Bvc2l0aW9ucyUzRHRhcmdldF9zdGFydF9pbmRleCUyQyUyMGVuZF9wb3NpdGlvbnMlM0R0YXJnZXRfZW5kX2luZGV4KSUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3M=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForQuestionAnswering
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),b=s("Example:"),f=p(),y(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);b=r(c,"Example:"),c.forEach(o),f=h(n),T(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,f,c),v(u,n,c),M=!0},p:oe,i(n){M||(w(u.$$.fragment,n),M=!0)},o(n){k(u.$$.fragment,n),M=!1},d(n){n&&o(d),n&&o(f),B(u,n)}}}function Tu($){let d,b,f,u,M,n,c,J,xa,Mr,ge,Pe,Dn,zt,Ia,Kn,Va,br,qe,Ra,Et,Ga,Pa,yr,on,qa,Tr,nn,es,Aa,vr,sn,Sa,wr,Ae,Xa,Ut,La,Qa,kr,ne,Ha,Wt,Oa,Ya,Nt,Da,Ka,Br,rn,ei,$r,an,ti,Jr,Zt,Fr,ln,oi,jr,xt,Cr,dn,ni,zr,se,si,ts,ri,ai,os,ii,li,Er,It,Ur,Vt,Wr,re,di,Rt,ci,pi,Gt,hi,mi,Nr,fe,Se,ns,Pt,ui,ss,gi,Zr,z,rs,cn,fi,_i,as,pn,Mi,bi,is,hn,yi,Ti,ls,mn,vi,wi,ds,un,ki,Bi,cs,gn,$i,xr,_e,Xe,ps,qt,Ji,hs,Fi,Ir,A,At,ji,Me,Ci,fn,zi,Ei,St,Ui,Wi,Ni,be,Zi,_n,xi,Ii,Mn,Vi,Ri,Gi,Le,Vr,ye,Qe,ms,Xt,Pi,us,qi,Rr,F,Lt,Ai,gs,Si,Xi,Qt,Li,bn,Qi,Hi,Oi,Ht,Yi,Ot,Di,Ki,el,Yt,tl,Dt,ol,nl,sl,C,rl,fs,al,il,_s,ll,dl,Ms,cl,pl,bs,hl,ml,ys,ul,gl,Ts,fl,_l,Ml,X,Kt,bl,Te,yl,yn,Tl,vl,vs,wl,kl,Bl,He,$l,Oe,Gr,ve,Ye,ws,eo,Jl,ks,Fl,Pr,E,to,jl,oo,Cl,Bs,zl,El,Ul,no,Wl,Tn,Nl,Zl,xl,so,Il,ro,Vl,Rl,Gl,L,ao,Pl,we,ql,vn,Al,Sl,$s,Xl,Ll,Ql,De,Hl,Ke,qr,ke,et,Js,io,Ol,Fs,Yl,Ar,U,lo,Dl,co,Kl,js,ed,td,od,po,nd,wn,sd,rd,ad,ho,id,mo,ld,dd,cd,Q,uo,pd,Be,hd,kn,md,ud,Cs,gd,fd,_d,tt,Md,ot,Sr,$e,nt,zs,go,bd,Es,yd,Xr,W,fo,Td,_o,vd,Us,wd,kd,Bd,Mo,$d,Bn,Jd,Fd,jd,bo,Cd,yo,zd,Ed,Ud,H,To,Wd,Je,Nd,$n,Zd,xd,Ws,Id,Vd,Rd,st,Gd,rt,Lr,Fe,at,Ns,vo,Pd,Zs,qd,Qr,N,wo,Ad,je,Sd,xs,Xd,Ld,Is,Qd,Hd,Od,ko,Yd,Jn,Dd,Kd,ec,Bo,tc,$o,oc,nc,sc,O,Jo,rc,Ce,ac,Fn,ic,lc,Vs,dc,cc,pc,it,hc,lt,Hr,ze,dt,Rs,Fo,mc,Gs,uc,Or,Z,jo,gc,Ps,fc,_c,Co,Mc,jn,bc,yc,Tc,zo,vc,Eo,wc,kc,Bc,G,Uo,$c,Ee,Jc,Cn,Fc,jc,qs,Cc,zc,Ec,ct,Uc,pt,Wc,ht,Yr,Ue,mt,As,Wo,Nc,Ss,Zc,Dr,x,No,xc,Xs,Ic,Vc,Zo,Rc,zn,Gc,Pc,qc,xo,Ac,Io,Sc,Xc,Lc,Y,Vo,Qc,We,Hc,En,Oc,Yc,Ls,Dc,Kc,ep,ut,tp,gt,Kr,Ne,ft,Qs,Ro,op,Hs,np,ea,I,Go,sp,Os,rp,ap,Po,ip,Un,lp,dp,cp,qo,pp,Ao,hp,mp,up,D,So,gp,Ze,fp,Wn,_p,Mp,Ys,bp,yp,Tp,_t,vp,Mt,ta,xe,bt,Ds,Xo,wp,Ks,kp,oa,V,Lo,Bp,Ie,$p,er,Jp,Fp,tr,jp,Cp,zp,Qo,Ep,Nn,Up,Wp,Np,Ho,Zp,Oo,xp,Ip,Vp,K,Yo,Rp,Ve,Gp,Zn,Pp,qp,or,Ap,Sp,Xp,yt,Lp,Tt,na;return n=new S({}),zt=new S({}),Zt=new R({props:{code:"d2dldCUyMC0tY29udGVudC1kaXNwb3NpdGlvbiUyMGh0dHBzJTNBJTJGJTJGYXBpLm5nYy5udmlkaWEuY29tJTJGdjIlMkZtb2RlbHMlMkZudmlkaWElMkZtZWdhdHJvbl9iZXJ0XzM0NW0lMkZ2ZXJzaW9ucyUyRnYwLjFfdW5jYXNlZCUyRnppcCUwQS1PJTIwbWVnYXRyb25fYmVydF8zNDVtX3YwXzFfdW5jYXNlZC56aXA=",highlighted:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_bert_345m/versions/v0.1_uncased/zip
-O megatron_bert_345m_v0_1_uncased.zip`}}),xt=new R({props:{code:"d2dldCUyMC0tY29udGVudC1kaXNwb3NpdGlvbiUyMGh0dHBzJTNBJTJGJTJGYXBpLm5nYy5udmlkaWEuY29tJTJGdjIlMkZtb2RlbHMlMkZudmlkaWElMkZtZWdhdHJvbl9iZXJ0XzM0NW0lMkZ2ZXJzaW9ucyUyRnYwLjFfY2FzZWQlMkZ6aXAlMjAtTyUwQW1lZ2F0cm9uX2JlcnRfMzQ1bV92MF8xX2Nhc2VkLnppcA==",highlighted:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_bert_345m/versions/v0.1_cased/zip -O
megatron_bert_345m_v0_1_cased.zip`}}),It=new R({props:{code:"cHl0aG9uMyUyMCUyNFBBVEhfVE9fVFJBTlNGT1JNRVJTJTJGbW9kZWxzJTJGbWVnYXRyb25fYmVydCUyRmNvbnZlcnRfbWVnYXRyb25fYmVydF9jaGVja3BvaW50LnB5JTIwbWVnYXRyb25fYmVydF8zNDVtX3YwXzFfdW5jYXNlZC56aXA=",highlighted:'python3 <span class="hljs-variable">$PATH_TO_TRANSFORMERS</span>/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron_bert_345m_v0_1_uncased.zip'}}),Vt=new R({props:{code:"cHl0aG9uMyUyMCUyNFBBVEhfVE9fVFJBTlNGT1JNRVJTJTJGbW9kZWxzJTJGbWVnYXRyb25fYmVydCUyRmNvbnZlcnRfbWVnYXRyb25fYmVydF9jaGVja3BvaW50LnB5JTIwbWVnYXRyb25fYmVydF8zNDVtX3YwXzFfY2FzZWQuemlw",highlighted:'python3 <span class="hljs-variable">$PATH_TO_TRANSFORMERS</span>/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron_bert_345m_v0_1_cased.zip'}}),Pt=new S({}),qt=new S({}),At=new j({props:{name:"class transformers.MegatronBertConfig",anchor:"transformers.MegatronBertConfig",parameters:[{name:"vocab_size",val:" = 29056"},{name:"hidden_size",val:" = 1024"},{name:"num_hidden_layers",val:" = 24"},{name:"num_attention_heads",val:" = 16"},{name:"intermediate_size",val:" = 4096"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 512"},{name:"type_vocab_size",val:" = 2"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"pad_token_id",val:" = 0"},{name:"position_embedding_type",val:" = 'absolute'"},{name:"use_cache",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 29056) &#x2014;
Vocabulary size of the MEGATRON_BERT 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/megatron-bert#transformers.MegatronBertModel">MegatronBertModel</a>.`,name:"vocab_size"},{anchor:"transformers.MegatronBertConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.MegatronBertConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 24) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.MegatronBertConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.MegatronBertConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.MegatronBertConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>Callable</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.MegatronBertConfig.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.MegatronBertConfig.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.MegatronBertConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.MegatronBertConfig.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/megatron-bert#transformers.MegatronBertModel">MegatronBertModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.MegatronBertConfig.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.MegatronBertConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.MegatronBertConfig.position_embedding_type",description:`<strong>position_embedding_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;absolute&quot;</code>) &#x2014;
Type of position embedding. Choose one of <code>&quot;absolute&quot;</code>, <code>&quot;relative_key&quot;</code>, <code>&quot;relative_key_query&quot;</code>. For
positional embeddings use <code>&quot;absolute&quot;</code>. For more information on <code>&quot;relative_key&quot;</code>, please refer to
<a href="https://arxiv.org/abs/1803.02155" rel="nofollow">Self-Attention with Relative Position Representations (Shaw et al.)</a>.
For more information on <code>&quot;relative_key_query&quot;</code>, please refer to <em>Method 4</em> in <a href="https://arxiv.org/abs/2009.13658" rel="nofollow">Improve Transformer Models
with Better Relative Position Embeddings (Huang et al.)</a>.`,name:"position_embedding_type"},{anchor:"transformers.MegatronBertConfig.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.MegatronBertConfig.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"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/megatron_bert/configuration_megatron_bert.py#L28"}}),Le=new te({props:{anchor:"transformers.MegatronBertConfig.example",$$slots:{default:[tu]},$$scope:{ctx:$}}}),Xt=new S({}),Lt=new j({props:{name:"class transformers.MegatronBertModel",anchor:"transformers.MegatronBertModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.MegatronBertModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L841"}}),Kt=new j({props:{name:"forward",anchor:"transformers.MegatronBertModel.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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/megatron_bert/modeling_megatron_bert.py#L880",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),He=new Ge({props:{$$slots:{default:[ou]},$$scope:{ctx:$}}}),Oe=new te({props:{anchor:"transformers.MegatronBertModel.forward.example",$$slots:{default:[nu]},$$scope:{ctx:$}}}),eo=new S({}),to=new j({props:{name:"class transformers.MegatronBertForMaskedLM",anchor:"transformers.MegatronBertForMaskedLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1268"}}),ao=new j({props:{name:"forward",anchor:"transformers.MegatronBertForMaskedLM.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForMaskedLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForMaskedLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1292",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),De=new Ge({props:{$$slots:{default:[su]},$$scope:{ctx:$}}}),Ke=new te({props:{anchor:"transformers.MegatronBertForMaskedLM.forward.example",$$slots:{default:[ru]},$$scope:{ctx:$}}}),io=new S({}),lo=new j({props:{name:"class transformers.MegatronBertForCausalLM",anchor:"transformers.MegatronBertForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1124"}}),uo=new j({props:{name:"forward",anchor:"transformers.MegatronBertForCausalLM.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForCausalLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForCausalLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
<code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are
ignored (masked), the loss is only computed for the tokens with labels n <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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/megatron_bert/modeling_megatron_bert.py#L1145",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),tt=new Ge({props:{$$slots:{default:[au]},$$scope:{ctx:$}}}),ot=new te({props:{anchor:"transformers.MegatronBertForCausalLM.forward.example",$$slots:{default:[iu]},$$scope:{ctx:$}}}),go=new S({}),fo=new j({props:{name:"class transformers.MegatronBertForNextSentencePrediction",anchor:"transformers.MegatronBertForNextSentencePrediction",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForNextSentencePrediction.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1375"}}),To=new j({props:{name:"forward",anchor:"transformers.MegatronBertForNextSentencePrediction.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForNextSentencePrediction.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForNextSentencePrediction.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair
(see <code>input_ids</code> docstring). Indices should be in <code>[0, 1]</code>:</p>
<ul>
<li>0 indicates sequence B is a continuation of sequence A,</li>
<li>1 indicates sequence B is a random sequence.</li>
</ul>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1385",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.0/en/main_classes/output#transformers.modeling_outputs.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>next_sentence_label</code> is provided) \u2014 Next sequence prediction (classification) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, 2)</code>) \u2014 Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, 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.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),st=new Ge({props:{$$slots:{default:[lu]},$$scope:{ctx:$}}}),rt=new te({props:{anchor:"transformers.MegatronBertForNextSentencePrediction.forward.example",$$slots:{default:[du]},$$scope:{ctx:$}}}),vo=new S({}),wo=new j({props:{name:"class transformers.MegatronBertForPreTraining",anchor:"transformers.MegatronBertForPreTraining",parameters:[{name:"config",val:""},{name:"add_binary_head",val:" = True"}],parametersDescription:[{anchor:"transformers.MegatronBertForPreTraining.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1018"}}),Jo=new j({props:{name:"forward",anchor:"transformers.MegatronBertForPreTraining.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"next_sentence_label",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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForPreTraining.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForPreTraining.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.forward.next_sentence_label",description:`<strong>next_sentence_label</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair
(see <code>input_ids</code> docstring) Indices should be in <code>[0, 1]</code>:</p>
<ul>
<li>0 indicates sequence B is a continuation of sequence A,</li>
<li>1 indicates sequence B is a random sequence.</li>
</ul>`,name:"next_sentence_label"},{anchor:"transformers.MegatronBertForPreTraining.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/megatron_bert/modeling_megatron_bert.py#L1036",returnDescription:`
<p>A <code>transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForPreTrainingOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<em>optional</em>, returned when <code>labels</code> is provided, <code>torch.FloatTensor</code> of shape <code>(1,)</code>) \u2014 Total loss as the sum of the masked language modeling loss and the next sequence prediction
(classification) loss.</p>
</li>
<li>
<p><strong>prediction_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>seq_relationship_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, 2)</code>) \u2014 Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForPreTrainingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),it=new Ge({props:{$$slots:{default:[cu]},$$scope:{ctx:$}}}),lt=new te({props:{anchor:"transformers.MegatronBertForPreTraining.forward.example",$$slots:{default:[pu]},$$scope:{ctx:$}}}),Fo=new S({}),jo=new j({props:{name:"class transformers.MegatronBertForSequenceClassification",anchor:"transformers.MegatronBertForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1479"}}),Uo=new j({props:{name:"forward",anchor:"transformers.MegatronBertForSequenceClassification.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForSequenceClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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/megatron_bert/modeling_megatron_bert.py#L1491",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),ct=new Ge({props:{$$slots:{default:[hu]},$$scope:{ctx:$}}}),pt=new te({props:{anchor:"transformers.MegatronBertForSequenceClassification.forward.example",$$slots:{default:[mu]},$$scope:{ctx:$}}}),ht=new te({props:{anchor:"transformers.MegatronBertForSequenceClassification.forward.example-2",$$slots:{default:[uu]},$$scope:{ctx:$}}}),Wo=new S({}),No=new j({props:{name:"class transformers.MegatronBertForMultipleChoice",anchor:"transformers.MegatronBertForMultipleChoice",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1576"}}),Vo=new j({props:{name:"forward",anchor:"transformers.MegatronBertForMultipleChoice.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForMultipleChoice.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForMultipleChoice.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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/megatron_bert/modeling_megatron_bert.py#L1587",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),ut=new Ge({props:{$$slots:{default:[gu]},$$scope:{ctx:$}}}),gt=new te({props:{anchor:"transformers.MegatronBertForMultipleChoice.forward.example",$$slots:{default:[fu]},$$scope:{ctx:$}}}),Ro=new S({}),Go=new j({props:{name:"class transformers.MegatronBertForTokenClassification",anchor:"transformers.MegatronBertForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1669"}}),So=new j({props:{name:"forward",anchor:"transformers.MegatronBertForTokenClassification.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForTokenClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForTokenClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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/megatron_bert/modeling_megatron_bert.py#L1681",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),_t=new Ge({props:{$$slots:{default:[_u]},$$scope:{ctx:$}}}),Mt=new te({props:{anchor:"transformers.MegatronBertForTokenClassification.forward.example",$$slots:{default:[Mu]},$$scope:{ctx:$}}}),Xo=new S({}),Lo=new j({props:{name:"class transformers.MegatronBertForQuestionAnswering",anchor:"transformers.MegatronBertForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</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/megatron_bert/modeling_megatron_bert.py#L1747"}}),Yo=new j({props:{name:"forward",anchor:"transformers.MegatronBertForQuestionAnswering.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:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.MegatronBertForQuestionAnswering.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.MegatronBertForQuestionAnswering.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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/megatron_bert/modeling_megatron_bert.py#L1758",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/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>
`}}),yt=new Ge({props:{$$slots:{default:[bu]},$$scope:{ctx:$}}}),Tt=new te({props:{anchor:"transformers.MegatronBertForQuestionAnswering.forward.example",$$slots:{default:[yu]},$$scope:{ctx:$}}}),{c(){d=a("meta"),b=p(),f=a("h1"),u=a("a"),M=a("span"),y(n.$$.fragment),c=p(),J=a("span"),xa=s("MegatronBERT"),Mr=p(),ge=a("h2"),Pe=a("a"),Dn=a("span"),y(zt.$$.fragment),Ia=p(),Kn=a("span"),Va=s("Overview"),br=p(),qe=a("p"),Ra=s("The MegatronBERT model was proposed in "),Et=a("a"),Ga=s(`Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism`),Pa=s(` by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`),yr=p(),on=a("p"),qa=s("The abstract from the paper is the following:"),Tr=p(),nn=a("p"),es=a("em"),Aa=s(`Recent work in language modeling demonstrates that training large transformer models advances the state of the art in
Natural Language Processing applications. However, very large models can be quite difficult to train due to memory
constraints. In this work, we present our techniques for training very large transformer models and implement a simple,
efficient intra-layer model parallel approach that enables training transformer models with billions of parameters. Our
approach does not require a new compiler or library changes, is orthogonal and complimentary to pipeline model
parallelism, and can be fully implemented with the insertion of a few communication operations in native PyTorch. We
illustrate this approach by converging transformer based models up to 8.3 billion parameters using 512 GPUs. We sustain
15.1 PetaFLOPs across the entire application with 76% scaling efficiency when compared to a strong single GPU baseline
that sustains 39 TeraFLOPs, which is 30% of peak FLOPs. To demonstrate that large language models can further advance
the state of the art (SOTA), we train an 8.3 billion parameter transformer language model similar to GPT-2 and a 3.9
billion parameter model similar to BERT. We show that careful attention to the placement of layer normalization in
BERT-like models is critical to achieving increased performance as the model size grows. Using the GPT-2 model we
achieve SOTA results on the WikiText103 (10.8 compared to SOTA perplexity of 15.8) and LAMBADA (66.5% compared to SOTA
accuracy of 63.2%) datasets. Our BERT model achieves SOTA results on the RACE dataset (90.9% compared to SOTA accuracy
of 89.4%).`),vr=p(),sn=a("p"),Sa=s("Tips:"),wr=p(),Ae=a("p"),Xa=s("We have provided pretrained "),Ut=a("a"),La=s("BERT-345M"),Qa=s(` checkpoints
for use to evaluate or finetuning downstream tasks.`),kr=p(),ne=a("p"),Ha=s("To access these checkpoints, first "),Wt=a("a"),Oa=s("sign up"),Ya=s(` for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the `),Nt=a("a"),Da=s("NGC documentation"),Ka=s("."),Br=p(),rn=a("p"),ei=s("Alternatively, you can directly download the checkpoints using:"),$r=p(),an=a("p"),ti=s("BERT-345M-uncased:"),Jr=p(),y(Zt.$$.fragment),Fr=p(),ln=a("p"),oi=s("BERT-345M-cased:"),jr=p(),y(xt.$$.fragment),Cr=p(),dn=a("p"),ni=s(`Once you have obtained the checkpoints from NVIDIA GPU Cloud (NGC), you have to convert them to a format that will
easily be loaded by Hugging Face Transformers and our port of the BERT code.`),zr=p(),se=a("p"),si=s("The following commands allow you to do the conversion. We assume that the folder "),ts=a("code"),ri=s("models/megatron_bert"),ai=s(` contains
`),os=a("code"),ii=s("megatron_bert_345m_v0_1_{cased, uncased}.zip"),li=s(" and that the commands are run from inside that folder:"),Er=p(),y(It.$$.fragment),Ur=p(),y(Vt.$$.fragment),Wr=p(),re=a("p"),di=s("This model was contributed by "),Rt=a("a"),ci=s("jdemouth"),pi=s(". The original code can be found "),Gt=a("a"),hi=s("here"),mi=s(`. That repository contains a multi-GPU and multi-node implementation of the
Megatron Language models. In particular, it contains a hybrid model parallel approach using \u201Ctensor parallel\u201D and
\u201Cpipeline parallel\u201D techniques.`),Nr=p(),fe=a("h2"),Se=a("a"),ns=a("span"),y(Pt.$$.fragment),ui=p(),ss=a("span"),gi=s("Documentation resources"),Zr=p(),z=a("ul"),rs=a("li"),cn=a("a"),fi=s("Text classification task guide"),_i=p(),as=a("li"),pn=a("a"),Mi=s("Token classification task guide"),bi=p(),is=a("li"),hn=a("a"),yi=s("Question answering task guide"),Ti=p(),ls=a("li"),mn=a("a"),vi=s("Causal language modeling task guide"),wi=p(),ds=a("li"),un=a("a"),ki=s("Masked language modeling task guide"),Bi=p(),cs=a("li"),gn=a("a"),$i=s("Multiple choice task guide"),xr=p(),_e=a("h2"),Xe=a("a"),ps=a("span"),y(qt.$$.fragment),Ji=p(),hs=a("span"),Fi=s("MegatronBertConfig"),Ir=p(),A=a("div"),y(At.$$.fragment),ji=p(),Me=a("p"),Ci=s("This is the configuration class to store the configuration of a "),fn=a("a"),zi=s("MegatronBertModel"),Ei=s(`. It is used to instantiate a
MEGATRON_BERT 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 MEGATRON_BERT
`),St=a("a"),Ui=s("nvidia/megatron-bert-uncased-345m"),Wi=s(" architecture."),Ni=p(),be=a("p"),Zi=s("Configuration objects inherit from "),_n=a("a"),xi=s("PretrainedConfig"),Ii=s(` and can be used to control the model outputs. Read the
documentation from `),Mn=a("a"),Vi=s("PretrainedConfig"),Ri=s(" for more information."),Gi=p(),y(Le.$$.fragment),Vr=p(),ye=a("h2"),Qe=a("a"),ms=a("span"),y(Xt.$$.fragment),Pi=p(),us=a("span"),qi=s("MegatronBertModel"),Rr=p(),F=a("div"),y(Lt.$$.fragment),Ai=p(),gs=a("p"),Si=s("The bare MegatronBert Model transformer outputting raw hidden-states without any specific head on top."),Xi=p(),Qt=a("p"),Li=s("This model inherits from "),bn=a("a"),Qi=s("PreTrainedModel"),Hi=s(`. 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.)`),Oi=p(),Ht=a("p"),Yi=s("This model is also a PyTorch "),Ot=a("a"),Di=s("torch.nn.Module"),Ki=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),el=p(),Yt=a("p"),tl=s(`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in `),Dt=a("a"),ol=s(`Attention is
all you need`),nl=s(` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),sl=p(),C=a("p"),rl=s("To behave as an decoder the model needs to be initialized with the "),fs=a("code"),al=s("is_decoder"),il=s(` argument of the configuration set
to `),_s=a("code"),ll=s("True"),dl=s(". To be used in a Seq2Seq model, the model needs to initialized with both "),Ms=a("code"),cl=s("is_decoder"),pl=s(` argument and
`),bs=a("code"),hl=s("add_cross_attention"),ml=s(" set to "),ys=a("code"),ul=s("True"),gl=s("; an "),Ts=a("code"),fl=s("encoder_hidden_states"),_l=s(" is then expected as an input to the forward pass."),Ml=p(),X=a("div"),y(Kt.$$.fragment),bl=p(),Te=a("p"),yl=s("The "),yn=a("a"),Tl=s("MegatronBertModel"),vl=s(" forward method, overrides the "),vs=a("code"),wl=s("__call__"),kl=s(" special method."),Bl=p(),y(He.$$.fragment),$l=p(),y(Oe.$$.fragment),Gr=p(),ve=a("h2"),Ye=a("a"),ws=a("span"),y(eo.$$.fragment),Jl=p(),ks=a("span"),Fl=s("MegatronBertForMaskedLM"),Pr=p(),E=a("div"),y(to.$$.fragment),jl=p(),oo=a("p"),Cl=s("MegatronBert Model with a "),Bs=a("code"),zl=s("language modeling"),El=s(" head on top."),Ul=p(),no=a("p"),Wl=s("This model inherits from "),Tn=a("a"),Nl=s("PreTrainedModel"),Zl=s(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),xl=p(),so=a("p"),Il=s("This model is also a PyTorch "),ro=a("a"),Vl=s("torch.nn.Module"),Rl=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Gl=p(),L=a("div"),y(ao.$$.fragment),Pl=p(),we=a("p"),ql=s("The "),vn=a("a"),Al=s("MegatronBertForMaskedLM"),Sl=s(" forward method, overrides the "),$s=a("code"),Xl=s("__call__"),Ll=s(" special method."),Ql=p(),y(De.$$.fragment),Hl=p(),y(Ke.$$.fragment),qr=p(),ke=a("h2"),et=a("a"),Js=a("span"),y(io.$$.fragment),Ol=p(),Fs=a("span"),Yl=s("MegatronBertForCausalLM"),Ar=p(),U=a("div"),y(lo.$$.fragment),Dl=p(),co=a("p"),Kl=s("MegatronBert Model with a "),js=a("code"),ed=s("language modeling"),td=s(" head on top for CLM fine-tuning."),od=p(),po=a("p"),nd=s("This model inherits from "),wn=a("a"),sd=s("PreTrainedModel"),rd=s(`. 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.)`),ad=p(),ho=a("p"),id=s("This model is also a PyTorch "),mo=a("a"),ld=s("torch.nn.Module"),dd=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),cd=p(),Q=a("div"),y(uo.$$.fragment),pd=p(),Be=a("p"),hd=s("The "),kn=a("a"),md=s("MegatronBertForCausalLM"),ud=s(" forward method, overrides the "),Cs=a("code"),gd=s("__call__"),fd=s(" special method."),_d=p(),y(tt.$$.fragment),Md=p(),y(ot.$$.fragment),Sr=p(),$e=a("h2"),nt=a("a"),zs=a("span"),y(go.$$.fragment),bd=p(),Es=a("span"),yd=s("MegatronBertForNextSentencePrediction"),Xr=p(),W=a("div"),y(fo.$$.fragment),Td=p(),_o=a("p"),vd=s("MegatronBert Model with a "),Us=a("code"),wd=s("next sentence prediction (classification)"),kd=s(" head on top."),Bd=p(),Mo=a("p"),$d=s("This model inherits from "),Bn=a("a"),Jd=s("PreTrainedModel"),Fd=s(`. 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.)`),jd=p(),bo=a("p"),Cd=s("This model is also a PyTorch "),yo=a("a"),zd=s("torch.nn.Module"),Ed=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ud=p(),H=a("div"),y(To.$$.fragment),Wd=p(),Je=a("p"),Nd=s("The "),$n=a("a"),Zd=s("MegatronBertForNextSentencePrediction"),xd=s(" forward method, overrides the "),Ws=a("code"),Id=s("__call__"),Vd=s(" special method."),Rd=p(),y(st.$$.fragment),Gd=p(),y(rt.$$.fragment),Lr=p(),Fe=a("h2"),at=a("a"),Ns=a("span"),y(vo.$$.fragment),Pd=p(),Zs=a("span"),qd=s("MegatronBertForPreTraining"),Qr=p(),N=a("div"),y(wo.$$.fragment),Ad=p(),je=a("p"),Sd=s("MegatronBert Model with two heads on top as done during the pretraining: a "),xs=a("code"),Xd=s("masked language modeling"),Ld=s(` head and a
`),Is=a("code"),Qd=s("next sentence prediction (classification)"),Hd=s(" head."),Od=p(),ko=a("p"),Yd=s("This model inherits from "),Jn=a("a"),Dd=s("PreTrainedModel"),Kd=s(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ec=p(),Bo=a("p"),tc=s("This model is also a PyTorch "),$o=a("a"),oc=s("torch.nn.Module"),nc=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),sc=p(),O=a("div"),y(Jo.$$.fragment),rc=p(),Ce=a("p"),ac=s("The "),Fn=a("a"),ic=s("MegatronBertForPreTraining"),lc=s(" forward method, overrides the "),Vs=a("code"),dc=s("__call__"),cc=s(" special method."),pc=p(),y(it.$$.fragment),hc=p(),y(lt.$$.fragment),Hr=p(),ze=a("h2"),dt=a("a"),Rs=a("span"),y(Fo.$$.fragment),mc=p(),Gs=a("span"),uc=s("MegatronBertForSequenceClassification"),Or=p(),Z=a("div"),y(jo.$$.fragment),gc=p(),Ps=a("p"),fc=s(`MegatronBert Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),_c=p(),Co=a("p"),Mc=s("This model inherits from "),jn=a("a"),bc=s("PreTrainedModel"),yc=s(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Tc=p(),zo=a("p"),vc=s("This model is also a PyTorch "),Eo=a("a"),wc=s("torch.nn.Module"),kc=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Bc=p(),G=a("div"),y(Uo.$$.fragment),$c=p(),Ee=a("p"),Jc=s("The "),Cn=a("a"),Fc=s("MegatronBertForSequenceClassification"),jc=s(" forward method, overrides the "),qs=a("code"),Cc=s("__call__"),zc=s(" special method."),Ec=p(),y(ct.$$.fragment),Uc=p(),y(pt.$$.fragment),Wc=p(),y(ht.$$.fragment),Yr=p(),Ue=a("h2"),mt=a("a"),As=a("span"),y(Wo.$$.fragment),Nc=p(),Ss=a("span"),Zc=s("MegatronBertForMultipleChoice"),Dr=p(),x=a("div"),y(No.$$.fragment),xc=p(),Xs=a("p"),Ic=s(`MegatronBert 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.`),Vc=p(),Zo=a("p"),Rc=s("This model inherits from "),zn=a("a"),Gc=s("PreTrainedModel"),Pc=s(`. 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.)`),qc=p(),xo=a("p"),Ac=s("This model is also a PyTorch "),Io=a("a"),Sc=s("torch.nn.Module"),Xc=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Lc=p(),Y=a("div"),y(Vo.$$.fragment),Qc=p(),We=a("p"),Hc=s("The "),En=a("a"),Oc=s("MegatronBertForMultipleChoice"),Yc=s(" forward method, overrides the "),Ls=a("code"),Dc=s("__call__"),Kc=s(" special method."),ep=p(),y(ut.$$.fragment),tp=p(),y(gt.$$.fragment),Kr=p(),Ne=a("h2"),ft=a("a"),Qs=a("span"),y(Ro.$$.fragment),op=p(),Hs=a("span"),np=s("MegatronBertForTokenClassification"),ea=p(),I=a("div"),y(Go.$$.fragment),sp=p(),Os=a("p"),rp=s(`MegatronBert 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.`),ap=p(),Po=a("p"),ip=s("This model inherits from "),Un=a("a"),lp=s("PreTrainedModel"),dp=s(`. 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.)`),cp=p(),qo=a("p"),pp=s("This model is also a PyTorch "),Ao=a("a"),hp=s("torch.nn.Module"),mp=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),up=p(),D=a("div"),y(So.$$.fragment),gp=p(),Ze=a("p"),fp=s("The "),Wn=a("a"),_p=s("MegatronBertForTokenClassification"),Mp=s(" forward method, overrides the "),Ys=a("code"),bp=s("__call__"),yp=s(" special method."),Tp=p(),y(_t.$$.fragment),vp=p(),y(Mt.$$.fragment),ta=p(),xe=a("h2"),bt=a("a"),Ds=a("span"),y(Xo.$$.fragment),wp=p(),Ks=a("span"),kp=s("MegatronBertForQuestionAnswering"),oa=p(),V=a("div"),y(Lo.$$.fragment),Bp=p(),Ie=a("p"),$p=s(`MegatronBert 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 `),er=a("code"),Jp=s("span start logits"),Fp=s(" and "),tr=a("code"),jp=s("span end logits"),Cp=s(")."),zp=p(),Qo=a("p"),Ep=s("This model inherits from "),Nn=a("a"),Up=s("PreTrainedModel"),Wp=s(`. 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.)`),Np=p(),Ho=a("p"),Zp=s("This model is also a PyTorch "),Oo=a("a"),xp=s("torch.nn.Module"),Ip=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Vp=p(),K=a("div"),y(Yo.$$.fragment),Rp=p(),Ve=a("p"),Gp=s("The "),Zn=a("a"),Pp=s("MegatronBertForQuestionAnswering"),qp=s(" forward method, overrides the "),or=a("code"),Ap=s("__call__"),Sp=s(" special method."),Xp=p(),y(yt.$$.fragment),Lp=p(),y(Tt.$$.fragment),this.h()},l(t){const g=Km('[data-svelte="svelte-1phssyn"]',document.head);d=i(g,"META",{name:!0,content:!0}),g.forEach(o),b=h(t),f=i(t,"H1",{class:!0});var Do=l(f);u=i(Do,"A",{id:!0,class:!0,href:!0});var nr=l(u);M=i(nr,"SPAN",{});var sr=l(M);T(n.$$.fragment,sr),sr.forEach(o),nr.forEach(o),c=h(Do),J=i(Do,"SPAN",{});var rr=l(J);xa=r(rr,"MegatronBERT"),rr.forEach(o),Do.forEach(o),Mr=h(t),ge=i(t,"H2",{class:!0});var Ko=l(ge);Pe=i(Ko,"A",{id:!0,class:!0,href:!0});var ar=l(Pe);Dn=i(ar,"SPAN",{});var ir=l(Dn);T(zt.$$.fragment,ir),ir.forEach(o),ar.forEach(o),Ia=h(Ko),Kn=i(Ko,"SPAN",{});var lr=l(Kn);Va=r(lr,"Overview"),lr.forEach(o),Ko.forEach(o),br=h(t),qe=i(t,"P",{});var en=l(qe);Ra=r(en,"The MegatronBERT model was proposed in "),Et=i(en,"A",{href:!0,rel:!0});var dr=l(Et);Ga=r(dr,`Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism`),dr.forEach(o),Pa=r(en,` by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`),en.forEach(o),yr=h(t),on=i(t,"P",{});var cr=l(on);qa=r(cr,"The abstract from the paper is the following:"),cr.forEach(o),Tr=h(t),nn=i(t,"P",{});var pr=l(nn);es=i(pr,"EM",{});var hr=l(es);Aa=r(hr,`Recent work in language modeling demonstrates that training large transformer models advances the state of the art in
Natural Language Processing applications. However, very large models can be quite difficult to train due to memory
constraints. In this work, we present our techniques for training very large transformer models and implement a simple,
efficient intra-layer model parallel approach that enables training transformer models with billions of parameters. Our
approach does not require a new compiler or library changes, is orthogonal and complimentary to pipeline model
parallelism, and can be fully implemented with the insertion of a few communication operations in native PyTorch. We
illustrate this approach by converging transformer based models up to 8.3 billion parameters using 512 GPUs. We sustain
15.1 PetaFLOPs across the entire application with 76% scaling efficiency when compared to a strong single GPU baseline
that sustains 39 TeraFLOPs, which is 30% of peak FLOPs. To demonstrate that large language models can further advance
the state of the art (SOTA), we train an 8.3 billion parameter transformer language model similar to GPT-2 and a 3.9
billion parameter model similar to BERT. We show that careful attention to the placement of layer normalization in
BERT-like models is critical to achieving increased performance as the model size grows. Using the GPT-2 model we
achieve SOTA results on the WikiText103 (10.8 compared to SOTA perplexity of 15.8) and LAMBADA (66.5% compared to SOTA
accuracy of 63.2%) datasets. Our BERT model achieves SOTA results on the RACE dataset (90.9% compared to SOTA accuracy
of 89.4%).`),hr.forEach(o),pr.forEach(o),vr=h(t),sn=i(t,"P",{});var mr=l(sn);Sa=r(mr,"Tips:"),mr.forEach(o),wr=h(t),Ae=i(t,"P",{});var tn=l(Ae);Xa=r(tn,"We have provided pretrained "),Ut=i(tn,"A",{href:!0,rel:!0});var ur=l(Ut);La=r(ur,"BERT-345M"),ur.forEach(o),Qa=r(tn,` checkpoints
for use to evaluate or finetuning downstream tasks.`),tn.forEach(o),kr=h(t),ne=i(t,"P",{});var Re=l(ne);Ha=r(Re,"To access these checkpoints, first "),Wt=i(Re,"A",{href:!0,rel:!0});var gr=l(Wt);Oa=r(gr,"sign up"),gr.forEach(o),Ya=r(Re,` for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the `),Nt=i(Re,"A",{href:!0,rel:!0});var fr=l(Nt);Da=r(fr,"NGC documentation"),fr.forEach(o),Ka=r(Re,"."),Re.forEach(o),Br=h(t),rn=i(t,"P",{});var _r=l(rn);ei=r(_r,"Alternatively, you can directly download the checkpoints using:"),_r.forEach(o),$r=h(t),an=i(t,"P",{});var Qp=l(an);ti=r(Qp,"BERT-345M-uncased:"),Qp.forEach(o),Jr=h(t),T(Zt.$$.fragment,t),Fr=h(t),ln=i(t,"P",{});var Hp=l(ln);oi=r(Hp,"BERT-345M-cased:"),Hp.forEach(o),jr=h(t),T(xt.$$.fragment,t),Cr=h(t),dn=i(t,"P",{});var Op=l(dn);ni=r(Op,`Once you have obtained the checkpoints from NVIDIA GPU Cloud (NGC), you have to convert them to a format that will
easily be loaded by Hugging Face Transformers and our port of the BERT code.`),Op.forEach(o),zr=h(t),se=i(t,"P",{});var xn=l(se);si=r(xn,"The following commands allow you to do the conversion. We assume that the folder "),ts=i(xn,"CODE",{});var Yp=l(ts);ri=r(Yp,"models/megatron_bert"),Yp.forEach(o),ai=r(xn,` contains
`),os=i(xn,"CODE",{});var Dp=l(os);ii=r(Dp,"megatron_bert_345m_v0_1_{cased, uncased}.zip"),Dp.forEach(o),li=r(xn," and that the commands are run from inside that folder:"),xn.forEach(o),Er=h(t),T(It.$$.fragment,t),Ur=h(t),T(Vt.$$.fragment,t),Wr=h(t),re=i(t,"P",{});var In=l(re);di=r(In,"This model was contributed by "),Rt=i(In,"A",{href:!0,rel:!0});var Kp=l(Rt);ci=r(Kp,"jdemouth"),Kp.forEach(o),pi=r(In,". The original code can be found "),Gt=i(In,"A",{href:!0,rel:!0});var eh=l(Gt);hi=r(eh,"here"),eh.forEach(o),mi=r(In,`. That repository contains a multi-GPU and multi-node implementation of the
Megatron Language models. In particular, it contains a hybrid model parallel approach using \u201Ctensor parallel\u201D and
\u201Cpipeline parallel\u201D techniques.`),In.forEach(o),Nr=h(t),fe=i(t,"H2",{class:!0});var sa=l(fe);Se=i(sa,"A",{id:!0,class:!0,href:!0});var th=l(Se);ns=i(th,"SPAN",{});var oh=l(ns);T(Pt.$$.fragment,oh),oh.forEach(o),th.forEach(o),ui=h(sa),ss=i(sa,"SPAN",{});var nh=l(ss);gi=r(nh,"Documentation resources"),nh.forEach(o),sa.forEach(o),Zr=h(t),z=i(t,"UL",{});var ee=l(z);rs=i(ee,"LI",{});var sh=l(rs);cn=i(sh,"A",{href:!0});var rh=l(cn);fi=r(rh,"Text classification task guide"),rh.forEach(o),sh.forEach(o),_i=h(ee),as=i(ee,"LI",{});var ah=l(as);pn=i(ah,"A",{href:!0});var ih=l(pn);Mi=r(ih,"Token classification task guide"),ih.forEach(o),ah.forEach(o),bi=h(ee),is=i(ee,"LI",{});var lh=l(is);hn=i(lh,"A",{href:!0});var dh=l(hn);yi=r(dh,"Question answering task guide"),dh.forEach(o),lh.forEach(o),Ti=h(ee),ls=i(ee,"LI",{});var ch=l(ls);mn=i(ch,"A",{href:!0});var ph=l(mn);vi=r(ph,"Causal language modeling task guide"),ph.forEach(o),ch.forEach(o),wi=h(ee),ds=i(ee,"LI",{});var hh=l(ds);un=i(hh,"A",{href:!0});var mh=l(un);ki=r(mh,"Masked language modeling task guide"),mh.forEach(o),hh.forEach(o),Bi=h(ee),cs=i(ee,"LI",{});var uh=l(cs);gn=i(uh,"A",{href:!0});var gh=l(gn);$i=r(gh,"Multiple choice task guide"),gh.forEach(o),uh.forEach(o),ee.forEach(o),xr=h(t),_e=i(t,"H2",{class:!0});var ra=l(_e);Xe=i(ra,"A",{id:!0,class:!0,href:!0});var fh=l(Xe);ps=i(fh,"SPAN",{});var _h=l(ps);T(qt.$$.fragment,_h),_h.forEach(o),fh.forEach(o),Ji=h(ra),hs=i(ra,"SPAN",{});var Mh=l(hs);Fi=r(Mh,"MegatronBertConfig"),Mh.forEach(o),ra.forEach(o),Ir=h(t),A=i(t,"DIV",{class:!0});var vt=l(A);T(At.$$.fragment,vt),ji=h(vt),Me=i(vt,"P",{});var Vn=l(Me);Ci=r(Vn,"This is the configuration class to store the configuration of a "),fn=i(Vn,"A",{href:!0});var bh=l(fn);zi=r(bh,"MegatronBertModel"),bh.forEach(o),Ei=r(Vn,`. It is used to instantiate a
MEGATRON_BERT 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 MEGATRON_BERT
`),St=i(Vn,"A",{href:!0,rel:!0});var yh=l(St);Ui=r(yh,"nvidia/megatron-bert-uncased-345m"),yh.forEach(o),Wi=r(Vn," architecture."),Vn.forEach(o),Ni=h(vt),be=i(vt,"P",{});var Rn=l(be);Zi=r(Rn,"Configuration objects inherit from "),_n=i(Rn,"A",{href:!0});var Th=l(_n);xi=r(Th,"PretrainedConfig"),Th.forEach(o),Ii=r(Rn,` and can be used to control the model outputs. Read the
documentation from `),Mn=i(Rn,"A",{href:!0});var vh=l(Mn);Vi=r(vh,"PretrainedConfig"),vh.forEach(o),Ri=r(Rn," for more information."),Rn.forEach(o),Gi=h(vt),T(Le.$$.fragment,vt),vt.forEach(o),Vr=h(t),ye=i(t,"H2",{class:!0});var aa=l(ye);Qe=i(aa,"A",{id:!0,class:!0,href:!0});var wh=l(Qe);ms=i(wh,"SPAN",{});var kh=l(ms);T(Xt.$$.fragment,kh),kh.forEach(o),wh.forEach(o),Pi=h(aa),us=i(aa,"SPAN",{});var Bh=l(us);qi=r(Bh,"MegatronBertModel"),Bh.forEach(o),aa.forEach(o),Rr=h(t),F=i(t,"DIV",{class:!0});var P=l(F);T(Lt.$$.fragment,P),Ai=h(P),gs=i(P,"P",{});var $h=l(gs);Si=r($h,"The bare MegatronBert Model transformer outputting raw hidden-states without any specific head on top."),$h.forEach(o),Xi=h(P),Qt=i(P,"P",{});var ia=l(Qt);Li=r(ia,"This model inherits from "),bn=i(ia,"A",{href:!0});var Jh=l(bn);Qi=r(Jh,"PreTrainedModel"),Jh.forEach(o),Hi=r(ia,`. 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.)`),ia.forEach(o),Oi=h(P),Ht=i(P,"P",{});var la=l(Ht);Yi=r(la,"This model is also a PyTorch "),Ot=i(la,"A",{href:!0,rel:!0});var Fh=l(Ot);Di=r(Fh,"torch.nn.Module"),Fh.forEach(o),Ki=r(la,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),la.forEach(o),el=h(P),Yt=i(P,"P",{});var da=l(Yt);tl=r(da,`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in `),Dt=i(da,"A",{href:!0,rel:!0});var jh=l(Dt);ol=r(jh,`Attention is
all you need`),jh.forEach(o),nl=r(da,` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),da.forEach(o),sl=h(P),C=i(P,"P",{});var q=l(C);rl=r(q,"To behave as an decoder the model needs to be initialized with the "),fs=i(q,"CODE",{});var Ch=l(fs);al=r(Ch,"is_decoder"),Ch.forEach(o),il=r(q,` argument of the configuration set
to `),_s=i(q,"CODE",{});var zh=l(_s);ll=r(zh,"True"),zh.forEach(o),dl=r(q,". To be used in a Seq2Seq model, the model needs to initialized with both "),Ms=i(q,"CODE",{});var Eh=l(Ms);cl=r(Eh,"is_decoder"),Eh.forEach(o),pl=r(q,` argument and
`),bs=i(q,"CODE",{});var Uh=l(bs);hl=r(Uh,"add_cross_attention"),Uh.forEach(o),ml=r(q," set to "),ys=i(q,"CODE",{});var Wh=l(ys);ul=r(Wh,"True"),Wh.forEach(o),gl=r(q,"; an "),Ts=i(q,"CODE",{});var Nh=l(Ts);fl=r(Nh,"encoder_hidden_states"),Nh.forEach(o),_l=r(q," is then expected as an input to the forward pass."),q.forEach(o),Ml=h(P),X=i(P,"DIV",{class:!0});var wt=l(X);T(Kt.$$.fragment,wt),bl=h(wt),Te=i(wt,"P",{});var Gn=l(Te);yl=r(Gn,"The "),yn=i(Gn,"A",{href:!0});var Zh=l(yn);Tl=r(Zh,"MegatronBertModel"),Zh.forEach(o),vl=r(Gn," forward method, overrides the "),vs=i(Gn,"CODE",{});var xh=l(vs);wl=r(xh,"__call__"),xh.forEach(o),kl=r(Gn," special method."),Gn.forEach(o),Bl=h(wt),T(He.$$.fragment,wt),$l=h(wt),T(Oe.$$.fragment,wt),wt.forEach(o),P.forEach(o),Gr=h(t),ve=i(t,"H2",{class:!0});var ca=l(ve);Ye=i(ca,"A",{id:!0,class:!0,href:!0});var Ih=l(Ye);ws=i(Ih,"SPAN",{});var Vh=l(ws);T(eo.$$.fragment,Vh),Vh.forEach(o),Ih.forEach(o),Jl=h(ca),ks=i(ca,"SPAN",{});var Rh=l(ks);Fl=r(Rh,"MegatronBertForMaskedLM"),Rh.forEach(o),ca.forEach(o),Pr=h(t),E=i(t,"DIV",{class:!0});var ae=l(E);T(to.$$.fragment,ae),jl=h(ae),oo=i(ae,"P",{});var pa=l(oo);Cl=r(pa,"MegatronBert Model with a "),Bs=i(pa,"CODE",{});var Gh=l(Bs);zl=r(Gh,"language modeling"),Gh.forEach(o),El=r(pa," head on top."),pa.forEach(o),Ul=h(ae),no=i(ae,"P",{});var ha=l(no);Wl=r(ha,"This model inherits from "),Tn=i(ha,"A",{href:!0});var Ph=l(Tn);Nl=r(Ph,"PreTrainedModel"),Ph.forEach(o),Zl=r(ha,`. 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.)`),ha.forEach(o),xl=h(ae),so=i(ae,"P",{});var ma=l(so);Il=r(ma,"This model is also a PyTorch "),ro=i(ma,"A",{href:!0,rel:!0});var qh=l(ro);Vl=r(qh,"torch.nn.Module"),qh.forEach(o),Rl=r(ma,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ma.forEach(o),Gl=h(ae),L=i(ae,"DIV",{class:!0});var kt=l(L);T(ao.$$.fragment,kt),Pl=h(kt),we=i(kt,"P",{});var Pn=l(we);ql=r(Pn,"The "),vn=i(Pn,"A",{href:!0});var Ah=l(vn);Al=r(Ah,"MegatronBertForMaskedLM"),Ah.forEach(o),Sl=r(Pn," forward method, overrides the "),$s=i(Pn,"CODE",{});var Sh=l($s);Xl=r(Sh,"__call__"),Sh.forEach(o),Ll=r(Pn," special method."),Pn.forEach(o),Ql=h(kt),T(De.$$.fragment,kt),Hl=h(kt),T(Ke.$$.fragment,kt),kt.forEach(o),ae.forEach(o),qr=h(t),ke=i(t,"H2",{class:!0});var ua=l(ke);et=i(ua,"A",{id:!0,class:!0,href:!0});var Xh=l(et);Js=i(Xh,"SPAN",{});var Lh=l(Js);T(io.$$.fragment,Lh),Lh.forEach(o),Xh.forEach(o),Ol=h(ua),Fs=i(ua,"SPAN",{});var Qh=l(Fs);Yl=r(Qh,"MegatronBertForCausalLM"),Qh.forEach(o),ua.forEach(o),Ar=h(t),U=i(t,"DIV",{class:!0});var ie=l(U);T(lo.$$.fragment,ie),Dl=h(ie),co=i(ie,"P",{});var ga=l(co);Kl=r(ga,"MegatronBert Model with a "),js=i(ga,"CODE",{});var Hh=l(js);ed=r(Hh,"language modeling"),Hh.forEach(o),td=r(ga," head on top for CLM fine-tuning."),ga.forEach(o),od=h(ie),po=i(ie,"P",{});var fa=l(po);nd=r(fa,"This model inherits from "),wn=i(fa,"A",{href:!0});var Oh=l(wn);sd=r(Oh,"PreTrainedModel"),Oh.forEach(o),rd=r(fa,`. 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.)`),fa.forEach(o),ad=h(ie),ho=i(ie,"P",{});var _a=l(ho);id=r(_a,"This model is also a PyTorch "),mo=i(_a,"A",{href:!0,rel:!0});var Yh=l(mo);ld=r(Yh,"torch.nn.Module"),Yh.forEach(o),dd=r(_a,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),_a.forEach(o),cd=h(ie),Q=i(ie,"DIV",{class:!0});var Bt=l(Q);T(uo.$$.fragment,Bt),pd=h(Bt),Be=i(Bt,"P",{});var qn=l(Be);hd=r(qn,"The "),kn=i(qn,"A",{href:!0});var Dh=l(kn);md=r(Dh,"MegatronBertForCausalLM"),Dh.forEach(o),ud=r(qn," forward method, overrides the "),Cs=i(qn,"CODE",{});var Kh=l(Cs);gd=r(Kh,"__call__"),Kh.forEach(o),fd=r(qn," special method."),qn.forEach(o),_d=h(Bt),T(tt.$$.fragment,Bt),Md=h(Bt),T(ot.$$.fragment,Bt),Bt.forEach(o),ie.forEach(o),Sr=h(t),$e=i(t,"H2",{class:!0});var Ma=l($e);nt=i(Ma,"A",{id:!0,class:!0,href:!0});var em=l(nt);zs=i(em,"SPAN",{});var tm=l(zs);T(go.$$.fragment,tm),tm.forEach(o),em.forEach(o),bd=h(Ma),Es=i(Ma,"SPAN",{});var om=l(Es);yd=r(om,"MegatronBertForNextSentencePrediction"),om.forEach(o),Ma.forEach(o),Xr=h(t),W=i(t,"DIV",{class:!0});var le=l(W);T(fo.$$.fragment,le),Td=h(le),_o=i(le,"P",{});var ba=l(_o);vd=r(ba,"MegatronBert Model with a "),Us=i(ba,"CODE",{});var nm=l(Us);wd=r(nm,"next sentence prediction (classification)"),nm.forEach(o),kd=r(ba," head on top."),ba.forEach(o),Bd=h(le),Mo=i(le,"P",{});var ya=l(Mo);$d=r(ya,"This model inherits from "),Bn=i(ya,"A",{href:!0});var sm=l(Bn);Jd=r(sm,"PreTrainedModel"),sm.forEach(o),Fd=r(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),jd=h(le),bo=i(le,"P",{});var Ta=l(bo);Cd=r(Ta,"This model is also a PyTorch "),yo=i(Ta,"A",{href:!0,rel:!0});var rm=l(yo);zd=r(rm,"torch.nn.Module"),rm.forEach(o),Ed=r(Ta,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ta.forEach(o),Ud=h(le),H=i(le,"DIV",{class:!0});var $t=l(H);T(To.$$.fragment,$t),Wd=h($t),Je=i($t,"P",{});var An=l(Je);Nd=r(An,"The "),$n=i(An,"A",{href:!0});var am=l($n);Zd=r(am,"MegatronBertForNextSentencePrediction"),am.forEach(o),xd=r(An," forward method, overrides the "),Ws=i(An,"CODE",{});var im=l(Ws);Id=r(im,"__call__"),im.forEach(o),Vd=r(An," special method."),An.forEach(o),Rd=h($t),T(st.$$.fragment,$t),Gd=h($t),T(rt.$$.fragment,$t),$t.forEach(o),le.forEach(o),Lr=h(t),Fe=i(t,"H2",{class:!0});var va=l(Fe);at=i(va,"A",{id:!0,class:!0,href:!0});var lm=l(at);Ns=i(lm,"SPAN",{});var dm=l(Ns);T(vo.$$.fragment,dm),dm.forEach(o),lm.forEach(o),Pd=h(va),Zs=i(va,"SPAN",{});var cm=l(Zs);qd=r(cm,"MegatronBertForPreTraining"),cm.forEach(o),va.forEach(o),Qr=h(t),N=i(t,"DIV",{class:!0});var de=l(N);T(wo.$$.fragment,de),Ad=h(de),je=i(de,"P",{});var Sn=l(je);Sd=r(Sn,"MegatronBert Model with two heads on top as done during the pretraining: a "),xs=i(Sn,"CODE",{});var pm=l(xs);Xd=r(pm,"masked language modeling"),pm.forEach(o),Ld=r(Sn,` head and a
`),Is=i(Sn,"CODE",{});var hm=l(Is);Qd=r(hm,"next sentence prediction (classification)"),hm.forEach(o),Hd=r(Sn," head."),Sn.forEach(o),Od=h(de),ko=i(de,"P",{});var wa=l(ko);Yd=r(wa,"This model inherits from "),Jn=i(wa,"A",{href:!0});var mm=l(Jn);Dd=r(mm,"PreTrainedModel"),mm.forEach(o),Kd=r(wa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),wa.forEach(o),ec=h(de),Bo=i(de,"P",{});var ka=l(Bo);tc=r(ka,"This model is also a PyTorch "),$o=i(ka,"A",{href:!0,rel:!0});var um=l($o);oc=r(um,"torch.nn.Module"),um.forEach(o),nc=r(ka,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ka.forEach(o),sc=h(de),O=i(de,"DIV",{class:!0});var Jt=l(O);T(Jo.$$.fragment,Jt),rc=h(Jt),Ce=i(Jt,"P",{});var Xn=l(Ce);ac=r(Xn,"The "),Fn=i(Xn,"A",{href:!0});var gm=l(Fn);ic=r(gm,"MegatronBertForPreTraining"),gm.forEach(o),lc=r(Xn," forward method, overrides the "),Vs=i(Xn,"CODE",{});var fm=l(Vs);dc=r(fm,"__call__"),fm.forEach(o),cc=r(Xn," special method."),Xn.forEach(o),pc=h(Jt),T(it.$$.fragment,Jt),hc=h(Jt),T(lt.$$.fragment,Jt),Jt.forEach(o),de.forEach(o),Hr=h(t),ze=i(t,"H2",{class:!0});var Ba=l(ze);dt=i(Ba,"A",{id:!0,class:!0,href:!0});var _m=l(dt);Rs=i(_m,"SPAN",{});var Mm=l(Rs);T(Fo.$$.fragment,Mm),Mm.forEach(o),_m.forEach(o),mc=h(Ba),Gs=i(Ba,"SPAN",{});var bm=l(Gs);uc=r(bm,"MegatronBertForSequenceClassification"),bm.forEach(o),Ba.forEach(o),Or=h(t),Z=i(t,"DIV",{class:!0});var ce=l(Z);T(jo.$$.fragment,ce),gc=h(ce),Ps=i(ce,"P",{});var ym=l(Ps);fc=r(ym,`MegatronBert Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),ym.forEach(o),_c=h(ce),Co=i(ce,"P",{});var $a=l(Co);Mc=r($a,"This model inherits from "),jn=i($a,"A",{href:!0});var Tm=l(jn);bc=r(Tm,"PreTrainedModel"),Tm.forEach(o),yc=r($a,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),$a.forEach(o),Tc=h(ce),zo=i(ce,"P",{});var Ja=l(zo);vc=r(Ja,"This model is also a PyTorch "),Eo=i(Ja,"A",{href:!0,rel:!0});var vm=l(Eo);wc=r(vm,"torch.nn.Module"),vm.forEach(o),kc=r(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),Bc=h(ce),G=i(ce,"DIV",{class:!0});var pe=l(G);T(Uo.$$.fragment,pe),$c=h(pe),Ee=i(pe,"P",{});var Ln=l(Ee);Jc=r(Ln,"The "),Cn=i(Ln,"A",{href:!0});var wm=l(Cn);Fc=r(wm,"MegatronBertForSequenceClassification"),wm.forEach(o),jc=r(Ln," forward method, overrides the "),qs=i(Ln,"CODE",{});var km=l(qs);Cc=r(km,"__call__"),km.forEach(o),zc=r(Ln," special method."),Ln.forEach(o),Ec=h(pe),T(ct.$$.fragment,pe),Uc=h(pe),T(pt.$$.fragment,pe),Wc=h(pe),T(ht.$$.fragment,pe),pe.forEach(o),ce.forEach(o),Yr=h(t),Ue=i(t,"H2",{class:!0});var Fa=l(Ue);mt=i(Fa,"A",{id:!0,class:!0,href:!0});var Bm=l(mt);As=i(Bm,"SPAN",{});var $m=l(As);T(Wo.$$.fragment,$m),$m.forEach(o),Bm.forEach(o),Nc=h(Fa),Ss=i(Fa,"SPAN",{});var Jm=l(Ss);Zc=r(Jm,"MegatronBertForMultipleChoice"),Jm.forEach(o),Fa.forEach(o),Dr=h(t),x=i(t,"DIV",{class:!0});var he=l(x);T(No.$$.fragment,he),xc=h(he),Xs=i(he,"P",{});var Fm=l(Xs);Ic=r(Fm,`MegatronBert 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.`),Fm.forEach(o),Vc=h(he),Zo=i(he,"P",{});var ja=l(Zo);Rc=r(ja,"This model inherits from "),zn=i(ja,"A",{href:!0});var jm=l(zn);Gc=r(jm,"PreTrainedModel"),jm.forEach(o),Pc=r(ja,`. 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.)`),ja.forEach(o),qc=h(he),xo=i(he,"P",{});var Ca=l(xo);Ac=r(Ca,"This model is also a PyTorch "),Io=i(Ca,"A",{href:!0,rel:!0});var Cm=l(Io);Sc=r(Cm,"torch.nn.Module"),Cm.forEach(o),Xc=r(Ca,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ca.forEach(o),Lc=h(he),Y=i(he,"DIV",{class:!0});var Ft=l(Y);T(Vo.$$.fragment,Ft),Qc=h(Ft),We=i(Ft,"P",{});var Qn=l(We);Hc=r(Qn,"The "),En=i(Qn,"A",{href:!0});var zm=l(En);Oc=r(zm,"MegatronBertForMultipleChoice"),zm.forEach(o),Yc=r(Qn," forward method, overrides the "),Ls=i(Qn,"CODE",{});var Em=l(Ls);Dc=r(Em,"__call__"),Em.forEach(o),Kc=r(Qn," special method."),Qn.forEach(o),ep=h(Ft),T(ut.$$.fragment,Ft),tp=h(Ft),T(gt.$$.fragment,Ft),Ft.forEach(o),he.forEach(o),Kr=h(t),Ne=i(t,"H2",{class:!0});var za=l(Ne);ft=i(za,"A",{id:!0,class:!0,href:!0});var Um=l(ft);Qs=i(Um,"SPAN",{});var Wm=l(Qs);T(Ro.$$.fragment,Wm),Wm.forEach(o),Um.forEach(o),op=h(za),Hs=i(za,"SPAN",{});var Nm=l(Hs);np=r(Nm,"MegatronBertForTokenClassification"),Nm.forEach(o),za.forEach(o),ea=h(t),I=i(t,"DIV",{class:!0});var me=l(I);T(Go.$$.fragment,me),sp=h(me),Os=i(me,"P",{});var Zm=l(Os);rp=r(Zm,`MegatronBert 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.`),Zm.forEach(o),ap=h(me),Po=i(me,"P",{});var Ea=l(Po);ip=r(Ea,"This model inherits from "),Un=i(Ea,"A",{href:!0});var xm=l(Un);lp=r(xm,"PreTrainedModel"),xm.forEach(o),dp=r(Ea,`. 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.)`),Ea.forEach(o),cp=h(me),qo=i(me,"P",{});var Ua=l(qo);pp=r(Ua,"This model is also a PyTorch "),Ao=i(Ua,"A",{href:!0,rel:!0});var Im=l(Ao);hp=r(Im,"torch.nn.Module"),Im.forEach(o),mp=r(Ua,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ua.forEach(o),up=h(me),D=i(me,"DIV",{class:!0});var jt=l(D);T(So.$$.fragment,jt),gp=h(jt),Ze=i(jt,"P",{});var Hn=l(Ze);fp=r(Hn,"The "),Wn=i(Hn,"A",{href:!0});var Vm=l(Wn);_p=r(Vm,"MegatronBertForTokenClassification"),Vm.forEach(o),Mp=r(Hn," forward method, overrides the "),Ys=i(Hn,"CODE",{});var Rm=l(Ys);bp=r(Rm,"__call__"),Rm.forEach(o),yp=r(Hn," special method."),Hn.forEach(o),Tp=h(jt),T(_t.$$.fragment,jt),vp=h(jt),T(Mt.$$.fragment,jt),jt.forEach(o),me.forEach(o),ta=h(t),xe=i(t,"H2",{class:!0});var Wa=l(xe);bt=i(Wa,"A",{id:!0,class:!0,href:!0});var Gm=l(bt);Ds=i(Gm,"SPAN",{});var Pm=l(Ds);T(Xo.$$.fragment,Pm),Pm.forEach(o),Gm.forEach(o),wp=h(Wa),Ks=i(Wa,"SPAN",{});var qm=l(Ks);kp=r(qm,"MegatronBertForQuestionAnswering"),qm.forEach(o),Wa.forEach(o),oa=h(t),V=i(t,"DIV",{class:!0});var ue=l(V);T(Lo.$$.fragment,ue),Bp=h(ue),Ie=i(ue,"P",{});var On=l(Ie);$p=r(On,`MegatronBert 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 `),er=i(On,"CODE",{});var Am=l(er);Jp=r(Am,"span start logits"),Am.forEach(o),Fp=r(On," and "),tr=i(On,"CODE",{});var Sm=l(tr);jp=r(Sm,"span end logits"),Sm.forEach(o),Cp=r(On,")."),On.forEach(o),zp=h(ue),Qo=i(ue,"P",{});var Na=l(Qo);Ep=r(Na,"This model inherits from "),Nn=i(Na,"A",{href:!0});var Xm=l(Nn);Up=r(Xm,"PreTrainedModel"),Xm.forEach(o),Wp=r(Na,`. 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.)`),Na.forEach(o),Np=h(ue),Ho=i(ue,"P",{});var Za=l(Ho);Zp=r(Za,"This model is also a PyTorch "),Oo=i(Za,"A",{href:!0,rel:!0});var Lm=l(Oo);xp=r(Lm,"torch.nn.Module"),Lm.forEach(o),Ip=r(Za,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Za.forEach(o),Vp=h(ue),K=i(ue,"DIV",{class:!0});var Ct=l(K);T(Yo.$$.fragment,Ct),Rp=h(Ct),Ve=i(Ct,"P",{});var Yn=l(Ve);Gp=r(Yn,"The "),Zn=i(Yn,"A",{href:!0});var Qm=l(Zn);Pp=r(Qm,"MegatronBertForQuestionAnswering"),Qm.forEach(o),qp=r(Yn," forward method, overrides the "),or=i(Yn,"CODE",{});var Hm=l(or);Ap=r(Hm,"__call__"),Hm.forEach(o),Sp=r(Yn," special method."),Yn.forEach(o),Xp=h(Ct),T(yt.$$.fragment,Ct),Lp=h(Ct),T(Tt.$$.fragment,Ct),Ct.forEach(o),ue.forEach(o),this.h()},h(){m(d,"name","hf:doc:metadata"),m(d,"content",JSON.stringify(vu)),m(u,"id","megatronbert"),m(u,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(u,"href","#megatronbert"),m(f,"class","relative group"),m(Pe,"id","overview"),m(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"),m(Pe,"href","#overview"),m(ge,"class","relative group"),m(Et,"href","https://arxiv.org/abs/1909.08053"),m(Et,"rel","nofollow"),m(Ut,"href","https://ngc.nvidia.com/catalog/models/nvidia:megatron_bert_345m"),m(Ut,"rel","nofollow"),m(Wt,"href","https://ngc.nvidia.com/signup"),m(Wt,"rel","nofollow"),m(Nt,"href","https://docs.nvidia.com/dgx/ngc-registry-cli-user-guide/index.html#topic_6_4_1"),m(Nt,"rel","nofollow"),m(Rt,"href","https://huggingface.co/jdemouth"),m(Rt,"rel","nofollow"),m(Gt,"href","https://github.com/NVIDIA/Megatron-LM"),m(Gt,"rel","nofollow"),m(Se,"id","documentation-resources"),m(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Se,"href","#documentation-resources"),m(fe,"class","relative group"),m(cn,"href","../tasks/sequence_classification"),m(pn,"href","../tasks/token_classification"),m(hn,"href","../tasks/question_answering"),m(mn,"href","../tasks/language_modeling"),m(un,"href","../tasks/masked_language_modeling"),m(gn,"href","../tasks/multiple_choice"),m(Xe,"id","transformers.MegatronBertConfig"),m(Xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Xe,"href","#transformers.MegatronBertConfig"),m(_e,"class","relative group"),m(fn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertModel"),m(St,"href","https://huggingface.co/nvidia/megatron-bert-uncased-345m"),m(St,"rel","nofollow"),m(_n,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(Mn,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Qe,"id","transformers.MegatronBertModel"),m(Qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Qe,"href","#transformers.MegatronBertModel"),m(ye,"class","relative group"),m(bn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(Ot,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Ot,"rel","nofollow"),m(Dt,"href","https://arxiv.org/abs/1706.03762"),m(Dt,"rel","nofollow"),m(yn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertModel"),m(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ye,"id","transformers.MegatronBertForMaskedLM"),m(Ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Ye,"href","#transformers.MegatronBertForMaskedLM"),m(ve,"class","relative group"),m(Tn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(ro,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(ro,"rel","nofollow"),m(vn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForMaskedLM"),m(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(et,"id","transformers.MegatronBertForCausalLM"),m(et,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(et,"href","#transformers.MegatronBertForCausalLM"),m(ke,"class","relative group"),m(wn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(mo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(mo,"rel","nofollow"),m(kn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForCausalLM"),m(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(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(nt,"id","transformers.MegatronBertForNextSentencePrediction"),m(nt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(nt,"href","#transformers.MegatronBertForNextSentencePrediction"),m($e,"class","relative group"),m(Bn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(yo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(yo,"rel","nofollow"),m($n,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForNextSentencePrediction"),m(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(at,"id","transformers.MegatronBertForPreTraining"),m(at,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(at,"href","#transformers.MegatronBertForPreTraining"),m(Fe,"class","relative group"),m(Jn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m($o,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m($o,"rel","nofollow"),m(Fn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForPreTraining"),m(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(dt,"id","transformers.MegatronBertForSequenceClassification"),m(dt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(dt,"href","#transformers.MegatronBertForSequenceClassification"),m(ze,"class","relative group"),m(jn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(Eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Eo,"rel","nofollow"),m(Cn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForSequenceClassification"),m(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(mt,"id","transformers.MegatronBertForMultipleChoice"),m(mt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(mt,"href","#transformers.MegatronBertForMultipleChoice"),m(Ue,"class","relative group"),m(zn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(Io,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Io,"rel","nofollow"),m(En,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForMultipleChoice"),m(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ft,"id","transformers.MegatronBertForTokenClassification"),m(ft,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ft,"href","#transformers.MegatronBertForTokenClassification"),m(Ne,"class","relative group"),m(Un,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(Ao,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Ao,"rel","nofollow"),m(Wn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForTokenClassification"),m(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(bt,"id","transformers.MegatronBertForQuestionAnswering"),m(bt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(bt,"href","#transformers.MegatronBertForQuestionAnswering"),m(xe,"class","relative group"),m(Nn,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),m(Oo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Oo,"rel","nofollow"),m(Zn,"href","/docs/transformers/v4.32.0/en/model_doc/megatron-bert#transformers.MegatronBertForQuestionAnswering"),m(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(V,"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,g){e(document.head,d),_(t,b,g),_(t,f,g),e(f,u),e(u,M),v(n,M,null),e(f,c),e(f,J),e(J,xa),_(t,Mr,g),_(t,ge,g),e(ge,Pe),e(Pe,Dn),v(zt,Dn,null),e(ge,Ia),e(ge,Kn),e(Kn,Va),_(t,br,g),_(t,qe,g),e(qe,Ra),e(qe,Et),e(Et,Ga),e(qe,Pa),_(t,yr,g),_(t,on,g),e(on,qa),_(t,Tr,g),_(t,nn,g),e(nn,es),e(es,Aa),_(t,vr,g),_(t,sn,g),e(sn,Sa),_(t,wr,g),_(t,Ae,g),e(Ae,Xa),e(Ae,Ut),e(Ut,La),e(Ae,Qa),_(t,kr,g),_(t,ne,g),e(ne,Ha),e(ne,Wt),e(Wt,Oa),e(ne,Ya),e(ne,Nt),e(Nt,Da),e(ne,Ka),_(t,Br,g),_(t,rn,g),e(rn,ei),_(t,$r,g),_(t,an,g),e(an,ti),_(t,Jr,g),v(Zt,t,g),_(t,Fr,g),_(t,ln,g),e(ln,oi),_(t,jr,g),v(xt,t,g),_(t,Cr,g),_(t,dn,g),e(dn,ni),_(t,zr,g),_(t,se,g),e(se,si),e(se,ts),e(ts,ri),e(se,ai),e(se,os),e(os,ii),e(se,li),_(t,Er,g),v(It,t,g),_(t,Ur,g),v(Vt,t,g),_(t,Wr,g),_(t,re,g),e(re,di),e(re,Rt),e(Rt,ci),e(re,pi),e(re,Gt),e(Gt,hi),e(re,mi),_(t,Nr,g),_(t,fe,g),e(fe,Se),e(Se,ns),v(Pt,ns,null),e(fe,ui),e(fe,ss),e(ss,gi),_(t,Zr,g),_(t,z,g),e(z,rs),e(rs,cn),e(cn,fi),e(z,_i),e(z,as),e(as,pn),e(pn,Mi),e(z,bi),e(z,is),e(is,hn),e(hn,yi),e(z,Ti),e(z,ls),e(ls,mn),e(mn,vi),e(z,wi),e(z,ds),e(ds,un),e(un,ki),e(z,Bi),e(z,cs),e(cs,gn),e(gn,$i),_(t,xr,g),_(t,_e,g),e(_e,Xe),e(Xe,ps),v(qt,ps,null),e(_e,Ji),e(_e,hs),e(hs,Fi),_(t,Ir,g),_(t,A,g),v(At,A,null),e(A,ji),e(A,Me),e(Me,Ci),e(Me,fn),e(fn,zi),e(Me,Ei),e(Me,St),e(St,Ui),e(Me,Wi),e(A,Ni),e(A,be),e(be,Zi),e(be,_n),e(_n,xi),e(be,Ii),e(be,Mn),e(Mn,Vi),e(be,Ri),e(A,Gi),v(Le,A,null),_(t,Vr,g),_(t,ye,g),e(ye,Qe),e(Qe,ms),v(Xt,ms,null),e(ye,Pi),e(ye,us),e(us,qi),_(t,Rr,g),_(t,F,g),v(Lt,F,null),e(F,Ai),e(F,gs),e(gs,Si),e(F,Xi),e(F,Qt),e(Qt,Li),e(Qt,bn),e(bn,Qi),e(Qt,Hi),e(F,Oi),e(F,Ht),e(Ht,Yi),e(Ht,Ot),e(Ot,Di),e(Ht,Ki),e(F,el),e(F,Yt),e(Yt,tl),e(Yt,Dt),e(Dt,ol),e(Yt,nl),e(F,sl),e(F,C),e(C,rl),e(C,fs),e(fs,al),e(C,il),e(C,_s),e(_s,ll),e(C,dl),e(C,Ms),e(Ms,cl),e(C,pl),e(C,bs),e(bs,hl),e(C,ml),e(C,ys),e(ys,ul),e(C,gl),e(C,Ts),e(Ts,fl),e(C,_l),e(F,Ml),e(F,X),v(Kt,X,null),e(X,bl),e(X,Te),e(Te,yl),e(Te,yn),e(yn,Tl),e(Te,vl),e(Te,vs),e(vs,wl),e(Te,kl),e(X,Bl),v(He,X,null),e(X,$l),v(Oe,X,null),_(t,Gr,g),_(t,ve,g),e(ve,Ye),e(Ye,ws),v(eo,ws,null),e(ve,Jl),e(ve,ks),e(ks,Fl),_(t,Pr,g),_(t,E,g),v(to,E,null),e(E,jl),e(E,oo),e(oo,Cl),e(oo,Bs),e(Bs,zl),e(oo,El),e(E,Ul),e(E,no),e(no,Wl),e(no,Tn),e(Tn,Nl),e(no,Zl),e(E,xl),e(E,so),e(so,Il),e(so,ro),e(ro,Vl),e(so,Rl),e(E,Gl),e(E,L),v(ao,L,null),e(L,Pl),e(L,we),e(we,ql),e(we,vn),e(vn,Al),e(we,Sl),e(we,$s),e($s,Xl),e(we,Ll),e(L,Ql),v(De,L,null),e(L,Hl),v(Ke,L,null),_(t,qr,g),_(t,ke,g),e(ke,et),e(et,Js),v(io,Js,null),e(ke,Ol),e(ke,Fs),e(Fs,Yl),_(t,Ar,g),_(t,U,g),v(lo,U,null),e(U,Dl),e(U,co),e(co,Kl),e(co,js),e(js,ed),e(co,td),e(U,od),e(U,po),e(po,nd),e(po,wn),e(wn,sd),e(po,rd),e(U,ad),e(U,ho),e(ho,id),e(ho,mo),e(mo,ld),e(ho,dd),e(U,cd),e(U,Q),v(uo,Q,null),e(Q,pd),e(Q,Be),e(Be,hd),e(Be,kn),e(kn,md),e(Be,ud),e(Be,Cs),e(Cs,gd),e(Be,fd),e(Q,_d),v(tt,Q,null),e(Q,Md),v(ot,Q,null),_(t,Sr,g),_(t,$e,g),e($e,nt),e(nt,zs),v(go,zs,null),e($e,bd),e($e,Es),e(Es,yd),_(t,Xr,g),_(t,W,g),v(fo,W,null),e(W,Td),e(W,_o),e(_o,vd),e(_o,Us),e(Us,wd),e(_o,kd),e(W,Bd),e(W,Mo),e(Mo,$d),e(Mo,Bn),e(Bn,Jd),e(Mo,Fd),e(W,jd),e(W,bo),e(bo,Cd),e(bo,yo),e(yo,zd),e(bo,Ed),e(W,Ud),e(W,H),v(To,H,null),e(H,Wd),e(H,Je),e(Je,Nd),e(Je,$n),e($n,Zd),e(Je,xd),e(Je,Ws),e(Ws,Id),e(Je,Vd),e(H,Rd),v(st,H,null),e(H,Gd),v(rt,H,null),_(t,Lr,g),_(t,Fe,g),e(Fe,at),e(at,Ns),v(vo,Ns,null),e(Fe,Pd),e(Fe,Zs),e(Zs,qd),_(t,Qr,g),_(t,N,g),v(wo,N,null),e(N,Ad),e(N,je),e(je,Sd),e(je,xs),e(xs,Xd),e(je,Ld),e(je,Is),e(Is,Qd),e(je,Hd),e(N,Od),e(N,ko),e(ko,Yd),e(ko,Jn),e(Jn,Dd),e(ko,Kd),e(N,ec),e(N,Bo),e(Bo,tc),e(Bo,$o),e($o,oc),e(Bo,nc),e(N,sc),e(N,O),v(Jo,O,null),e(O,rc),e(O,Ce),e(Ce,ac),e(Ce,Fn),e(Fn,ic),e(Ce,lc),e(Ce,Vs),e(Vs,dc),e(Ce,cc),e(O,pc),v(it,O,null),e(O,hc),v(lt,O,null),_(t,Hr,g),_(t,ze,g),e(ze,dt),e(dt,Rs),v(Fo,Rs,null),e(ze,mc),e(ze,Gs),e(Gs,uc),_(t,Or,g),_(t,Z,g),v(jo,Z,null),e(Z,gc),e(Z,Ps),e(Ps,fc),e(Z,_c),e(Z,Co),e(Co,Mc),e(Co,jn),e(jn,bc),e(Co,yc),e(Z,Tc),e(Z,zo),e(zo,vc),e(zo,Eo),e(Eo,wc),e(zo,kc),e(Z,Bc),e(Z,G),v(Uo,G,null),e(G,$c),e(G,Ee),e(Ee,Jc),e(Ee,Cn),e(Cn,Fc),e(Ee,jc),e(Ee,qs),e(qs,Cc),e(Ee,zc),e(G,Ec),v(ct,G,null),e(G,Uc),v(pt,G,null),e(G,Wc),v(ht,G,null),_(t,Yr,g),_(t,Ue,g),e(Ue,mt),e(mt,As),v(Wo,As,null),e(Ue,Nc),e(Ue,Ss),e(Ss,Zc),_(t,Dr,g),_(t,x,g),v(No,x,null),e(x,xc),e(x,Xs),e(Xs,Ic),e(x,Vc),e(x,Zo),e(Zo,Rc),e(Zo,zn),e(zn,Gc),e(Zo,Pc),e(x,qc),e(x,xo),e(xo,Ac),e(xo,Io),e(Io,Sc),e(xo,Xc),e(x,Lc),e(x,Y),v(Vo,Y,null),e(Y,Qc),e(Y,We),e(We,Hc),e(We,En),e(En,Oc),e(We,Yc),e(We,Ls),e(Ls,Dc),e(We,Kc),e(Y,ep),v(ut,Y,null),e(Y,tp),v(gt,Y,null),_(t,Kr,g),_(t,Ne,g),e(Ne,ft),e(ft,Qs),v(Ro,Qs,null),e(Ne,op),e(Ne,Hs),e(Hs,np),_(t,ea,g),_(t,I,g),v(Go,I,null),e(I,sp),e(I,Os),e(Os,rp),e(I,ap),e(I,Po),e(Po,ip),e(Po,Un),e(Un,lp),e(Po,dp),e(I,cp),e(I,qo),e(qo,pp),e(qo,Ao),e(Ao,hp),e(qo,mp),e(I,up),e(I,D),v(So,D,null),e(D,gp),e(D,Ze),e(Ze,fp),e(Ze,Wn),e(Wn,_p),e(Ze,Mp),e(Ze,Ys),e(Ys,bp),e(Ze,yp),e(D,Tp),v(_t,D,null),e(D,vp),v(Mt,D,null),_(t,ta,g),_(t,xe,g),e(xe,bt),e(bt,Ds),v(Xo,Ds,null),e(xe,wp),e(xe,Ks),e(Ks,kp),_(t,oa,g),_(t,V,g),v(Lo,V,null),e(V,Bp),e(V,Ie),e(Ie,$p),e(Ie,er),e(er,Jp),e(Ie,Fp),e(Ie,tr),e(tr,jp),e(Ie,Cp),e(V,zp),e(V,Qo),e(Qo,Ep),e(Qo,Nn),e(Nn,Up),e(Qo,Wp),e(V,Np),e(V,Ho),e(Ho,Zp),e(Ho,Oo),e(Oo,xp),e(Ho,Ip),e(V,Vp),e(V,K),v(Yo,K,null),e(K,Rp),e(K,Ve),e(Ve,Gp),e(Ve,Zn),e(Zn,Pp),e(Ve,qp),e(Ve,or),e(or,Ap),e(Ve,Sp),e(K,Xp),v(yt,K,null),e(K,Lp),v(Tt,K,null),na=!0},p(t,[g]){const Do={};g&2&&(Do.$$scope={dirty:g,ctx:t}),Le.$set(Do);const nr={};g&2&&(nr.$$scope={dirty:g,ctx:t}),He.$set(nr);const sr={};g&2&&(sr.$$scope={dirty:g,ctx:t}),Oe.$set(sr);const rr={};g&2&&(rr.$$scope={dirty:g,ctx:t}),De.$set(rr);const Ko={};g&2&&(Ko.$$scope={dirty:g,ctx:t}),Ke.$set(Ko);const ar={};g&2&&(ar.$$scope={dirty:g,ctx:t}),tt.$set(ar);const ir={};g&2&&(ir.$$scope={dirty:g,ctx:t}),ot.$set(ir);const lr={};g&2&&(lr.$$scope={dirty:g,ctx:t}),st.$set(lr);const en={};g&2&&(en.$$scope={dirty:g,ctx:t}),rt.$set(en);const dr={};g&2&&(dr.$$scope={dirty:g,ctx:t}),it.$set(dr);const cr={};g&2&&(cr.$$scope={dirty:g,ctx:t}),lt.$set(cr);const pr={};g&2&&(pr.$$scope={dirty:g,ctx:t}),ct.$set(pr);const hr={};g&2&&(hr.$$scope={dirty:g,ctx:t}),pt.$set(hr);const mr={};g&2&&(mr.$$scope={dirty:g,ctx:t}),ht.$set(mr);const tn={};g&2&&(tn.$$scope={dirty:g,ctx:t}),ut.$set(tn);const ur={};g&2&&(ur.$$scope={dirty:g,ctx:t}),gt.$set(ur);const Re={};g&2&&(Re.$$scope={dirty:g,ctx:t}),_t.$set(Re);const gr={};g&2&&(gr.$$scope={dirty:g,ctx:t}),Mt.$set(gr);const fr={};g&2&&(fr.$$scope={dirty:g,ctx:t}),yt.$set(fr);const _r={};g&2&&(_r.$$scope={dirty:g,ctx:t}),Tt.$set(_r)},i(t){na||(w(n.$$.fragment,t),w(zt.$$.fragment,t),w(Zt.$$.fragment,t),w(xt.$$.fragment,t),w(It.$$.fragment,t),w(Vt.$$.fragment,t),w(Pt.$$.fragment,t),w(qt.$$.fragment,t),w(At.$$.fragment,t),w(Le.$$.fragment,t),w(Xt.$$.fragment,t),w(Lt.$$.fragment,t),w(Kt.$$.fragment,t),w(He.$$.fragment,t),w(Oe.$$.fragment,t),w(eo.$$.fragment,t),w(to.$$.fragment,t),w(ao.$$.fragment,t),w(De.$$.fragment,t),w(Ke.$$.fragment,t),w(io.$$.fragment,t),w(lo.$$.fragment,t),w(uo.$$.fragment,t),w(tt.$$.fragment,t),w(ot.$$.fragment,t),w(go.$$.fragment,t),w(fo.$$.fragment,t),w(To.$$.fragment,t),w(st.$$.fragment,t),w(rt.$$.fragment,t),w(vo.$$.fragment,t),w(wo.$$.fragment,t),w(Jo.$$.fragment,t),w(it.$$.fragment,t),w(lt.$$.fragment,t),w(Fo.$$.fragment,t),w(jo.$$.fragment,t),w(Uo.$$.fragment,t),w(ct.$$.fragment,t),w(pt.$$.fragment,t),w(ht.$$.fragment,t),w(Wo.$$.fragment,t),w(No.$$.fragment,t),w(Vo.$$.fragment,t),w(ut.$$.fragment,t),w(gt.$$.fragment,t),w(Ro.$$.fragment,t),w(Go.$$.fragment,t),w(So.$$.fragment,t),w(_t.$$.fragment,t),w(Mt.$$.fragment,t),w(Xo.$$.fragment,t),w(Lo.$$.fragment,t),w(Yo.$$.fragment,t),w(yt.$$.fragment,t),w(Tt.$$.fragment,t),na=!0)},o(t){k(n.$$.fragment,t),k(zt.$$.fragment,t),k(Zt.$$.fragment,t),k(xt.$$.fragment,t),k(It.$$.fragment,t),k(Vt.$$.fragment,t),k(Pt.$$.fragment,t),k(qt.$$.fragment,t),k(At.$$.fragment,t),k(Le.$$.fragment,t),k(Xt.$$.fragment,t),k(Lt.$$.fragment,t),k(Kt.$$.fragment,t),k(He.$$.fragment,t),k(Oe.$$.fragment,t),k(eo.$$.fragment,t),k(to.$$.fragment,t),k(ao.$$.fragment,t),k(De.$$.fragment,t),k(Ke.$$.fragment,t),k(io.$$.fragment,t),k(lo.$$.fragment,t),k(uo.$$.fragment,t),k(tt.$$.fragment,t),k(ot.$$.fragment,t),k(go.$$.fragment,t),k(fo.$$.fragment,t),k(To.$$.fragment,t),k(st.$$.fragment,t),k(rt.$$.fragment,t),k(vo.$$.fragment,t),k(wo.$$.fragment,t),k(Jo.$$.fragment,t),k(it.$$.fragment,t),k(lt.$$.fragment,t),k(Fo.$$.fragment,t),k(jo.$$.fragment,t),k(Uo.$$.fragment,t),k(ct.$$.fragment,t),k(pt.$$.fragment,t),k(ht.$$.fragment,t),k(Wo.$$.fragment,t),k(No.$$.fragment,t),k(Vo.$$.fragment,t),k(ut.$$.fragment,t),k(gt.$$.fragment,t),k(Ro.$$.fragment,t),k(Go.$$.fragment,t),k(So.$$.fragment,t),k(_t.$$.fragment,t),k(Mt.$$.fragment,t),k(Xo.$$.fragment,t),k(Lo.$$.fragment,t),k(Yo.$$.fragment,t),k(yt.$$.fragment,t),k(Tt.$$.fragment,t),na=!1},d(t){o(d),t&&o(b),t&&o(f),B(n),t&&o(Mr),t&&o(ge),B(zt),t&&o(br),t&&o(qe),t&&o(yr),t&&o(on),t&&o(Tr),t&&o(nn),t&&o(vr),t&&o(sn),t&&o(wr),t&&o(Ae),t&&o(kr),t&&o(ne),t&&o(Br),t&&o(rn),t&&o($r),t&&o(an),t&&o(Jr),B(Zt,t),t&&o(Fr),t&&o(ln),t&&o(jr),B(xt,t),t&&o(Cr),t&&o(dn),t&&o(zr),t&&o(se),t&&o(Er),B(It,t),t&&o(Ur),B(Vt,t),t&&o(Wr),t&&o(re),t&&o(Nr),t&&o(fe),B(Pt),t&&o(Zr),t&&o(z),t&&o(xr),t&&o(_e),B(qt),t&&o(Ir),t&&o(A),B(At),B(Le),t&&o(Vr),t&&o(ye),B(Xt),t&&o(Rr),t&&o(F),B(Lt),B(Kt),B(He),B(Oe),t&&o(Gr),t&&o(ve),B(eo),t&&o(Pr),t&&o(E),B(to),B(ao),B(De),B(Ke),t&&o(qr),t&&o(ke),B(io),t&&o(Ar),t&&o(U),B(lo),B(uo),B(tt),B(ot),t&&o(Sr),t&&o($e),B(go),t&&o(Xr),t&&o(W),B(fo),B(To),B(st),B(rt),t&&o(Lr),t&&o(Fe),B(vo),t&&o(Qr),t&&o(N),B(wo),B(Jo),B(it),B(lt),t&&o(Hr),t&&o(ze),B(Fo),t&&o(Or),t&&o(Z),B(jo),B(Uo),B(ct),B(pt),B(ht),t&&o(Yr),t&&o(Ue),B(Wo),t&&o(Dr),t&&o(x),B(No),B(Vo),B(ut),B(gt),t&&o(Kr),t&&o(Ne),B(Ro),t&&o(ea),t&&o(I),B(Go),B(So),B(_t),B(Mt),t&&o(ta),t&&o(xe),B(Xo),t&&o(oa),t&&o(V),B(Lo),B(Yo),B(yt),B(Tt)}}}const vu={local:"megatronbert",sections:[{local:"overview",title:"Overview"},{local:"documentation-resources",title:"Documentation resources"},{local:"transformers.MegatronBertConfig",title:"MegatronBertConfig"},{local:"transformers.MegatronBertModel",title:"MegatronBertModel"},{local:"transformers.MegatronBertForMaskedLM",title:"MegatronBertForMaskedLM"},{local:"transformers.MegatronBertForCausalLM",title:"MegatronBertForCausalLM"},{local:"transformers.MegatronBertForNextSentencePrediction",title:"MegatronBertForNextSentencePrediction"},{local:"transformers.MegatronBertForPreTraining",title:"MegatronBertForPreTraining"},{local:"transformers.MegatronBertForSequenceClassification",title:"MegatronBertForSequenceClassification"},{local:"transformers.MegatronBertForMultipleChoice",title:"MegatronBertForMultipleChoice"},{local:"transformers.MegatronBertForTokenClassification",title:"MegatronBertForTokenClassification"},{local:"transformers.MegatronBertForQuestionAnswering",title:"MegatronBertForQuestionAnswering"}],title:"MegatronBERT"};function wu($){return eu(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cu extends Om{constructor(d){super();Ym(this,d,wu,Tu,Dm,{})}}export{Cu as default,vu as metadata};
