import{S as Sn,i as zn,s as Fn,e as s,k as f,w as N,t as a,M as On,c as r,d as o,m,a as i,x as $,h as n,b as d,N as Dn,G as e,g as p,y,q as T,o as A,B as E,v as Ln,L as Da}from"../../chunks/vendor-hf-doc-builder.js";import{T as qn}from"../../chunks/Tip-hf-doc-builder.js";import{D as wt}from"../../chunks/Docstring-hf-doc-builder.js";import{C as La}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Nt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Oa}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Wn(I){let h,b,_,u,v;return u=new La({props:{code:`from transformers import NatConfig, NatModel

# Initializing a Nat shi-labs/nat-mini-in1k-224 style configuration
configuration = NatConfig()

# Initializing a model (with random weights) from the shi-labs/nat-mini-in1k-224 style configuration
model = NatModel(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> NatConfig, NatModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Nat shi-labs/nat-mini-in1k-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = NatConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the shi-labs/nat-mini-in1k-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NatModel(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(){h=s("p"),b=a("Example:"),_=f(),N(u.$$.fragment)},l(l){h=r(l,"P",{});var g=i(h);b=n(g,"Example:"),g.forEach(o),_=m(l),$(u.$$.fragment,l)},m(l,g){p(l,h,g),e(h,b),p(l,_,g),y(u,l,g),v=!0},p:Da,i(l){v||(T(u.$$.fragment,l),v=!0)},o(l){A(u.$$.fragment,l),v=!1},d(l){l&&o(h),l&&o(_),E(u,l)}}}function Hn(I){let h,b,_,u,v;return{c(){h=s("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s("code"),u=a("Module"),v=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=r(l,"P",{});var g=i(h);b=n(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(g,"CODE",{});var M=i(_);u=n(M,"Module"),M.forEach(o),v=n(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(o)},m(l,g){p(l,h,g),e(h,b),e(h,_),e(_,u),e(h,v)},d(l){l&&o(h)}}}function Un(I){let h,b,_,u,v;return u=new La({props:{code:`from transformers import AutoImageProcessor, NatModel
import torch
from datasets import load_dataset

dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0]

feature_extractor = AutoImageProcessor.from_pretrained("shi-labs/nat-mini-in1k-224")
model = NatModel.from_pretrained("shi-labs/nat-mini-in1k-224")

inputs = feature_extractor(image, return_tensors="pt")

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

last_hidden_states = outputs.last_hidden_state
list(last_hidden_states.shape)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, NatModel
<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> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;shi-labs/nat-mini-in1k-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NatModel.from_pretrained(<span class="hljs-string">&quot;shi-labs/nat-mini-in1k-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = feature_extractor(image, 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>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">7</span>, <span class="hljs-number">7</span>, <span class="hljs-number">512</span>]`}}),{c(){h=s("p"),b=a("Example:"),_=f(),N(u.$$.fragment)},l(l){h=r(l,"P",{});var g=i(h);b=n(g,"Example:"),g.forEach(o),_=m(l),$(u.$$.fragment,l)},m(l,g){p(l,h,g),e(h,b),p(l,_,g),y(u,l,g),v=!0},p:Da,i(l){v||(T(u.$$.fragment,l),v=!0)},o(l){A(u.$$.fragment,l),v=!1},d(l){l&&o(h),l&&o(_),E(u,l)}}}function Vn(I){let h,b,_,u,v;return{c(){h=s("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s("code"),u=a("Module"),v=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=r(l,"P",{});var g=i(h);b=n(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(g,"CODE",{});var M=i(_);u=n(M,"Module"),M.forEach(o),v=n(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(o)},m(l,g){p(l,h,g),e(h,b),e(h,_),e(_,u),e(h,v)},d(l){l&&o(h)}}}function Kn(I){let h,b,_,u,v;return u=new La({props:{code:`from transformers import AutoImageProcessor, NatForImageClassification
import torch
from datasets import load_dataset

dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0]

feature_extractor = AutoImageProcessor.from_pretrained("shi-labs/nat-mini-in1k-224")
model = NatForImageClassification.from_pretrained("shi-labs/nat-mini-in1k-224")

inputs = feature_extractor(image, return_tensors="pt")

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

# model predicts one of the 1000 ImageNet classes
predicted_label = logits.argmax(-1).item()
print(model.config.id2label[predicted_label])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, NatForImageClassification
<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> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;shi-labs/nat-mini-in1k-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = NatForImageClassification.from_pretrained(<span class="hljs-string">&quot;shi-labs/nat-mini-in1k-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = feature_extractor(image, 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"># model predicts one of the 1000 ImageNet classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model.config.id2label[predicted_label])
tiger cat`}}),{c(){h=s("p"),b=a("Example:"),_=f(),N(u.$$.fragment)},l(l){h=r(l,"P",{});var g=i(h);b=n(g,"Example:"),g.forEach(o),_=m(l),$(u.$$.fragment,l)},m(l,g){p(l,h,g),e(h,b),p(l,_,g),y(u,l,g),v=!0},p:Da,i(l){v||(T(u.$$.fragment,l),v=!0)},o(l){A(u.$$.fragment,l),v=!1},d(l){l&&o(h),l&&o(_),E(u,l)}}}function Rn(I){let h,b,_,u,v,l,g,M,Qt,$t,F,K,Ye,ce,Xt,Qe,Zt,yt,R,eo,he,to,oo,Tt,je,ao,At,Me,no,Et,qe,Xe,so,Ct,Se,ro,xt,B,pe,io,ze,lo,co,ho,w,po,Ze,fo,mo,et,uo,go,tt,_o,vo,ot,bo,wo,at,No,$o,nt,yo,To,st,Ao,Eo,kt,Fe,Co,It,J,q,xo,fe,ko,Io,me,Po,jo,rt,Mo,qo,So,it,zo,Pt,G,Wa,jt,Y,Fo,Oe,Oo,Do,Mt,z,Lo,ue,Wo,Ho,ge,Uo,Vo,qt,O,Q,lt,_e,Ko,dt,Ro,St,x,ve,Bo,D,Jo,De,Go,Yo,be,Qo,Xo,Zo,L,ea,Le,ta,oa,We,aa,na,sa,X,zt,W,Z,ct,we,ra,ht,ia,Ft,S,Ne,la,$e,da,ye,ca,ha,pa,P,Te,fa,H,ma,He,ua,ga,pt,_a,va,ba,ee,wa,te,Ot,U,oe,ft,Ae,Na,mt,$a,Dt,k,Ee,ya,ut,Ta,Aa,Ce,Ea,xe,Ca,xa,ka,j,ke,Ia,V,Pa,Ue,ja,Ma,gt,qa,Sa,za,ae,Fa,ne,Lt;return l=new Nt({}),ce=new Nt({}),_e=new Nt({}),ve=new wt({props:{name:"class transformers.NatConfig",anchor:"transformers.NatConfig",parameters:[{name:"patch_size",val:" = 4"},{name:"num_channels",val:" = 3"},{name:"embed_dim",val:" = 64"},{name:"depths",val:" = [3, 4, 6, 5]"},{name:"num_heads",val:" = [2, 4, 8, 16]"},{name:"kernel_size",val:" = 7"},{name:"mlp_ratio",val:" = 3.0"},{name:"qkv_bias",val:" = True"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"drop_path_rate",val:" = 0.1"},{name:"hidden_act",val:" = 'gelu'"},{name:"patch_norm",val:" = True"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"layer_scale_init_value",val:" = 0.0"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.NatConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The size (resolution) of each patch. NOTE: Only patch size of 4 is supported at the moment.`,name:"patch_size"},{anchor:"transformers.NatConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of input channels.`,name:"num_channels"},{anchor:"transformers.NatConfig.embed_dim",description:`<strong>embed_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Dimensionality of patch embedding.`,name:"embed_dim"},{anchor:"transformers.NatConfig.depths",description:`<strong>depths</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[2, 2, 6, 2]</code>) &#x2014;
Number of layers in each level of the encoder.`,name:"depths"},{anchor:"transformers.NatConfig.num_heads",description:`<strong>num_heads</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[3, 6, 12, 24]</code>) &#x2014;
Number of attention heads in each layer of the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.NatConfig.kernel_size",description:`<strong>kernel_size</strong> (<code>int</code>, <em>optional</em>, defaults to 7) &#x2014;
Neighborhood Attention kernel size.`,name:"kernel_size"},{anchor:"transformers.NatConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 3.0) &#x2014;
Ratio of MLP hidden dimensionality to embedding dimensionality.`,name:"mlp_ratio"},{anchor:"transformers.NatConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not a learnable bias should be added to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.NatConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for all fully connected layers in the embeddings and encoder.`,name:"hidden_dropout_prob"},{anchor:"transformers.NatConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.NatConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Stochastic depth rate.`,name:"drop_path_rate"},{anchor:"transformers.NatConfig.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. 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.NatConfig.patch_norm",description:`<strong>patch_norm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to add layer normalization after patch embedding.`,name:"patch_norm"},{anchor:"transformers.NatConfig.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.NatConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.NatConfig.layer_scale_init_value",description:`<strong>layer_scale_init_value</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The initial value for the layer scale. Disabled if &lt;=0.`,name:"layer_scale_init_value"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/nat/configuration_nat.py#L29"}}),X=new Oa({props:{anchor:"transformers.NatConfig.example",$$slots:{default:[Wn]},$$scope:{ctx:I}}}),we=new Nt({}),Ne=new wt({props:{name:"class transformers.NatModel",anchor:"transformers.NatModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.NatModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatConfig">NatConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.25.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/nat/modeling_nat.py#L673"}}),Te=new wt({props:{name:"forward",anchor:"transformers.NatModel.forward",parameters:[{name:"pixel_values",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.NatModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/v4.25.1/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<code>AutoImageProcessor.__call__()</code> for details.`,name:"pixel_values"},{anchor:"transformers.NatModel.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.NatModel.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.NatModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.25.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/nat/modeling_nat.py#L703",returnDescription:`
<p>A <code>transformers.models.nat.modeling_nat.NatModelOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatConfig"
>NatConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>, <em>optional</em>, returned when <code>add_pooling_layer=True</code> is passed) \u2014 Average pooling of the last layer hidden-state.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each stage) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each stage) 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>reshaped_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.nat.modeling_nat.NatModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ee=new qn({props:{$$slots:{default:[Hn]},$$scope:{ctx:I}}}),te=new Oa({props:{anchor:"transformers.NatModel.forward.example",$$slots:{default:[Un]},$$scope:{ctx:I}}}),Ae=new Nt({}),Ee=new wt({props:{name:"class transformers.NatForImageClassification",anchor:"transformers.NatForImageClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.NatForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatConfig">NatConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.25.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/nat/modeling_nat.py#L766"}}),ke=new wt({props:{name:"forward",anchor:"transformers.NatForImageClassification.forward",parameters:[{name:"pixel_values",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.NatForImageClassification.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/v4.25.1/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<code>AutoImageProcessor.__call__()</code> for details.`,name:"pixel_values"},{anchor:"transformers.NatForImageClassification.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.NatForImageClassification.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.NatForImageClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.25.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.NatForImageClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the image classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.25.1/src/transformers/models/nat/modeling_nat.py#L783",returnDescription:`
<p>A <code>transformers.models.nat.modeling_nat.NatImageClassifierOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatConfig"
>NatConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each stage) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each stage) 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>reshaped_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.nat.modeling_nat.NatImageClassifierOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ae=new qn({props:{$$slots:{default:[Vn]},$$scope:{ctx:I}}}),ne=new Oa({props:{anchor:"transformers.NatForImageClassification.forward.example",$$slots:{default:[Kn]},$$scope:{ctx:I}}}),{c(){h=s("meta"),b=f(),_=s("h1"),u=s("a"),v=s("span"),N(l.$$.fragment),g=f(),M=s("span"),Qt=a("Neighborhood Attention Transformer"),$t=f(),F=s("h2"),K=s("a"),Ye=s("span"),N(ce.$$.fragment),Xt=f(),Qe=s("span"),Zt=a("Overview"),yt=f(),R=s("p"),eo=a("NAT was proposed in "),he=s("a"),to=a("Neighborhood Attention Transformer"),oo=a(`
by Ali Hassani, Steven Walton, Jiachen Li, Shen Li, and Humphrey Shi.`),Tt=f(),je=s("p"),ao=a("It is a hierarchical vision transformer based on Neighborhood Attention, a sliding-window self attention pattern."),At=f(),Me=s("p"),no=a("The abstract from the paper is the following:"),Et=f(),qe=s("p"),Xe=s("em"),so=a(`We present Neighborhood Attention (NA), the first efficient and scalable sliding-window attention mechanism for vision.
NA is a pixel-wise operation, localizing self attention (SA) to the nearest neighboring pixels, and therefore enjoys a
linear time and space complexity compared to the quadratic complexity of SA. The sliding-window pattern allows NA\u2019s
receptive field to grow without needing extra pixel shifts, and preserves translational equivariance, unlike
Swin Transformer\u2019s Window Self Attention (WSA). We develop NATTEN (Neighborhood Attention Extension), a Python package
with efficient C++ and CUDA kernels, which allows NA to run up to 40% faster than Swin\u2019s WSA while using up to 25% less
memory. We further present Neighborhood Attention Transformer (NAT), a new hierarchical transformer design based on NA
that boosts image classification and downstream vision performance. Experimental results on NAT are competitive;
NAT-Tiny reaches 83.2% top-1 accuracy on ImageNet, 51.4% mAP on MS-COCO and 48.4% mIoU on ADE20K, which is 1.9%
ImageNet accuracy, 1.0% COCO mAP, and 2.6% ADE20K mIoU improvement over a Swin model with similar size.`),Ct=f(),Se=s("p"),ro=a("Tips:"),xt=f(),B=s("ul"),pe=s("li"),io=a("One can use the "),ze=s("a"),lo=a("AutoImageProcessor"),co=a(" API to prepare images for the model."),ho=f(),w=s("li"),po=a("NAT can be used as a "),Ze=s("em"),fo=a("backbone"),mo=a(". When "),et=s("code"),uo=a("output_hidden_states = True"),go=a(`,
it will output both `),tt=s("code"),_o=a("hidden_states"),vo=a(" and "),ot=s("code"),bo=a("reshaped_hidden_states"),wo=a(`.
The `),at=s("code"),No=a("reshaped_hidden_states"),$o=a(" have a shape of "),nt=s("code"),yo=a("(batch, num_channels, height, width)"),To=a(` rather than
`),st=s("code"),Ao=a("(batch_size, height, width, num_channels)"),Eo=a("."),kt=f(),Fe=s("p"),Co=a("Notes:"),It=f(),J=s("ul"),q=s("li"),xo=a("NAT depends on "),fe=s("a"),ko=a("NATTEN"),Io=a(`\u2019s implementation of Neighborhood Attention.
You can install it with pre-built wheels for Linux by referring to `),me=s("a"),Po=a("shi-labs.com/natten"),jo=a(`,
or build on your system by running `),rt=s("code"),Mo=a("pip install natten"),qo=a(`.
Note that the latter will likely take time to compile. NATTEN does not support Windows devices yet.`),So=f(),it=s("li"),zo=a("Patch size of 4 is only supported at the moment."),Pt=f(),G=s("img"),jt=f(),Y=s("small"),Fo=a(`Neighborhood Attention compared to other attention patterns.
Taken from the `),Oe=s("a"),Oo=a("original paper"),Do=a("."),Mt=f(),z=s("p"),Lo=a("This model was contributed by "),ue=s("a"),Wo=a("Ali Hassani"),Ho=a(`.
The original code can be found `),ge=s("a"),Uo=a("here"),Vo=a("."),qt=f(),O=s("h2"),Q=s("a"),lt=s("span"),N(_e.$$.fragment),Ko=f(),dt=s("span"),Ro=a("NatConfig"),St=f(),x=s("div"),N(ve.$$.fragment),Bo=f(),D=s("p"),Jo=a("This is the configuration class to store the configuration of a "),De=s("a"),Go=a("NatModel"),Yo=a(`. It is used to instantiate a Nat 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 Nat
`),be=s("a"),Qo=a("shi-labs/nat-mini-in1k-224"),Xo=a(" architecture."),Zo=f(),L=s("p"),ea=a("Configuration objects inherit from "),Le=s("a"),ta=a("PretrainedConfig"),oa=a(` and can be used to control the model outputs. Read the
documentation from `),We=s("a"),aa=a("PretrainedConfig"),na=a(" for more information."),sa=f(),N(X.$$.fragment),zt=f(),W=s("h2"),Z=s("a"),ct=s("span"),N(we.$$.fragment),ra=f(),ht=s("span"),ia=a("NatModel"),Ft=f(),S=s("div"),N(Ne.$$.fragment),la=f(),$e=s("p"),da=a(`The bare Nat Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ye=s("a"),ca=a("torch.nn.Module"),ha=a(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),pa=f(),P=s("div"),N(Te.$$.fragment),fa=f(),H=s("p"),ma=a("The "),He=s("a"),ua=a("NatModel"),ga=a(" forward method, overrides the "),pt=s("code"),_a=a("__call__"),va=a(" special method."),ba=f(),N(ee.$$.fragment),wa=f(),N(te.$$.fragment),Ot=f(),U=s("h2"),oe=s("a"),ft=s("span"),N(Ae.$$.fragment),Na=f(),mt=s("span"),$a=a("NatForImageClassification"),Dt=f(),k=s("div"),N(Ee.$$.fragment),ya=f(),ut=s("p"),Ta=a(`Nat Model transformer with an image classification head on top (a linear layer on top of the final hidden state of
the [CLS] token) e.g. for ImageNet.`),Aa=f(),Ce=s("p"),Ea=a("This model is a PyTorch "),xe=s("a"),Ca=a("torch.nn.Module"),xa=a(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ka=f(),j=s("div"),N(ke.$$.fragment),Ia=f(),V=s("p"),Pa=a("The "),Ue=s("a"),ja=a("NatForImageClassification"),Ma=a(" forward method, overrides the "),gt=s("code"),qa=a("__call__"),Sa=a(" special method."),za=f(),N(ae.$$.fragment),Fa=f(),N(ne.$$.fragment),this.h()},l(t){const c=On('[data-svelte="svelte-1phssyn"]',document.head);h=r(c,"META",{name:!0,content:!0}),c.forEach(o),b=m(t),_=r(t,"H1",{class:!0});var Ie=i(_);u=r(Ie,"A",{id:!0,class:!0,href:!0});var _t=i(u);v=r(_t,"SPAN",{});var vt=i(v);$(l.$$.fragment,vt),vt.forEach(o),_t.forEach(o),g=m(Ie),M=r(Ie,"SPAN",{});var bt=i(M);Qt=n(bt,"Neighborhood Attention Transformer"),bt.forEach(o),Ie.forEach(o),$t=m(t),F=r(t,"H2",{class:!0});var Pe=i(F);K=r(Pe,"A",{id:!0,class:!0,href:!0});var Ha=i(K);Ye=r(Ha,"SPAN",{});var Ua=i(Ye);$(ce.$$.fragment,Ua),Ua.forEach(o),Ha.forEach(o),Xt=m(Pe),Qe=r(Pe,"SPAN",{});var Va=i(Qe);Zt=n(Va,"Overview"),Va.forEach(o),Pe.forEach(o),yt=m(t),R=r(t,"P",{});var Wt=i(R);eo=n(Wt,"NAT was proposed in "),he=r(Wt,"A",{href:!0,rel:!0});var Ka=i(he);to=n(Ka,"Neighborhood Attention Transformer"),Ka.forEach(o),oo=n(Wt,`
by Ali Hassani, Steven Walton, Jiachen Li, Shen Li, and Humphrey Shi.`),Wt.forEach(o),Tt=m(t),je=r(t,"P",{});var Ra=i(je);ao=n(Ra,"It is a hierarchical vision transformer based on Neighborhood Attention, a sliding-window self attention pattern."),Ra.forEach(o),At=m(t),Me=r(t,"P",{});var Ba=i(Me);no=n(Ba,"The abstract from the paper is the following:"),Ba.forEach(o),Et=m(t),qe=r(t,"P",{});var Ja=i(qe);Xe=r(Ja,"EM",{});var Ga=i(Xe);so=n(Ga,`We present Neighborhood Attention (NA), the first efficient and scalable sliding-window attention mechanism for vision.
NA is a pixel-wise operation, localizing self attention (SA) to the nearest neighboring pixels, and therefore enjoys a
linear time and space complexity compared to the quadratic complexity of SA. The sliding-window pattern allows NA\u2019s
receptive field to grow without needing extra pixel shifts, and preserves translational equivariance, unlike
Swin Transformer\u2019s Window Self Attention (WSA). We develop NATTEN (Neighborhood Attention Extension), a Python package
with efficient C++ and CUDA kernels, which allows NA to run up to 40% faster than Swin\u2019s WSA while using up to 25% less
memory. We further present Neighborhood Attention Transformer (NAT), a new hierarchical transformer design based on NA
that boosts image classification and downstream vision performance. Experimental results on NAT are competitive;
NAT-Tiny reaches 83.2% top-1 accuracy on ImageNet, 51.4% mAP on MS-COCO and 48.4% mIoU on ADE20K, which is 1.9%
ImageNet accuracy, 1.0% COCO mAP, and 2.6% ADE20K mIoU improvement over a Swin model with similar size.`),Ga.forEach(o),Ja.forEach(o),Ct=m(t),Se=r(t,"P",{});var Ya=i(Se);ro=n(Ya,"Tips:"),Ya.forEach(o),xt=m(t),B=r(t,"UL",{});var Ht=i(B);pe=r(Ht,"LI",{});var Ut=i(pe);io=n(Ut,"One can use the "),ze=r(Ut,"A",{href:!0});var Qa=i(ze);lo=n(Qa,"AutoImageProcessor"),Qa.forEach(o),co=n(Ut," API to prepare images for the model."),Ut.forEach(o),ho=m(Ht),w=r(Ht,"LI",{});var C=i(w);po=n(C,"NAT can be used as a "),Ze=r(C,"EM",{});var Xa=i(Ze);fo=n(Xa,"backbone"),Xa.forEach(o),mo=n(C,". When "),et=r(C,"CODE",{});var Za=i(et);uo=n(Za,"output_hidden_states = True"),Za.forEach(o),go=n(C,`,
it will output both `),tt=r(C,"CODE",{});var en=i(tt);_o=n(en,"hidden_states"),en.forEach(o),vo=n(C," and "),ot=r(C,"CODE",{});var tn=i(ot);bo=n(tn,"reshaped_hidden_states"),tn.forEach(o),wo=n(C,`.
The `),at=r(C,"CODE",{});var on=i(at);No=n(on,"reshaped_hidden_states"),on.forEach(o),$o=n(C," have a shape of "),nt=r(C,"CODE",{});var an=i(nt);yo=n(an,"(batch, num_channels, height, width)"),an.forEach(o),To=n(C,` rather than
`),st=r(C,"CODE",{});var nn=i(st);Ao=n(nn,"(batch_size, height, width, num_channels)"),nn.forEach(o),Eo=n(C,"."),C.forEach(o),Ht.forEach(o),kt=m(t),Fe=r(t,"P",{});var sn=i(Fe);Co=n(sn,"Notes:"),sn.forEach(o),It=m(t),J=r(t,"UL",{});var Vt=i(J);q=r(Vt,"LI",{});var se=i(q);xo=n(se,"NAT depends on "),fe=r(se,"A",{href:!0,rel:!0});var rn=i(fe);ko=n(rn,"NATTEN"),rn.forEach(o),Io=n(se,`\u2019s implementation of Neighborhood Attention.
You can install it with pre-built wheels for Linux by referring to `),me=r(se,"A",{href:!0,rel:!0});var ln=i(me);Po=n(ln,"shi-labs.com/natten"),ln.forEach(o),jo=n(se,`,
or build on your system by running `),rt=r(se,"CODE",{});var dn=i(rt);Mo=n(dn,"pip install natten"),dn.forEach(o),qo=n(se,`.
Note that the latter will likely take time to compile. NATTEN does not support Windows devices yet.`),se.forEach(o),So=m(Vt),it=r(Vt,"LI",{});var cn=i(it);zo=n(cn,"Patch size of 4 is only supported at the moment."),cn.forEach(o),Vt.forEach(o),Pt=m(t),G=r(t,"IMG",{src:!0,alt:!0,width:!0}),jt=m(t),Y=r(t,"SMALL",{});var Kt=i(Y);Fo=n(Kt,`Neighborhood Attention compared to other attention patterns.
Taken from the `),Oe=r(Kt,"A",{href:!0});var hn=i(Oe);Oo=n(hn,"original paper"),hn.forEach(o),Do=n(Kt,"."),Kt.forEach(o),Mt=m(t),z=r(t,"P",{});var Ve=i(z);Lo=n(Ve,"This model was contributed by "),ue=r(Ve,"A",{href:!0,rel:!0});var pn=i(ue);Wo=n(pn,"Ali Hassani"),pn.forEach(o),Ho=n(Ve,`.
The original code can be found `),ge=r(Ve,"A",{href:!0,rel:!0});var fn=i(ge);Uo=n(fn,"here"),fn.forEach(o),Vo=n(Ve,"."),Ve.forEach(o),qt=m(t),O=r(t,"H2",{class:!0});var Rt=i(O);Q=r(Rt,"A",{id:!0,class:!0,href:!0});var mn=i(Q);lt=r(mn,"SPAN",{});var un=i(lt);$(_e.$$.fragment,un),un.forEach(o),mn.forEach(o),Ko=m(Rt),dt=r(Rt,"SPAN",{});var gn=i(dt);Ro=n(gn,"NatConfig"),gn.forEach(o),Rt.forEach(o),St=m(t),x=r(t,"DIV",{class:!0});var re=i(x);$(ve.$$.fragment,re),Bo=m(re),D=r(re,"P",{});var Ke=i(D);Jo=n(Ke,"This is the configuration class to store the configuration of a "),De=r(Ke,"A",{href:!0});var _n=i(De);Go=n(_n,"NatModel"),_n.forEach(o),Yo=n(Ke,`. It is used to instantiate a Nat 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 Nat
`),be=r(Ke,"A",{href:!0,rel:!0});var vn=i(be);Qo=n(vn,"shi-labs/nat-mini-in1k-224"),vn.forEach(o),Xo=n(Ke," architecture."),Ke.forEach(o),Zo=m(re),L=r(re,"P",{});var Re=i(L);ea=n(Re,"Configuration objects inherit from "),Le=r(Re,"A",{href:!0});var bn=i(Le);ta=n(bn,"PretrainedConfig"),bn.forEach(o),oa=n(Re,` and can be used to control the model outputs. Read the
documentation from `),We=r(Re,"A",{href:!0});var wn=i(We);aa=n(wn,"PretrainedConfig"),wn.forEach(o),na=n(Re," for more information."),Re.forEach(o),sa=m(re),$(X.$$.fragment,re),re.forEach(o),zt=m(t),W=r(t,"H2",{class:!0});var Bt=i(W);Z=r(Bt,"A",{id:!0,class:!0,href:!0});var Nn=i(Z);ct=r(Nn,"SPAN",{});var $n=i(ct);$(we.$$.fragment,$n),$n.forEach(o),Nn.forEach(o),ra=m(Bt),ht=r(Bt,"SPAN",{});var yn=i(ht);ia=n(yn,"NatModel"),yn.forEach(o),Bt.forEach(o),Ft=m(t),S=r(t,"DIV",{class:!0});var Be=i(S);$(Ne.$$.fragment,Be),la=m(Be),$e=r(Be,"P",{});var Jt=i($e);da=n(Jt,`The bare Nat Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ye=r(Jt,"A",{href:!0,rel:!0});var Tn=i(ye);ca=n(Tn,"torch.nn.Module"),Tn.forEach(o),ha=n(Jt,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Jt.forEach(o),pa=m(Be),P=r(Be,"DIV",{class:!0});var ie=i(P);$(Te.$$.fragment,ie),fa=m(ie),H=r(ie,"P",{});var Je=i(H);ma=n(Je,"The "),He=r(Je,"A",{href:!0});var An=i(He);ua=n(An,"NatModel"),An.forEach(o),ga=n(Je," forward method, overrides the "),pt=r(Je,"CODE",{});var En=i(pt);_a=n(En,"__call__"),En.forEach(o),va=n(Je," special method."),Je.forEach(o),ba=m(ie),$(ee.$$.fragment,ie),wa=m(ie),$(te.$$.fragment,ie),ie.forEach(o),Be.forEach(o),Ot=m(t),U=r(t,"H2",{class:!0});var Gt=i(U);oe=r(Gt,"A",{id:!0,class:!0,href:!0});var Cn=i(oe);ft=r(Cn,"SPAN",{});var xn=i(ft);$(Ae.$$.fragment,xn),xn.forEach(o),Cn.forEach(o),Na=m(Gt),mt=r(Gt,"SPAN",{});var kn=i(mt);$a=n(kn,"NatForImageClassification"),kn.forEach(o),Gt.forEach(o),Dt=m(t),k=r(t,"DIV",{class:!0});var le=i(k);$(Ee.$$.fragment,le),ya=m(le),ut=r(le,"P",{});var In=i(ut);Ta=n(In,`Nat Model transformer with an image classification head on top (a linear layer on top of the final hidden state of
the [CLS] token) e.g. for ImageNet.`),In.forEach(o),Aa=m(le),Ce=r(le,"P",{});var Yt=i(Ce);Ea=n(Yt,"This model is a PyTorch "),xe=r(Yt,"A",{href:!0,rel:!0});var Pn=i(xe);Ca=n(Pn,"torch.nn.Module"),Pn.forEach(o),xa=n(Yt,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Yt.forEach(o),ka=m(le),j=r(le,"DIV",{class:!0});var de=i(j);$(ke.$$.fragment,de),Ia=m(de),V=r(de,"P",{});var Ge=i(V);Pa=n(Ge,"The "),Ue=r(Ge,"A",{href:!0});var jn=i(Ue);ja=n(jn,"NatForImageClassification"),jn.forEach(o),Ma=n(Ge," forward method, overrides the "),gt=r(Ge,"CODE",{});var Mn=i(gt);qa=n(Mn,"__call__"),Mn.forEach(o),Sa=n(Ge," special method."),Ge.forEach(o),za=m(de),$(ae.$$.fragment,de),Fa=m(de),$(ne.$$.fragment,de),de.forEach(o),le.forEach(o),this.h()},h(){d(h,"name","hf:doc:metadata"),d(h,"content",JSON.stringify(Bn)),d(u,"id","neighborhood-attention-transformer"),d(u,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(u,"href","#neighborhood-attention-transformer"),d(_,"class","relative group"),d(K,"id","overview"),d(K,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(K,"href","#overview"),d(F,"class","relative group"),d(he,"href","https://arxiv.org/abs/2204.07143"),d(he,"rel","nofollow"),d(ze,"href","/docs/transformers/v4.25.1/en/model_doc/auto#transformers.AutoImageProcessor"),d(fe,"href","https://github.com/SHI-Labs/NATTEN/"),d(fe,"rel","nofollow"),d(me,"href","https://shi-labs.com/natten"),d(me,"rel","nofollow"),Dn(G.src,Wa="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/neighborhood-attention-pattern.jpg")||d(G,"src",Wa),d(G,"alt","drawing"),d(G,"width","600"),d(Oe,"href","https://arxiv.org/abs/2204.07143"),d(ue,"href","https://huggingface.co/alihassanijr"),d(ue,"rel","nofollow"),d(ge,"href","https://github.com/SHI-Labs/Neighborhood-Attention-Transformer"),d(ge,"rel","nofollow"),d(Q,"id","transformers.NatConfig"),d(Q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Q,"href","#transformers.NatConfig"),d(O,"class","relative group"),d(De,"href","/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatModel"),d(be,"href","https://huggingface.co/shi-labs/nat-mini-in1k-224"),d(be,"rel","nofollow"),d(Le,"href","/docs/transformers/v4.25.1/en/main_classes/configuration#transformers.PretrainedConfig"),d(We,"href","/docs/transformers/v4.25.1/en/main_classes/configuration#transformers.PretrainedConfig"),d(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Z,"id","transformers.NatModel"),d(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Z,"href","#transformers.NatModel"),d(W,"class","relative group"),d(ye,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(ye,"rel","nofollow"),d(He,"href","/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatModel"),d(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(oe,"id","transformers.NatForImageClassification"),d(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(oe,"href","#transformers.NatForImageClassification"),d(U,"class","relative group"),d(xe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(xe,"rel","nofollow"),d(Ue,"href","/docs/transformers/v4.25.1/en/model_doc/nat#transformers.NatForImageClassification"),d(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,c){e(document.head,h),p(t,b,c),p(t,_,c),e(_,u),e(u,v),y(l,v,null),e(_,g),e(_,M),e(M,Qt),p(t,$t,c),p(t,F,c),e(F,K),e(K,Ye),y(ce,Ye,null),e(F,Xt),e(F,Qe),e(Qe,Zt),p(t,yt,c),p(t,R,c),e(R,eo),e(R,he),e(he,to),e(R,oo),p(t,Tt,c),p(t,je,c),e(je,ao),p(t,At,c),p(t,Me,c),e(Me,no),p(t,Et,c),p(t,qe,c),e(qe,Xe),e(Xe,so),p(t,Ct,c),p(t,Se,c),e(Se,ro),p(t,xt,c),p(t,B,c),e(B,pe),e(pe,io),e(pe,ze),e(ze,lo),e(pe,co),e(B,ho),e(B,w),e(w,po),e(w,Ze),e(Ze,fo),e(w,mo),e(w,et),e(et,uo),e(w,go),e(w,tt),e(tt,_o),e(w,vo),e(w,ot),e(ot,bo),e(w,wo),e(w,at),e(at,No),e(w,$o),e(w,nt),e(nt,yo),e(w,To),e(w,st),e(st,Ao),e(w,Eo),p(t,kt,c),p(t,Fe,c),e(Fe,Co),p(t,It,c),p(t,J,c),e(J,q),e(q,xo),e(q,fe),e(fe,ko),e(q,Io),e(q,me),e(me,Po),e(q,jo),e(q,rt),e(rt,Mo),e(q,qo),e(J,So),e(J,it),e(it,zo),p(t,Pt,c),p(t,G,c),p(t,jt,c),p(t,Y,c),e(Y,Fo),e(Y,Oe),e(Oe,Oo),e(Y,Do),p(t,Mt,c),p(t,z,c),e(z,Lo),e(z,ue),e(ue,Wo),e(z,Ho),e(z,ge),e(ge,Uo),e(z,Vo),p(t,qt,c),p(t,O,c),e(O,Q),e(Q,lt),y(_e,lt,null),e(O,Ko),e(O,dt),e(dt,Ro),p(t,St,c),p(t,x,c),y(ve,x,null),e(x,Bo),e(x,D),e(D,Jo),e(D,De),e(De,Go),e(D,Yo),e(D,be),e(be,Qo),e(D,Xo),e(x,Zo),e(x,L),e(L,ea),e(L,Le),e(Le,ta),e(L,oa),e(L,We),e(We,aa),e(L,na),e(x,sa),y(X,x,null),p(t,zt,c),p(t,W,c),e(W,Z),e(Z,ct),y(we,ct,null),e(W,ra),e(W,ht),e(ht,ia),p(t,Ft,c),p(t,S,c),y(Ne,S,null),e(S,la),e(S,$e),e($e,da),e($e,ye),e(ye,ca),e($e,ha),e(S,pa),e(S,P),y(Te,P,null),e(P,fa),e(P,H),e(H,ma),e(H,He),e(He,ua),e(H,ga),e(H,pt),e(pt,_a),e(H,va),e(P,ba),y(ee,P,null),e(P,wa),y(te,P,null),p(t,Ot,c),p(t,U,c),e(U,oe),e(oe,ft),y(Ae,ft,null),e(U,Na),e(U,mt),e(mt,$a),p(t,Dt,c),p(t,k,c),y(Ee,k,null),e(k,ya),e(k,ut),e(ut,Ta),e(k,Aa),e(k,Ce),e(Ce,Ea),e(Ce,xe),e(xe,Ca),e(Ce,xa),e(k,ka),e(k,j),y(ke,j,null),e(j,Ia),e(j,V),e(V,Pa),e(V,Ue),e(Ue,ja),e(V,Ma),e(V,gt),e(gt,qa),e(V,Sa),e(j,za),y(ae,j,null),e(j,Fa),y(ne,j,null),Lt=!0},p(t,[c]){const Ie={};c&2&&(Ie.$$scope={dirty:c,ctx:t}),X.$set(Ie);const _t={};c&2&&(_t.$$scope={dirty:c,ctx:t}),ee.$set(_t);const vt={};c&2&&(vt.$$scope={dirty:c,ctx:t}),te.$set(vt);const bt={};c&2&&(bt.$$scope={dirty:c,ctx:t}),ae.$set(bt);const Pe={};c&2&&(Pe.$$scope={dirty:c,ctx:t}),ne.$set(Pe)},i(t){Lt||(T(l.$$.fragment,t),T(ce.$$.fragment,t),T(_e.$$.fragment,t),T(ve.$$.fragment,t),T(X.$$.fragment,t),T(we.$$.fragment,t),T(Ne.$$.fragment,t),T(Te.$$.fragment,t),T(ee.$$.fragment,t),T(te.$$.fragment,t),T(Ae.$$.fragment,t),T(Ee.$$.fragment,t),T(ke.$$.fragment,t),T(ae.$$.fragment,t),T(ne.$$.fragment,t),Lt=!0)},o(t){A(l.$$.fragment,t),A(ce.$$.fragment,t),A(_e.$$.fragment,t),A(ve.$$.fragment,t),A(X.$$.fragment,t),A(we.$$.fragment,t),A(Ne.$$.fragment,t),A(Te.$$.fragment,t),A(ee.$$.fragment,t),A(te.$$.fragment,t),A(Ae.$$.fragment,t),A(Ee.$$.fragment,t),A(ke.$$.fragment,t),A(ae.$$.fragment,t),A(ne.$$.fragment,t),Lt=!1},d(t){o(h),t&&o(b),t&&o(_),E(l),t&&o($t),t&&o(F),E(ce),t&&o(yt),t&&o(R),t&&o(Tt),t&&o(je),t&&o(At),t&&o(Me),t&&o(Et),t&&o(qe),t&&o(Ct),t&&o(Se),t&&o(xt),t&&o(B),t&&o(kt),t&&o(Fe),t&&o(It),t&&o(J),t&&o(Pt),t&&o(G),t&&o(jt),t&&o(Y),t&&o(Mt),t&&o(z),t&&o(qt),t&&o(O),E(_e),t&&o(St),t&&o(x),E(ve),E(X),t&&o(zt),t&&o(W),E(we),t&&o(Ft),t&&o(S),E(Ne),E(Te),E(ee),E(te),t&&o(Ot),t&&o(U),E(Ae),t&&o(Dt),t&&o(k),E(Ee),E(ke),E(ae),E(ne)}}}const Bn={local:"neighborhood-attention-transformer",sections:[{local:"overview",title:"Overview"},{local:"transformers.NatConfig",title:"NatConfig"},{local:"transformers.NatModel",title:"NatModel"},{local:"transformers.NatForImageClassification",title:"NatForImageClassification"}],title:"Neighborhood Attention Transformer"};function Jn(I){return Ln(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ts extends Sn{constructor(h){super();zn(this,h,Jn,Rn,Fn,{})}}export{ts as default,Bn as metadata};
