import{S as Ha,i as Ua,s as Ra,e as s,k as h,w as k,t as l,M as Va,c as r,d as t,m as u,a,x as w,h as d,b as f,G as e,g as y,y as v,q as $,o as T,B as N,v as Ga,L as Be}from"../../chunks/vendor-hf-doc-builder.js";import{T as ot}from"../../chunks/Tip-hf-doc-builder.js";import{D as E}from"../../chunks/Docstring-hf-doc-builder.js";import{C as He}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as le}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Qe}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Ka(M){let i,b,p,m,_;return m=new He({props:{code:`from transformers import NystromformerModel, NystromformerConfig

# Initializing a Nystromformer uw-madison/nystromformer-512 style configuration
configuration = NystromformerConfig()

# Initializing a model from the uw-madison/nystromformer-512 style configuration
model = NystromformerModel(configuration)

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Nystromformer uw-madison/nystromformer-512 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = NystromformerConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the uw-madison/nystromformer-512 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerModel(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(){i=s("p"),b=l("Example:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function Ya(M){let i,b,p,m,_;return{c(){i=s("p"),b=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),p=s("code"),m=l("Module"),_=l(`
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){i=r(n,"P",{});var c=a(i);b=d(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),p=r(c,"CODE",{});var F=a(p);m=d(F,"Module"),F.forEach(t),_=d(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(t)},m(n,c){y(n,i,c),e(i,b),e(i,p),e(p,m),e(i,_)},d(n){n&&t(i)}}}function Ja(M){let i,b,p,m,_;return m=new He({props:{code:`from transformers import AutoTokenizer, NystromformerModel
import torch

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerModel.from_pretrained("uw-madison/nystromformer-512")

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

last_hidden_states = outputs.last_hidden_state`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NystromformerModel
<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;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerModel.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function Za(M){let i,b,p,m,_;return{c(){i=s("p"),b=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),p=s("code"),m=l("Module"),_=l(`
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){i=r(n,"P",{});var c=a(i);b=d(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),p=r(c,"CODE",{});var F=a(p);m=d(F,"Module"),F.forEach(t),_=d(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(t)},m(n,c){y(n,i,c),e(i,b),e(i,p),e(p,m),e(i,_)},d(n){n&&t(i)}}}function Xa(M){let i,b,p,m,_;return m=new He({props:{code:`from transformers import AutoTokenizer, NystromformerForMaskedLM
import torch

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerForMaskedLM.from_pretrained("uw-madison/nystromformer-512")

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

with torch.no_grad():
    logits = model(**inputs).logits

# retrieve index of [MASK]
mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[0].nonzero(as_tuple=True)[0]

predicted_token_id = logits[0, mask_token_index].argmax(axis=-1)

labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]
# mask labels of non-[MASK] tokens
labels = torch.where(inputs.input_ids == tokenizer.mask_token_id, labels, -100)

outputs = model(**inputs, labels=labels)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NystromformerForMaskedLM
<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;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerForMaskedLM.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function ei(M){let i,b,p,m,_;return{c(){i=s("p"),b=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),p=s("code"),m=l("Module"),_=l(`
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){i=r(n,"P",{});var c=a(i);b=d(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),p=r(c,"CODE",{});var F=a(p);m=d(F,"Module"),F.forEach(t),_=d(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(t)},m(n,c){y(n,i,c),e(i,b),e(i,p),e(p,m),e(i,_)},d(n){n&&t(i)}}}function oi(M){let i,b,p,m,_;return m=new He({props:{code:`import torch
from transformers import AutoTokenizer, NystromformerForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerForSequenceClassification.from_pretrained("uw-madison/nystromformer-512")

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

with torch.no_grad():
    logits = model(**inputs).logits

predicted_class_id = logits.argmax().item()

# To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`
num_labels = len(model.config.id2label)
model = NystromformerForSequenceClassification.from_pretrained("uw-madison/nystromformer-512", num_labels=num_labels)

labels = torch.tensor([1])
loss = model(**inputs, labels=labels).loss`,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, NystromformerForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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 = NystromformerForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example of single-label classification:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example of single-label classification:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function ti(M){let i,b,p,m,_;return m=new He({props:{code:`import torch
from transformers import AutoTokenizer, NystromformerForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerForSequenceClassification.from_pretrained("uw-madison/nystromformer-512", problem_type="multi_label_classification")

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

with torch.no_grad():
    logits = model(**inputs).logits

predicted_class_ids = torch.arange(0, logits.shape[-1])[torch.sigmoid(logits).squeeze(dim=0) > 0.5]

# To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`
num_labels = len(model.config.id2label)
model = NystromformerForSequenceClassification.from_pretrained(
    "uw-madison/nystromformer-512", num_labels=num_labels, problem_type="multi_label_classification"
)

labels = torch.sum(
    torch.nn.functional.one_hot(predicted_class_ids[None, :].clone(), num_classes=num_labels), dim=1
).to(torch.float)
loss = model(**inputs, labels=labels).loss`,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, NystromformerForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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 = NystromformerForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example of multi-label classification:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example of multi-label classification:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function ni(M){let i,b,p,m,_;return{c(){i=s("p"),b=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),p=s("code"),m=l("Module"),_=l(`
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){i=r(n,"P",{});var c=a(i);b=d(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),p=r(c,"CODE",{});var F=a(p);m=d(F,"Module"),F.forEach(t),_=d(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(t)},m(n,c){y(n,i,c),e(i,b),e(i,p),e(p,m),e(i,_)},d(n){n&&t(i)}}}function si(M){let i,b,p,m,_;return m=new He({props:{code:`from transformers import AutoTokenizer, NystromformerForMultipleChoice
import torch

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerForMultipleChoice.from_pretrained("uw-madison/nystromformer-512")

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

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

# the linear classifier still needs to be trained
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NystromformerForMultipleChoice
<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;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function ri(M){let i,b,p,m,_;return{c(){i=s("p"),b=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),p=s("code"),m=l("Module"),_=l(`
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){i=r(n,"P",{});var c=a(i);b=d(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),p=r(c,"CODE",{});var F=a(p);m=d(F,"Module"),F.forEach(t),_=d(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(t)},m(n,c){y(n,i,c),e(i,b),e(i,p),e(p,m),e(i,_)},d(n){n&&t(i)}}}function ai(M){let i,b,p,m,_;return m=new He({props:{code:`from transformers import AutoTokenizer, NystromformerForTokenClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerForTokenClassification.from_pretrained("uw-madison/nystromformer-512")

inputs = tokenizer(
    "HuggingFace is a company based in Paris and New York", add_special_tokens=False, return_tensors="pt"
)

with torch.no_grad():
    logits = model(**inputs).logits

predicted_token_class_ids = logits.argmax(-1)

# Note that tokens are classified rather then input words which means that
# there might be more predicted token classes than words.
# Multiple token classes might account for the same word
predicted_tokens_classes = [model.config.id2label[t.item()] for t in predicted_token_class_ids[0]]

labels = predicted_token_class_ids
loss = model(**inputs, labels=labels).loss`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NystromformerForTokenClassification
<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;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerForTokenClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function ii(M){let i,b,p,m,_;return{c(){i=s("p"),b=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),p=s("code"),m=l("Module"),_=l(`
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){i=r(n,"P",{});var c=a(i);b=d(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),p=r(c,"CODE",{});var F=a(p);m=d(F,"Module"),F.forEach(t),_=d(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(t)},m(n,c){y(n,i,c),e(i,b),e(i,p),e(p,m),e(i,_)},d(n){n&&t(i)}}}function li(M){let i,b,p,m,_;return m=new He({props:{code:`from transformers import AutoTokenizer, NystromformerForQuestionAnswering
import torch

tokenizer = AutoTokenizer.from_pretrained("uw-madison/nystromformer-512")
model = NystromformerForQuestionAnswering.from_pretrained("uw-madison/nystromformer-512")

question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"

inputs = tokenizer(question, text, return_tensors="pt")
with torch.no_grad():
    outputs = model(**inputs)

answer_start_index = outputs.start_logits.argmax()
answer_end_index = outputs.end_logits.argmax()

predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]

# target is "nice puppet"
target_start_index = torch.tensor([14])
target_end_index = torch.tensor([15])

outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
loss = outputs.loss`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, NystromformerForQuestionAnswering
<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;uw-madison/nystromformer-512&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NystromformerForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;uw-madison/nystromformer-512&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(){i=s("p"),b=l("Example:"),p=h(),k(m.$$.fragment)},l(n){i=r(n,"P",{});var c=a(i);b=d(c,"Example:"),c.forEach(t),p=u(n),w(m.$$.fragment,n)},m(n,c){y(n,i,c),e(i,b),y(n,p,c),v(m,n,c),_=!0},p:Be,i(n){_||($(m.$$.fragment,n),_=!0)},o(n){T(m.$$.fragment,n),_=!1},d(n){n&&t(i),n&&t(p),N(m,n)}}}function di(M){let i,b,p,m,_,n,c,F,vn,Bt,H,de,tt,Ue,$n,nt,Tn,Ht,ce,Nn,Re,st,Mn,Fn,Ut,jo,qn,Rt,Co,rt,zn,Vt,Q,xn,Ve,jn,Cn,Ge,An,En,Gt,U,me,at,Ke,Pn,it,On,Kt,z,Ye,Sn,R,Ln,Ao,In,Dn,Je,Wn,Qn,Bn,V,Hn,Eo,Un,Rn,Po,Vn,Gn,Kn,pe,Yt,G,fe,lt,Ze,Yn,dt,Jn,Jt,D,Xe,Zn,eo,Xn,oo,es,os,ts,P,to,ns,K,ss,Oo,rs,as,ct,is,ls,ds,he,cs,ue,Zt,Y,ge,mt,no,ms,pt,ps,Xt,W,so,fs,J,hs,ft,us,gs,ro,_s,ys,bs,O,ao,ks,Z,ws,So,vs,$s,ht,Ts,Ns,Ms,_e,Fs,ye,en,X,be,ut,io,qs,gt,zs,on,x,lo,xs,_t,js,Cs,co,As,mo,Es,Ps,Os,q,po,Ss,ee,Ls,Lo,Is,Ds,yt,Ws,Qs,Bs,ke,Hs,we,Us,ve,tn,oe,$e,bt,fo,Rs,kt,Vs,nn,j,ho,Gs,wt,Ks,Ys,uo,Js,go,Zs,Xs,er,S,_o,or,te,tr,Io,nr,sr,vt,rr,ar,ir,Te,lr,Ne,sn,ne,Me,$t,yo,dr,Tt,cr,rn,C,bo,mr,Nt,pr,fr,ko,hr,wo,ur,gr,_r,L,vo,yr,se,br,Do,kr,wr,Mt,vr,$r,Tr,Fe,Nr,qe,an,re,ze,Ft,$o,Mr,qt,Fr,ln,A,To,qr,ae,zr,zt,xr,jr,xt,Cr,Ar,Er,No,Pr,Mo,Or,Sr,Lr,I,Fo,Ir,ie,Dr,Wo,Wr,Qr,jt,Br,Hr,Ur,xe,Rr,je,dn;return n=new le({}),Ue=new le({}),Ke=new le({}),Ye=new E({props:{name:"class transformers.NystromformerConfig",anchor:"transformers.NystromformerConfig",parameters:[{name:"vocab_size",val:" = 30000"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu_new'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 510"},{name:"type_vocab_size",val:" = 2"},{name:"segment_means_seq_len",val:" = 64"},{name:"num_landmarks",val:" = 64"},{name:"conv_kernel_size",val:" = 65"},{name:"inv_coeff_init_option",val:" = False"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.NystromformerConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30000) &#x2014;
Vocabulary size of the Nystromformer model. Defines the number of different tokens that can be represented
by the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerModel">NystromformerModel</a>.`,name:"vocab_size"},{anchor:"transformers.NystromformerConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimension of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.NystromformerConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.NystromformerConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.NystromformerConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.NystromformerConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.NystromformerConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.NystromformerConfig.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.NystromformerConfig.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.NystromformerConfig.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/main/en/model_doc/nystromformer#transformers.NystromformerModel">NystromformerModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.NystromformerConfig.segment_means_seq_len",description:`<strong>segment_means_seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Sequence length used in segment-means.`,name:"segment_means_seq_len"},{anchor:"transformers.NystromformerConfig.num_landmarks",description:`<strong>num_landmarks</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The number of landmark (or Nystrom) points to use in Nystrom approximation of the softmax self-attention
matrix.`,name:"num_landmarks"},{anchor:"transformers.NystromformerConfig.conv_kernel_size",description:`<strong>conv_kernel_size</strong> (<code>int</code>, <em>optional</em>, defaults to 65) &#x2014;
The kernel size of depthwise convolution used in Nystrom approximation.`,name:"conv_kernel_size"},{anchor:"transformers.NystromformerConfig.inv_coeff_init_option",description:`<strong>inv_coeff_init_option</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use exact coefficient computation for the initial values for the iterative method of
calculating the Moore-Penrose inverse of a matrix.`,name:"inv_coeff_init_option"},{anchor:"transformers.NystromformerConfig.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.NystromformerConfig.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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/configuration_nystromformer.py#L29"}}),pe=new Qe({props:{anchor:"transformers.NystromformerConfig.example",$$slots:{default:[Ka]},$$scope:{ctx:M}}}),Ze=new le({}),Xe=new E({props:{name:"class transformers.NystromformerModel",anchor:"transformers.NystromformerModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NystromformerModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerConfig">NystromformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L549"}}),to=new E({props:{name:"forward",anchor:"transformers.NystromformerModel.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:"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.NystromformerModel.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.NystromformerModel.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.NystromformerModel.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.NystromformerModel.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.NystromformerModel.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.NystromformerModel.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.NystromformerModel.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.NystromformerModel.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.NystromformerModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L574",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</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/main/en/model_doc/nystromformer#transformers.NystromformerConfig"
>NystromformerConfig</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>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 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>
<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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),he=new ot({props:{$$slots:{default:[Ya]},$$scope:{ctx:M}}}),ue=new Qe({props:{anchor:"transformers.NystromformerModel.forward.example",$$slots:{default:[Ja]},$$scope:{ctx:M}}}),no=new le({}),so=new E({props:{name:"class transformers.NystromformerForMaskedLM",anchor:"transformers.NystromformerForMaskedLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NystromformerForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerConfig">NystromformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L660"}}),ao=new E({props:{name:"forward",anchor:"transformers.NystromformerForMaskedLM.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.NystromformerForMaskedLM.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.NystromformerForMaskedLM.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.NystromformerForMaskedLM.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.NystromformerForMaskedLM.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.NystromformerForMaskedLM.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.NystromformerForMaskedLM.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.NystromformerForMaskedLM.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.NystromformerForMaskedLM.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.NystromformerForMaskedLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.NystromformerForMaskedLM.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/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L678",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/nystromformer#transformers.NystromformerConfig"
>NystromformerConfig</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/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),_e=new ot({props:{$$slots:{default:[Za]},$$scope:{ctx:M}}}),ye=new Qe({props:{anchor:"transformers.NystromformerForMaskedLM.forward.example",$$slots:{default:[Xa]},$$scope:{ctx:M}}}),io=new le({}),lo=new E({props:{name:"class transformers.NystromformerForSequenceClassification",anchor:"transformers.NystromformerForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NystromformerForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerConfig">NystromformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L765"}}),po=new E({props:{name:"forward",anchor:"transformers.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.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.NystromformerForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.NystromformerForSequenceClassification.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/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L775",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/nystromformer#transformers.NystromformerConfig"
>NystromformerConfig</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/main/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ke=new ot({props:{$$slots:{default:[ei]},$$scope:{ctx:M}}}),we=new Qe({props:{anchor:"transformers.NystromformerForSequenceClassification.forward.example",$$slots:{default:[oi]},$$scope:{ctx:M}}}),ve=new Qe({props:{anchor:"transformers.NystromformerForSequenceClassification.forward.example-2",$$slots:{default:[ti]},$$scope:{ctx:M}}}),fo=new le({}),ho=new E({props:{name:"class transformers.NystromformerForMultipleChoice",anchor:"transformers.NystromformerForMultipleChoice",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NystromformerForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerConfig">NystromformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L858"}}),_o=new E({props:{name:"forward",anchor:"transformers.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.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.NystromformerForMultipleChoice.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.NystromformerForMultipleChoice.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/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L869",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/nystromformer#transformers.NystromformerConfig"
>NystromformerConfig</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/main/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Te=new ot({props:{$$slots:{default:[ni]},$$scope:{ctx:M}}}),Ne=new Qe({props:{anchor:"transformers.NystromformerForMultipleChoice.forward.example",$$slots:{default:[si]},$$scope:{ctx:M}}}),yo=new le({}),bo=new E({props:{name:"class transformers.NystromformerForTokenClassification",anchor:"transformers.NystromformerForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NystromformerForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerConfig">NystromformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L953"}}),vo=new E({props:{name:"forward",anchor:"transformers.NystromformerForTokenClassification.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.NystromformerForTokenClassification.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.NystromformerForTokenClassification.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.NystromformerForTokenClassification.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.NystromformerForTokenClassification.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.NystromformerForTokenClassification.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.NystromformerForTokenClassification.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.NystromformerForTokenClassification.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.NystromformerForTokenClassification.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.NystromformerForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.NystromformerForTokenClassification.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/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L965",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/nystromformer#transformers.NystromformerConfig"
>NystromformerConfig</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/main/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Fe=new ot({props:{$$slots:{default:[ri]},$$scope:{ctx:M}}}),qe=new Qe({props:{anchor:"transformers.NystromformerForTokenClassification.forward.example",$$slots:{default:[ai]},$$scope:{ctx:M}}}),$o=new le({}),To=new E({props:{name:"class transformers.NystromformerForQuestionAnswering",anchor:"transformers.NystromformerForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NystromformerForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerConfig">NystromformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L1031"}}),Fo=new E({props:{name:"forward",anchor:"transformers.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.NystromformerForQuestionAnswering.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.NystromformerForQuestionAnswering.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/main/src/transformers/models/nystromformer/modeling_nystromformer.py#L1044",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/nystromformer#transformers.NystromformerConfig"
>NystromformerConfig</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/main/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),xe=new ot({props:{$$slots:{default:[ii]},$$scope:{ctx:M}}}),je=new Qe({props:{anchor:"transformers.NystromformerForQuestionAnswering.forward.example",$$slots:{default:[li]},$$scope:{ctx:M}}}),{c(){i=s("meta"),b=h(),p=s("h1"),m=s("a"),_=s("span"),k(n.$$.fragment),c=h(),F=s("span"),vn=l("Nystr\xF6mformer"),Bt=h(),H=s("h2"),de=s("a"),tt=s("span"),k(Ue.$$.fragment),$n=h(),nt=s("span"),Tn=l("Overview"),Ht=h(),ce=s("p"),Nn=l("The Nystr\xF6mformer model was proposed in "),Re=s("a"),st=s("em"),Mn=l("Nystr\xF6mformer: A Nystr\xF6m-Based Algorithm for Approximating Self-Attention"),Fn=l(` by Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn
Fung, Yin Li, and Vikas Singh.`),Ut=h(),jo=s("p"),qn=l("The abstract from the paper is the following:"),Rt=h(),Co=s("p"),rt=s("em"),zn=l(`Transformers have emerged as a powerful tool for a broad range of natural language processing tasks. A key component
that drives the impressive performance of Transformers is the self-attention mechanism that encodes the influence or
dependence of other tokens on each specific token. While beneficial, the quadratic complexity of self-attention on the
input sequence length has limited its application to longer sequences \u2014 a topic being actively studied in the
community. To address this limitation, we propose Nystr\xF6mformer \u2014 a model that exhibits favorable scalability as a
function of sequence length. Our idea is based on adapting the Nystr\xF6m method to approximate standard self-attention
with O(n) complexity. The scalability of Nystr\xF6mformer enables application to longer sequences with thousands of
tokens. We perform evaluations on multiple downstream tasks on the GLUE benchmark and IMDB reviews with standard
sequence length, and find that our Nystr\xF6mformer performs comparably, or in a few cases, even slightly better, than
standard self-attention. On longer sequence tasks in the Long Range Arena (LRA) benchmark, Nystr\xF6mformer performs
favorably relative to other efficient self-attention methods. Our code is available at this https URL.`),Vt=h(),Q=s("p"),xn=l("This model was contributed by "),Ve=s("a"),jn=l("novice03"),Cn=l(". The original code can be found "),Ge=s("a"),An=l("here"),En=l("."),Gt=h(),U=s("h2"),me=s("a"),at=s("span"),k(Ke.$$.fragment),Pn=h(),it=s("span"),On=l("NystromformerConfig"),Kt=h(),z=s("div"),k(Ye.$$.fragment),Sn=h(),R=s("p"),Ln=l("This is the configuration class to store the configuration of a "),Ao=s("a"),In=l("NystromformerModel"),Dn=l(`. It is used to instantiate
an Nystromformer 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 Nystromformer
`),Je=s("a"),Wn=l("uw-madison/nystromformer-512"),Qn=l(" architecture."),Bn=h(),V=s("p"),Hn=l("Configuration objects inherit from "),Eo=s("a"),Un=l("PretrainedConfig"),Rn=l(` and can be used to control the model outputs. Read the
documentation from `),Po=s("a"),Vn=l("PretrainedConfig"),Gn=l(" for more information."),Kn=h(),k(pe.$$.fragment),Yt=h(),G=s("h2"),fe=s("a"),lt=s("span"),k(Ze.$$.fragment),Yn=h(),dt=s("span"),Jn=l("NystromformerModel"),Jt=h(),D=s("div"),k(Xe.$$.fragment),Zn=h(),eo=s("p"),Xn=l(`The bare Nystr\xF6mformer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),oo=s("a"),es=l("torch.nn.Module"),os=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ts=h(),P=s("div"),k(to.$$.fragment),ns=h(),K=s("p"),ss=l("The "),Oo=s("a"),rs=l("NystromformerModel"),as=l(" forward method, overrides the "),ct=s("code"),is=l("__call__"),ls=l(" special method."),ds=h(),k(he.$$.fragment),cs=h(),k(ue.$$.fragment),Zt=h(),Y=s("h2"),ge=s("a"),mt=s("span"),k(no.$$.fragment),ms=h(),pt=s("span"),ps=l("NystromformerForMaskedLM"),Xt=h(),W=s("div"),k(so.$$.fragment),fs=h(),J=s("p"),hs=l("Nystr\xF6mformer Model with a "),ft=s("code"),us=l("language modeling"),gs=l(` head on top.
This model is a PyTorch `),ro=s("a"),_s=l("torch.nn.Module"),ys=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),bs=h(),O=s("div"),k(ao.$$.fragment),ks=h(),Z=s("p"),ws=l("The "),So=s("a"),vs=l("NystromformerForMaskedLM"),$s=l(" forward method, overrides the "),ht=s("code"),Ts=l("__call__"),Ns=l(" special method."),Ms=h(),k(_e.$$.fragment),Fs=h(),k(ye.$$.fragment),en=h(),X=s("h2"),be=s("a"),ut=s("span"),k(io.$$.fragment),qs=h(),gt=s("span"),zs=l("NystromformerForSequenceClassification"),on=h(),x=s("div"),k(lo.$$.fragment),xs=h(),_t=s("p"),js=l(`Nystr\xF6mformer Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),Cs=h(),co=s("p"),As=l("This model is a PyTorch "),mo=s("a"),Es=l("torch.nn.Module"),Ps=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Os=h(),q=s("div"),k(po.$$.fragment),Ss=h(),ee=s("p"),Ls=l("The "),Lo=s("a"),Is=l("NystromformerForSequenceClassification"),Ds=l(" forward method, overrides the "),yt=s("code"),Ws=l("__call__"),Qs=l(" special method."),Bs=h(),k(ke.$$.fragment),Hs=h(),k(we.$$.fragment),Us=h(),k(ve.$$.fragment),tn=h(),oe=s("h2"),$e=s("a"),bt=s("span"),k(fo.$$.fragment),Rs=h(),kt=s("span"),Vs=l("NystromformerForMultipleChoice"),nn=h(),j=s("div"),k(ho.$$.fragment),Gs=h(),wt=s("p"),Ks=l(`Nystr\xF6mformer 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.`),Ys=h(),uo=s("p"),Js=l("This model is a PyTorch "),go=s("a"),Zs=l("torch.nn.Module"),Xs=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),er=h(),S=s("div"),k(_o.$$.fragment),or=h(),te=s("p"),tr=l("The "),Io=s("a"),nr=l("NystromformerForMultipleChoice"),sr=l(" forward method, overrides the "),vt=s("code"),rr=l("__call__"),ar=l(" special method."),ir=h(),k(Te.$$.fragment),lr=h(),k(Ne.$$.fragment),sn=h(),ne=s("h2"),Me=s("a"),$t=s("span"),k(yo.$$.fragment),dr=h(),Tt=s("span"),cr=l("NystromformerForTokenClassification"),rn=h(),C=s("div"),k(bo.$$.fragment),mr=h(),Nt=s("p"),pr=l(`Nystr\xF6mformer 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.`),fr=h(),ko=s("p"),hr=l("This model is a PyTorch "),wo=s("a"),ur=l("torch.nn.Module"),gr=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),_r=h(),L=s("div"),k(vo.$$.fragment),yr=h(),se=s("p"),br=l("The "),Do=s("a"),kr=l("NystromformerForTokenClassification"),wr=l(" forward method, overrides the "),Mt=s("code"),vr=l("__call__"),$r=l(" special method."),Tr=h(),k(Fe.$$.fragment),Nr=h(),k(qe.$$.fragment),an=h(),re=s("h2"),ze=s("a"),Ft=s("span"),k($o.$$.fragment),Mr=h(),qt=s("span"),Fr=l("NystromformerForQuestionAnswering"),ln=h(),A=s("div"),k(To.$$.fragment),qr=h(),ae=s("p"),zr=l(`Nystr\xF6mformer 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 `),zt=s("code"),xr=l("span start logits"),jr=l(" and "),xt=s("code"),Cr=l("span end logits"),Ar=l(")."),Er=h(),No=s("p"),Pr=l("This model is a PyTorch "),Mo=s("a"),Or=l("torch.nn.Module"),Sr=l(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Lr=h(),I=s("div"),k(Fo.$$.fragment),Ir=h(),ie=s("p"),Dr=l("The "),Wo=s("a"),Wr=l("NystromformerForQuestionAnswering"),Qr=l(" forward method, overrides the "),jt=s("code"),Br=l("__call__"),Hr=l(" special method."),Ur=h(),k(xe.$$.fragment),Rr=h(),k(je.$$.fragment),this.h()},l(o){const g=Va('[data-svelte="svelte-1phssyn"]',document.head);i=r(g,"META",{name:!0,content:!0}),g.forEach(t),b=u(o),p=r(o,"H1",{class:!0});var qo=a(p);m=r(qo,"A",{id:!0,class:!0,href:!0});var Ct=a(m);_=r(Ct,"SPAN",{});var At=a(_);w(n.$$.fragment,At),At.forEach(t),Ct.forEach(t),c=u(qo),F=r(qo,"SPAN",{});var Et=a(F);vn=d(Et,"Nystr\xF6mformer"),Et.forEach(t),qo.forEach(t),Bt=u(o),H=r(o,"H2",{class:!0});var zo=a(H);de=r(zo,"A",{id:!0,class:!0,href:!0});var Pt=a(de);tt=r(Pt,"SPAN",{});var Ot=a(tt);w(Ue.$$.fragment,Ot),Ot.forEach(t),Pt.forEach(t),$n=u(zo),nt=r(zo,"SPAN",{});var St=a(nt);Tn=d(St,"Overview"),St.forEach(t),zo.forEach(t),Ht=u(o),ce=r(o,"P",{});var xo=a(ce);Nn=d(xo,"The Nystr\xF6mformer model was proposed in "),Re=r(xo,"A",{href:!0,rel:!0});var Lt=a(Re);st=r(Lt,"EM",{});var It=a(st);Mn=d(It,"Nystr\xF6mformer: A Nystr\xF6m-Based Algorithm for Approximating Self-Attention"),It.forEach(t),Lt.forEach(t),Fn=d(xo,` by Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn
Fung, Yin Li, and Vikas Singh.`),xo.forEach(t),Ut=u(o),jo=r(o,"P",{});var Dt=a(jo);qn=d(Dt,"The abstract from the paper is the following:"),Dt.forEach(t),Rt=u(o),Co=r(o,"P",{});var Wt=a(Co);rt=r(Wt,"EM",{});var Qt=a(rt);zn=d(Qt,`Transformers have emerged as a powerful tool for a broad range of natural language processing tasks. A key component
that drives the impressive performance of Transformers is the self-attention mechanism that encodes the influence or
dependence of other tokens on each specific token. While beneficial, the quadratic complexity of self-attention on the
input sequence length has limited its application to longer sequences \u2014 a topic being actively studied in the
community. To address this limitation, we propose Nystr\xF6mformer \u2014 a model that exhibits favorable scalability as a
function of sequence length. Our idea is based on adapting the Nystr\xF6m method to approximate standard self-attention
with O(n) complexity. The scalability of Nystr\xF6mformer enables application to longer sequences with thousands of
tokens. We perform evaluations on multiple downstream tasks on the GLUE benchmark and IMDB reviews with standard
sequence length, and find that our Nystr\xF6mformer performs comparably, or in a few cases, even slightly better, than
standard self-attention. On longer sequence tasks in the Long Range Arena (LRA) benchmark, Nystr\xF6mformer performs
favorably relative to other efficient self-attention methods. Our code is available at this https URL.`),Qt.forEach(t),Wt.forEach(t),Vt=u(o),Q=r(o,"P",{});var Qo=a(Q);xn=d(Qo,"This model was contributed by "),Ve=r(Qo,"A",{href:!0,rel:!0});var Vr=a(Ve);jn=d(Vr,"novice03"),Vr.forEach(t),Cn=d(Qo,". The original code can be found "),Ge=r(Qo,"A",{href:!0,rel:!0});var Gr=a(Ge);An=d(Gr,"here"),Gr.forEach(t),En=d(Qo,"."),Qo.forEach(t),Gt=u(o),U=r(o,"H2",{class:!0});var cn=a(U);me=r(cn,"A",{id:!0,class:!0,href:!0});var Kr=a(me);at=r(Kr,"SPAN",{});var Yr=a(at);w(Ke.$$.fragment,Yr),Yr.forEach(t),Kr.forEach(t),Pn=u(cn),it=r(cn,"SPAN",{});var Jr=a(it);On=d(Jr,"NystromformerConfig"),Jr.forEach(t),cn.forEach(t),Kt=u(o),z=r(o,"DIV",{class:!0});var Ce=a(z);w(Ye.$$.fragment,Ce),Sn=u(Ce),R=r(Ce,"P",{});var Bo=a(R);Ln=d(Bo,"This is the configuration class to store the configuration of a "),Ao=r(Bo,"A",{href:!0});var Zr=a(Ao);In=d(Zr,"NystromformerModel"),Zr.forEach(t),Dn=d(Bo,`. It is used to instantiate
an Nystromformer 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 Nystromformer
`),Je=r(Bo,"A",{href:!0,rel:!0});var Xr=a(Je);Wn=d(Xr,"uw-madison/nystromformer-512"),Xr.forEach(t),Qn=d(Bo," architecture."),Bo.forEach(t),Bn=u(Ce),V=r(Ce,"P",{});var Ho=a(V);Hn=d(Ho,"Configuration objects inherit from "),Eo=r(Ho,"A",{href:!0});var ea=a(Eo);Un=d(ea,"PretrainedConfig"),ea.forEach(t),Rn=d(Ho,` and can be used to control the model outputs. Read the
documentation from `),Po=r(Ho,"A",{href:!0});var oa=a(Po);Vn=d(oa,"PretrainedConfig"),oa.forEach(t),Gn=d(Ho," for more information."),Ho.forEach(t),Kn=u(Ce),w(pe.$$.fragment,Ce),Ce.forEach(t),Yt=u(o),G=r(o,"H2",{class:!0});var mn=a(G);fe=r(mn,"A",{id:!0,class:!0,href:!0});var ta=a(fe);lt=r(ta,"SPAN",{});var na=a(lt);w(Ze.$$.fragment,na),na.forEach(t),ta.forEach(t),Yn=u(mn),dt=r(mn,"SPAN",{});var sa=a(dt);Jn=d(sa,"NystromformerModel"),sa.forEach(t),mn.forEach(t),Jt=u(o),D=r(o,"DIV",{class:!0});var Uo=a(D);w(Xe.$$.fragment,Uo),Zn=u(Uo),eo=r(Uo,"P",{});var pn=a(eo);Xn=d(pn,`The bare Nystr\xF6mformer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),oo=r(pn,"A",{href:!0,rel:!0});var ra=a(oo);es=d(ra,"torch.nn.Module"),ra.forEach(t),os=d(pn,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),pn.forEach(t),ts=u(Uo),P=r(Uo,"DIV",{class:!0});var Ae=a(P);w(to.$$.fragment,Ae),ns=u(Ae),K=r(Ae,"P",{});var Ro=a(K);ss=d(Ro,"The "),Oo=r(Ro,"A",{href:!0});var aa=a(Oo);rs=d(aa,"NystromformerModel"),aa.forEach(t),as=d(Ro," forward method, overrides the "),ct=r(Ro,"CODE",{});var ia=a(ct);is=d(ia,"__call__"),ia.forEach(t),ls=d(Ro," special method."),Ro.forEach(t),ds=u(Ae),w(he.$$.fragment,Ae),cs=u(Ae),w(ue.$$.fragment,Ae),Ae.forEach(t),Uo.forEach(t),Zt=u(o),Y=r(o,"H2",{class:!0});var fn=a(Y);ge=r(fn,"A",{id:!0,class:!0,href:!0});var la=a(ge);mt=r(la,"SPAN",{});var da=a(mt);w(no.$$.fragment,da),da.forEach(t),la.forEach(t),ms=u(fn),pt=r(fn,"SPAN",{});var ca=a(pt);ps=d(ca,"NystromformerForMaskedLM"),ca.forEach(t),fn.forEach(t),Xt=u(o),W=r(o,"DIV",{class:!0});var Vo=a(W);w(so.$$.fragment,Vo),fs=u(Vo),J=r(Vo,"P",{});var Go=a(J);hs=d(Go,"Nystr\xF6mformer Model with a "),ft=r(Go,"CODE",{});var ma=a(ft);us=d(ma,"language modeling"),ma.forEach(t),gs=d(Go,` head on top.
This model is a PyTorch `),ro=r(Go,"A",{href:!0,rel:!0});var pa=a(ro);_s=d(pa,"torch.nn.Module"),pa.forEach(t),ys=d(Go,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Go.forEach(t),bs=u(Vo),O=r(Vo,"DIV",{class:!0});var Ee=a(O);w(ao.$$.fragment,Ee),ks=u(Ee),Z=r(Ee,"P",{});var Ko=a(Z);ws=d(Ko,"The "),So=r(Ko,"A",{href:!0});var fa=a(So);vs=d(fa,"NystromformerForMaskedLM"),fa.forEach(t),$s=d(Ko," forward method, overrides the "),ht=r(Ko,"CODE",{});var ha=a(ht);Ts=d(ha,"__call__"),ha.forEach(t),Ns=d(Ko," special method."),Ko.forEach(t),Ms=u(Ee),w(_e.$$.fragment,Ee),Fs=u(Ee),w(ye.$$.fragment,Ee),Ee.forEach(t),Vo.forEach(t),en=u(o),X=r(o,"H2",{class:!0});var hn=a(X);be=r(hn,"A",{id:!0,class:!0,href:!0});var ua=a(be);ut=r(ua,"SPAN",{});var ga=a(ut);w(io.$$.fragment,ga),ga.forEach(t),ua.forEach(t),qs=u(hn),gt=r(hn,"SPAN",{});var _a=a(gt);zs=d(_a,"NystromformerForSequenceClassification"),_a.forEach(t),hn.forEach(t),on=u(o),x=r(o,"DIV",{class:!0});var Pe=a(x);w(lo.$$.fragment,Pe),xs=u(Pe),_t=r(Pe,"P",{});var ya=a(_t);js=d(ya,`Nystr\xF6mformer Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),ya.forEach(t),Cs=u(Pe),co=r(Pe,"P",{});var un=a(co);As=d(un,"This model is a PyTorch "),mo=r(un,"A",{href:!0,rel:!0});var ba=a(mo);Es=d(ba,"torch.nn.Module"),ba.forEach(t),Ps=d(un,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),un.forEach(t),Os=u(Pe),q=r(Pe,"DIV",{class:!0});var B=a(q);w(po.$$.fragment,B),Ss=u(B),ee=r(B,"P",{});var Yo=a(ee);Ls=d(Yo,"The "),Lo=r(Yo,"A",{href:!0});var ka=a(Lo);Is=d(ka,"NystromformerForSequenceClassification"),ka.forEach(t),Ds=d(Yo," forward method, overrides the "),yt=r(Yo,"CODE",{});var wa=a(yt);Ws=d(wa,"__call__"),wa.forEach(t),Qs=d(Yo," special method."),Yo.forEach(t),Bs=u(B),w(ke.$$.fragment,B),Hs=u(B),w(we.$$.fragment,B),Us=u(B),w(ve.$$.fragment,B),B.forEach(t),Pe.forEach(t),tn=u(o),oe=r(o,"H2",{class:!0});var gn=a(oe);$e=r(gn,"A",{id:!0,class:!0,href:!0});var va=a($e);bt=r(va,"SPAN",{});var $a=a(bt);w(fo.$$.fragment,$a),$a.forEach(t),va.forEach(t),Rs=u(gn),kt=r(gn,"SPAN",{});var Ta=a(kt);Vs=d(Ta,"NystromformerForMultipleChoice"),Ta.forEach(t),gn.forEach(t),nn=u(o),j=r(o,"DIV",{class:!0});var Oe=a(j);w(ho.$$.fragment,Oe),Gs=u(Oe),wt=r(Oe,"P",{});var Na=a(wt);Ks=d(Na,`Nystr\xF6mformer 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.`),Na.forEach(t),Ys=u(Oe),uo=r(Oe,"P",{});var _n=a(uo);Js=d(_n,"This model is a PyTorch "),go=r(_n,"A",{href:!0,rel:!0});var Ma=a(go);Zs=d(Ma,"torch.nn.Module"),Ma.forEach(t),Xs=d(_n,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),_n.forEach(t),er=u(Oe),S=r(Oe,"DIV",{class:!0});var Se=a(S);w(_o.$$.fragment,Se),or=u(Se),te=r(Se,"P",{});var Jo=a(te);tr=d(Jo,"The "),Io=r(Jo,"A",{href:!0});var Fa=a(Io);nr=d(Fa,"NystromformerForMultipleChoice"),Fa.forEach(t),sr=d(Jo," forward method, overrides the "),vt=r(Jo,"CODE",{});var qa=a(vt);rr=d(qa,"__call__"),qa.forEach(t),ar=d(Jo," special method."),Jo.forEach(t),ir=u(Se),w(Te.$$.fragment,Se),lr=u(Se),w(Ne.$$.fragment,Se),Se.forEach(t),Oe.forEach(t),sn=u(o),ne=r(o,"H2",{class:!0});var yn=a(ne);Me=r(yn,"A",{id:!0,class:!0,href:!0});var za=a(Me);$t=r(za,"SPAN",{});var xa=a($t);w(yo.$$.fragment,xa),xa.forEach(t),za.forEach(t),dr=u(yn),Tt=r(yn,"SPAN",{});var ja=a(Tt);cr=d(ja,"NystromformerForTokenClassification"),ja.forEach(t),yn.forEach(t),rn=u(o),C=r(o,"DIV",{class:!0});var Le=a(C);w(bo.$$.fragment,Le),mr=u(Le),Nt=r(Le,"P",{});var Ca=a(Nt);pr=d(Ca,`Nystr\xF6mformer 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.`),Ca.forEach(t),fr=u(Le),ko=r(Le,"P",{});var bn=a(ko);hr=d(bn,"This model is a PyTorch "),wo=r(bn,"A",{href:!0,rel:!0});var Aa=a(wo);ur=d(Aa,"torch.nn.Module"),Aa.forEach(t),gr=d(bn,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),bn.forEach(t),_r=u(Le),L=r(Le,"DIV",{class:!0});var Ie=a(L);w(vo.$$.fragment,Ie),yr=u(Ie),se=r(Ie,"P",{});var Zo=a(se);br=d(Zo,"The "),Do=r(Zo,"A",{href:!0});var Ea=a(Do);kr=d(Ea,"NystromformerForTokenClassification"),Ea.forEach(t),wr=d(Zo," forward method, overrides the "),Mt=r(Zo,"CODE",{});var Pa=a(Mt);vr=d(Pa,"__call__"),Pa.forEach(t),$r=d(Zo," special method."),Zo.forEach(t),Tr=u(Ie),w(Fe.$$.fragment,Ie),Nr=u(Ie),w(qe.$$.fragment,Ie),Ie.forEach(t),Le.forEach(t),an=u(o),re=r(o,"H2",{class:!0});var kn=a(re);ze=r(kn,"A",{id:!0,class:!0,href:!0});var Oa=a(ze);Ft=r(Oa,"SPAN",{});var Sa=a(Ft);w($o.$$.fragment,Sa),Sa.forEach(t),Oa.forEach(t),Mr=u(kn),qt=r(kn,"SPAN",{});var La=a(qt);Fr=d(La,"NystromformerForQuestionAnswering"),La.forEach(t),kn.forEach(t),ln=u(o),A=r(o,"DIV",{class:!0});var De=a(A);w(To.$$.fragment,De),qr=u(De),ae=r(De,"P",{});var Xo=a(ae);zr=d(Xo,`Nystr\xF6mformer 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 `),zt=r(Xo,"CODE",{});var Ia=a(zt);xr=d(Ia,"span start logits"),Ia.forEach(t),jr=d(Xo," and "),xt=r(Xo,"CODE",{});var Da=a(xt);Cr=d(Da,"span end logits"),Da.forEach(t),Ar=d(Xo,")."),Xo.forEach(t),Er=u(De),No=r(De,"P",{});var wn=a(No);Pr=d(wn,"This model is a PyTorch "),Mo=r(wn,"A",{href:!0,rel:!0});var Wa=a(Mo);Or=d(Wa,"torch.nn.Module"),Wa.forEach(t),Sr=d(wn,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),wn.forEach(t),Lr=u(De),I=r(De,"DIV",{class:!0});var We=a(I);w(Fo.$$.fragment,We),Ir=u(We),ie=r(We,"P",{});var et=a(ie);Dr=d(et,"The "),Wo=r(et,"A",{href:!0});var Qa=a(Wo);Wr=d(Qa,"NystromformerForQuestionAnswering"),Qa.forEach(t),Qr=d(et," forward method, overrides the "),jt=r(et,"CODE",{});var Ba=a(jt);Br=d(Ba,"__call__"),Ba.forEach(t),Hr=d(et," special method."),et.forEach(t),Ur=u(We),w(xe.$$.fragment,We),Rr=u(We),w(je.$$.fragment,We),We.forEach(t),De.forEach(t),this.h()},h(){f(i,"name","hf:doc:metadata"),f(i,"content",JSON.stringify(ci)),f(m,"id","nystrmformer"),f(m,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(m,"href","#nystrmformer"),f(p,"class","relative group"),f(de,"id","overview"),f(de,"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"),f(de,"href","#overview"),f(H,"class","relative group"),f(Re,"href","https://arxiv.org/abs/2102.03902"),f(Re,"rel","nofollow"),f(Ve,"href","https://huggingface.co/novice03"),f(Ve,"rel","nofollow"),f(Ge,"href","https://github.com/mlpen/Nystromformer"),f(Ge,"rel","nofollow"),f(me,"id","transformers.NystromformerConfig"),f(me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(me,"href","#transformers.NystromformerConfig"),f(U,"class","relative group"),f(Ao,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerModel"),f(Je,"href","https://huggingface.co/uw-madison/nystromformer-512"),f(Je,"rel","nofollow"),f(Eo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),f(Po,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),f(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(fe,"id","transformers.NystromformerModel"),f(fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(fe,"href","#transformers.NystromformerModel"),f(G,"class","relative group"),f(oo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),f(oo,"rel","nofollow"),f(Oo,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerModel"),f(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ge,"id","transformers.NystromformerForMaskedLM"),f(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(ge,"href","#transformers.NystromformerForMaskedLM"),f(Y,"class","relative group"),f(ro,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),f(ro,"rel","nofollow"),f(So,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerForMaskedLM"),f(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(be,"id","transformers.NystromformerForSequenceClassification"),f(be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(be,"href","#transformers.NystromformerForSequenceClassification"),f(X,"class","relative group"),f(mo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),f(mo,"rel","nofollow"),f(Lo,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerForSequenceClassification"),f(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f($e,"id","transformers.NystromformerForMultipleChoice"),f($e,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f($e,"href","#transformers.NystromformerForMultipleChoice"),f(oe,"class","relative group"),f(go,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),f(go,"rel","nofollow"),f(Io,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerForMultipleChoice"),f(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Me,"id","transformers.NystromformerForTokenClassification"),f(Me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(Me,"href","#transformers.NystromformerForTokenClassification"),f(ne,"class","relative group"),f(wo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),f(wo,"rel","nofollow"),f(Do,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerForTokenClassification"),f(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ze,"id","transformers.NystromformerForQuestionAnswering"),f(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(ze,"href","#transformers.NystromformerForQuestionAnswering"),f(re,"class","relative group"),f(Mo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),f(Mo,"rel","nofollow"),f(Wo,"href","/docs/transformers/main/en/model_doc/nystromformer#transformers.NystromformerForQuestionAnswering"),f(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(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(o,g){e(document.head,i),y(o,b,g),y(o,p,g),e(p,m),e(m,_),v(n,_,null),e(p,c),e(p,F),e(F,vn),y(o,Bt,g),y(o,H,g),e(H,de),e(de,tt),v(Ue,tt,null),e(H,$n),e(H,nt),e(nt,Tn),y(o,Ht,g),y(o,ce,g),e(ce,Nn),e(ce,Re),e(Re,st),e(st,Mn),e(ce,Fn),y(o,Ut,g),y(o,jo,g),e(jo,qn),y(o,Rt,g),y(o,Co,g),e(Co,rt),e(rt,zn),y(o,Vt,g),y(o,Q,g),e(Q,xn),e(Q,Ve),e(Ve,jn),e(Q,Cn),e(Q,Ge),e(Ge,An),e(Q,En),y(o,Gt,g),y(o,U,g),e(U,me),e(me,at),v(Ke,at,null),e(U,Pn),e(U,it),e(it,On),y(o,Kt,g),y(o,z,g),v(Ye,z,null),e(z,Sn),e(z,R),e(R,Ln),e(R,Ao),e(Ao,In),e(R,Dn),e(R,Je),e(Je,Wn),e(R,Qn),e(z,Bn),e(z,V),e(V,Hn),e(V,Eo),e(Eo,Un),e(V,Rn),e(V,Po),e(Po,Vn),e(V,Gn),e(z,Kn),v(pe,z,null),y(o,Yt,g),y(o,G,g),e(G,fe),e(fe,lt),v(Ze,lt,null),e(G,Yn),e(G,dt),e(dt,Jn),y(o,Jt,g),y(o,D,g),v(Xe,D,null),e(D,Zn),e(D,eo),e(eo,Xn),e(eo,oo),e(oo,es),e(eo,os),e(D,ts),e(D,P),v(to,P,null),e(P,ns),e(P,K),e(K,ss),e(K,Oo),e(Oo,rs),e(K,as),e(K,ct),e(ct,is),e(K,ls),e(P,ds),v(he,P,null),e(P,cs),v(ue,P,null),y(o,Zt,g),y(o,Y,g),e(Y,ge),e(ge,mt),v(no,mt,null),e(Y,ms),e(Y,pt),e(pt,ps),y(o,Xt,g),y(o,W,g),v(so,W,null),e(W,fs),e(W,J),e(J,hs),e(J,ft),e(ft,us),e(J,gs),e(J,ro),e(ro,_s),e(J,ys),e(W,bs),e(W,O),v(ao,O,null),e(O,ks),e(O,Z),e(Z,ws),e(Z,So),e(So,vs),e(Z,$s),e(Z,ht),e(ht,Ts),e(Z,Ns),e(O,Ms),v(_e,O,null),e(O,Fs),v(ye,O,null),y(o,en,g),y(o,X,g),e(X,be),e(be,ut),v(io,ut,null),e(X,qs),e(X,gt),e(gt,zs),y(o,on,g),y(o,x,g),v(lo,x,null),e(x,xs),e(x,_t),e(_t,js),e(x,Cs),e(x,co),e(co,As),e(co,mo),e(mo,Es),e(co,Ps),e(x,Os),e(x,q),v(po,q,null),e(q,Ss),e(q,ee),e(ee,Ls),e(ee,Lo),e(Lo,Is),e(ee,Ds),e(ee,yt),e(yt,Ws),e(ee,Qs),e(q,Bs),v(ke,q,null),e(q,Hs),v(we,q,null),e(q,Us),v(ve,q,null),y(o,tn,g),y(o,oe,g),e(oe,$e),e($e,bt),v(fo,bt,null),e(oe,Rs),e(oe,kt),e(kt,Vs),y(o,nn,g),y(o,j,g),v(ho,j,null),e(j,Gs),e(j,wt),e(wt,Ks),e(j,Ys),e(j,uo),e(uo,Js),e(uo,go),e(go,Zs),e(uo,Xs),e(j,er),e(j,S),v(_o,S,null),e(S,or),e(S,te),e(te,tr),e(te,Io),e(Io,nr),e(te,sr),e(te,vt),e(vt,rr),e(te,ar),e(S,ir),v(Te,S,null),e(S,lr),v(Ne,S,null),y(o,sn,g),y(o,ne,g),e(ne,Me),e(Me,$t),v(yo,$t,null),e(ne,dr),e(ne,Tt),e(Tt,cr),y(o,rn,g),y(o,C,g),v(bo,C,null),e(C,mr),e(C,Nt),e(Nt,pr),e(C,fr),e(C,ko),e(ko,hr),e(ko,wo),e(wo,ur),e(ko,gr),e(C,_r),e(C,L),v(vo,L,null),e(L,yr),e(L,se),e(se,br),e(se,Do),e(Do,kr),e(se,wr),e(se,Mt),e(Mt,vr),e(se,$r),e(L,Tr),v(Fe,L,null),e(L,Nr),v(qe,L,null),y(o,an,g),y(o,re,g),e(re,ze),e(ze,Ft),v($o,Ft,null),e(re,Mr),e(re,qt),e(qt,Fr),y(o,ln,g),y(o,A,g),v(To,A,null),e(A,qr),e(A,ae),e(ae,zr),e(ae,zt),e(zt,xr),e(ae,jr),e(ae,xt),e(xt,Cr),e(ae,Ar),e(A,Er),e(A,No),e(No,Pr),e(No,Mo),e(Mo,Or),e(No,Sr),e(A,Lr),e(A,I),v(Fo,I,null),e(I,Ir),e(I,ie),e(ie,Dr),e(ie,Wo),e(Wo,Wr),e(ie,Qr),e(ie,jt),e(jt,Br),e(ie,Hr),e(I,Ur),v(xe,I,null),e(I,Rr),v(je,I,null),dn=!0},p(o,[g]){const qo={};g&2&&(qo.$$scope={dirty:g,ctx:o}),pe.$set(qo);const Ct={};g&2&&(Ct.$$scope={dirty:g,ctx:o}),he.$set(Ct);const At={};g&2&&(At.$$scope={dirty:g,ctx:o}),ue.$set(At);const Et={};g&2&&(Et.$$scope={dirty:g,ctx:o}),_e.$set(Et);const zo={};g&2&&(zo.$$scope={dirty:g,ctx:o}),ye.$set(zo);const Pt={};g&2&&(Pt.$$scope={dirty:g,ctx:o}),ke.$set(Pt);const Ot={};g&2&&(Ot.$$scope={dirty:g,ctx:o}),we.$set(Ot);const St={};g&2&&(St.$$scope={dirty:g,ctx:o}),ve.$set(St);const xo={};g&2&&(xo.$$scope={dirty:g,ctx:o}),Te.$set(xo);const Lt={};g&2&&(Lt.$$scope={dirty:g,ctx:o}),Ne.$set(Lt);const It={};g&2&&(It.$$scope={dirty:g,ctx:o}),Fe.$set(It);const Dt={};g&2&&(Dt.$$scope={dirty:g,ctx:o}),qe.$set(Dt);const Wt={};g&2&&(Wt.$$scope={dirty:g,ctx:o}),xe.$set(Wt);const Qt={};g&2&&(Qt.$$scope={dirty:g,ctx:o}),je.$set(Qt)},i(o){dn||($(n.$$.fragment,o),$(Ue.$$.fragment,o),$(Ke.$$.fragment,o),$(Ye.$$.fragment,o),$(pe.$$.fragment,o),$(Ze.$$.fragment,o),$(Xe.$$.fragment,o),$(to.$$.fragment,o),$(he.$$.fragment,o),$(ue.$$.fragment,o),$(no.$$.fragment,o),$(so.$$.fragment,o),$(ao.$$.fragment,o),$(_e.$$.fragment,o),$(ye.$$.fragment,o),$(io.$$.fragment,o),$(lo.$$.fragment,o),$(po.$$.fragment,o),$(ke.$$.fragment,o),$(we.$$.fragment,o),$(ve.$$.fragment,o),$(fo.$$.fragment,o),$(ho.$$.fragment,o),$(_o.$$.fragment,o),$(Te.$$.fragment,o),$(Ne.$$.fragment,o),$(yo.$$.fragment,o),$(bo.$$.fragment,o),$(vo.$$.fragment,o),$(Fe.$$.fragment,o),$(qe.$$.fragment,o),$($o.$$.fragment,o),$(To.$$.fragment,o),$(Fo.$$.fragment,o),$(xe.$$.fragment,o),$(je.$$.fragment,o),dn=!0)},o(o){T(n.$$.fragment,o),T(Ue.$$.fragment,o),T(Ke.$$.fragment,o),T(Ye.$$.fragment,o),T(pe.$$.fragment,o),T(Ze.$$.fragment,o),T(Xe.$$.fragment,o),T(to.$$.fragment,o),T(he.$$.fragment,o),T(ue.$$.fragment,o),T(no.$$.fragment,o),T(so.$$.fragment,o),T(ao.$$.fragment,o),T(_e.$$.fragment,o),T(ye.$$.fragment,o),T(io.$$.fragment,o),T(lo.$$.fragment,o),T(po.$$.fragment,o),T(ke.$$.fragment,o),T(we.$$.fragment,o),T(ve.$$.fragment,o),T(fo.$$.fragment,o),T(ho.$$.fragment,o),T(_o.$$.fragment,o),T(Te.$$.fragment,o),T(Ne.$$.fragment,o),T(yo.$$.fragment,o),T(bo.$$.fragment,o),T(vo.$$.fragment,o),T(Fe.$$.fragment,o),T(qe.$$.fragment,o),T($o.$$.fragment,o),T(To.$$.fragment,o),T(Fo.$$.fragment,o),T(xe.$$.fragment,o),T(je.$$.fragment,o),dn=!1},d(o){t(i),o&&t(b),o&&t(p),N(n),o&&t(Bt),o&&t(H),N(Ue),o&&t(Ht),o&&t(ce),o&&t(Ut),o&&t(jo),o&&t(Rt),o&&t(Co),o&&t(Vt),o&&t(Q),o&&t(Gt),o&&t(U),N(Ke),o&&t(Kt),o&&t(z),N(Ye),N(pe),o&&t(Yt),o&&t(G),N(Ze),o&&t(Jt),o&&t(D),N(Xe),N(to),N(he),N(ue),o&&t(Zt),o&&t(Y),N(no),o&&t(Xt),o&&t(W),N(so),N(ao),N(_e),N(ye),o&&t(en),o&&t(X),N(io),o&&t(on),o&&t(x),N(lo),N(po),N(ke),N(we),N(ve),o&&t(tn),o&&t(oe),N(fo),o&&t(nn),o&&t(j),N(ho),N(_o),N(Te),N(Ne),o&&t(sn),o&&t(ne),N(yo),o&&t(rn),o&&t(C),N(bo),N(vo),N(Fe),N(qe),o&&t(an),o&&t(re),N($o),o&&t(ln),o&&t(A),N(To),N(Fo),N(xe),N(je)}}}const ci={local:"nystrmformer",sections:[{local:"overview",title:"Overview"},{local:"transformers.NystromformerConfig",title:"NystromformerConfig"},{local:"transformers.NystromformerModel",title:"NystromformerModel"},{local:"transformers.NystromformerForMaskedLM",title:"NystromformerForMaskedLM"},{local:"transformers.NystromformerForSequenceClassification",title:"NystromformerForSequenceClassification"},{local:"transformers.NystromformerForMultipleChoice",title:"NystromformerForMultipleChoice"},{local:"transformers.NystromformerForTokenClassification",title:"NystromformerForTokenClassification"},{local:"transformers.NystromformerForQuestionAnswering",title:"NystromformerForQuestionAnswering"}],title:"Nystr\xF6mformer"};function mi(M){return Ga(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yi extends Ha{constructor(i){super();Ua(this,i,mi,di,Ra,{})}}export{yi as default,ci as metadata};
