import{S as ws,i as Ns,s as $s,e as a,k as p,w,t as s,M as ys,c as n,d as o,m,a as i,x as N,h as r,b as c,N as Ts,G as t,g as h,y as $,q as y,o as T,B as A,v as As,L as gn}from"../../chunks/vendor-hf-doc-builder.js";import{T as vs}from"../../chunks/Tip-hf-doc-builder.js";import{D as Ft}from"../../chunks/Docstring-hf-doc-builder.js";import{C as _n}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as lt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as un}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Es}from"../../chunks/PipelineTag-hf-doc-builder.js";function Cs(P){let f,v,_,u,b;return u=new _n({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(){f=a("p"),v=s("Example:"),_=p(),w(u.$$.fragment)},l(l){f=n(l,"P",{});var g=i(f);v=r(g,"Example:"),g.forEach(o),_=m(l),N(u.$$.fragment,l)},m(l,g){h(l,f,g),t(f,v),h(l,_,g),$(u,l,g),b=!0},p:gn,i(l){b||(y(u.$$.fragment,l),b=!0)},o(l){T(u.$$.fragment,l),b=!1},d(l){l&&o(f),l&&o(_),A(u,l)}}}function xs(P){let f,v,_,u,b;return{c(){f=a("p"),v=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("code"),u=s("Module"),b=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){f=n(l,"P",{});var g=i(f);v=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n(g,"CODE",{});var M=i(_);u=r(M,"Module"),M.forEach(o),b=r(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){h(l,f,g),t(f,v),t(f,_),t(_,u),t(f,b)},d(l){l&&o(f)}}}function ks(P){let f,v,_,u,b;return u=new _n({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]

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

inputs = image_processor(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>image_processor = 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 = image_processor(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(){f=a("p"),v=s("Example:"),_=p(),w(u.$$.fragment)},l(l){f=n(l,"P",{});var g=i(f);v=r(g,"Example:"),g.forEach(o),_=m(l),N(u.$$.fragment,l)},m(l,g){h(l,f,g),t(f,v),h(l,_,g),$(u,l,g),b=!0},p:gn,i(l){b||(y(u.$$.fragment,l),b=!0)},o(l){T(u.$$.fragment,l),b=!1},d(l){l&&o(f),l&&o(_),A(u,l)}}}function Ps(P){let f,v,_,u,b;return{c(){f=a("p"),v=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("code"),u=s("Module"),b=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){f=n(l,"P",{});var g=i(f);v=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n(g,"CODE",{});var M=i(_);u=r(M,"Module"),M.forEach(o),b=r(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){h(l,f,g),t(f,v),t(f,_),t(_,u),t(f,b)},d(l){l&&o(f)}}}function Is(P){let f,v,_,u,b;return u=new _n({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]

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

inputs = image_processor(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>image_processor = 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 = image_processor(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(){f=a("p"),v=s("Example:"),_=p(),w(u.$$.fragment)},l(l){f=n(l,"P",{});var g=i(f);v=r(g,"Example:"),g.forEach(o),_=m(l),N(u.$$.fragment,l)},m(l,g){h(l,f,g),t(f,v),h(l,_,g),$(u,l,g),b=!0},p:gn,i(l){b||(y(u.$$.fragment,l),b=!0)},o(l){T(u.$$.fragment,l),b=!1},d(l){l&&o(f),l&&o(_),A(u,l)}}}function js(P){let f,v,_,u,b,l,g,M,bo,St,O,B,dt,me,vo,ct,wo,zt,J,No,fe,$o,yo,Ot,De,To,Lt,We,Ao,Dt,He,ht,Eo,Wt,Ue,Co,Ht,G,ue,xo,Re,ko,Po,Io,E,jo,pt,Mo,qo,mt,Fo,So,ft,zo,Oo,ut,Lo,Do,gt,Wo,Ho,_t,Uo,Ro,bt,Vo,Ko,Ut,Ve,Bo,Rt,Y,q,Jo,ge,Go,Yo,_e,Qo,Xo,vt,Zo,ea,ta,wt,oa,Vt,Q,bn,Kt,X,aa,Ke,na,sa,Bt,S,ra,be,ia,la,ve,da,ca,Jt,L,Z,Nt,we,ha,$t,pa,Gt,Be,ma,Yt,Ne,Qt,Je,z,Ge,fa,ua,$e,ga,_a,ye,ba,va,Xt,Ye,wa,Zt,D,ee,yt,Te,Na,Tt,$a,eo,x,Ae,ya,W,Ta,Qe,Aa,Ea,Ee,Ca,xa,ka,H,Pa,Xe,Ia,ja,Ze,Ma,qa,Fa,te,to,U,oe,At,Ce,Sa,Et,za,oo,F,xe,Oa,ke,La,Pe,Da,Wa,Ha,I,Ie,Ua,R,Ra,et,Va,Ka,Ct,Ba,Ja,Ga,ae,Ya,ne,ao,V,se,xt,je,Qa,kt,Xa,no,k,Me,Za,Pt,en,tn,qe,on,Fe,an,nn,sn,j,Se,rn,K,ln,tt,dn,cn,It,hn,pn,mn,re,fn,ie,so;return l=new lt({}),me=new lt({}),we=new lt({}),Ne=new Es({props:{pipeline:"image-classification"}}),Te=new lt({}),Ae=new Ft({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:"out_features",val:" = None"},{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"},{anchor:"transformers.NatConfig.out_features",description:`<strong>out_features</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
If used as backbone, list of features to output. Can be any of <code>&quot;stem&quot;</code>, <code>&quot;stage1&quot;</code>, <code>&quot;stage2&quot;</code>, etc.
(depending on how many stages the model has). Will default to the last stage if unset.`,name:"out_features"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/nat/configuration_nat.py#L29"}}),te=new un({props:{anchor:"transformers.NatConfig.example",$$slots:{default:[Cs]},$$scope:{ctx:P}}}),Ce=new lt({}),xe=new Ft({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/main/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/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/nat/modeling_nat.py#L678"}}),Ie=new Ft({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/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/poolformer#transformers.PoolFormerFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
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/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/nat/modeling_nat.py#L708",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/main/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>
`}}),ae=new vs({props:{$$slots:{default:[xs]},$$scope:{ctx:P}}}),ne=new un({props:{anchor:"transformers.NatModel.forward.example",$$slots:{default:[ks]},$$scope:{ctx:P}}}),je=new lt({}),Me=new Ft({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/main/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/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/nat/modeling_nat.py#L770"}}),Se=new Ft({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/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/poolformer#transformers.PoolFormerFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
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/main/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/main/src/transformers/models/nat/modeling_nat.py#L787",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/main/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>
`}}),re=new vs({props:{$$slots:{default:[Ps]},$$scope:{ctx:P}}}),ie=new un({props:{anchor:"transformers.NatForImageClassification.forward.example",$$slots:{default:[Is]},$$scope:{ctx:P}}}),{c(){f=a("meta"),v=p(),_=a("h1"),u=a("a"),b=a("span"),w(l.$$.fragment),g=p(),M=a("span"),bo=s("Neighborhood Attention Transformer"),St=p(),O=a("h2"),B=a("a"),dt=a("span"),w(me.$$.fragment),vo=p(),ct=a("span"),wo=s("Overview"),zt=p(),J=a("p"),No=s("NAT was proposed in "),fe=a("a"),$o=s("Neighborhood Attention Transformer"),yo=s(`
by Ali Hassani, Steven Walton, Jiachen Li, Shen Li, and Humphrey Shi.`),Ot=p(),De=a("p"),To=s("It is a hierarchical vision transformer based on Neighborhood Attention, a sliding-window self attention pattern."),Lt=p(),We=a("p"),Ao=s("The abstract from the paper is the following:"),Dt=p(),He=a("p"),ht=a("em"),Eo=s(`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.`),Wt=p(),Ue=a("p"),Co=s("Tips:"),Ht=p(),G=a("ul"),ue=a("li"),xo=s("One can use the "),Re=a("a"),ko=s("AutoImageProcessor"),Po=s(" API to prepare images for the model."),Io=p(),E=a("li"),jo=s("NAT can be used as a "),pt=a("em"),Mo=s("backbone"),qo=s(". When "),mt=a("code"),Fo=s("output_hidden_states = True"),So=s(`,
it will output both `),ft=a("code"),zo=s("hidden_states"),Oo=s(" and "),ut=a("code"),Lo=s("reshaped_hidden_states"),Do=s(`.
The `),gt=a("code"),Wo=s("reshaped_hidden_states"),Ho=s(" have a shape of "),_t=a("code"),Uo=s("(batch, num_channels, height, width)"),Ro=s(` rather than
`),bt=a("code"),Vo=s("(batch_size, height, width, num_channels)"),Ko=s("."),Ut=p(),Ve=a("p"),Bo=s("Notes:"),Rt=p(),Y=a("ul"),q=a("li"),Jo=s("NAT depends on "),ge=a("a"),Go=s("NATTEN"),Yo=s(`\u2019s implementation of Neighborhood Attention.
You can install it with pre-built wheels for Linux by referring to `),_e=a("a"),Qo=s("shi-labs.com/natten"),Xo=s(`,
or build on your system by running `),vt=a("code"),Zo=s("pip install natten"),ea=s(`.
Note that the latter will likely take time to compile. NATTEN does not support Windows devices yet.`),ta=p(),wt=a("li"),oa=s("Patch size of 4 is only supported at the moment."),Vt=p(),Q=a("img"),Kt=p(),X=a("small"),aa=s(`Neighborhood Attention compared to other attention patterns.
Taken from the `),Ke=a("a"),na=s("original paper"),sa=s("."),Bt=p(),S=a("p"),ra=s("This model was contributed by "),be=a("a"),ia=s("Ali Hassani"),la=s(`.
The original code can be found `),ve=a("a"),da=s("here"),ca=s("."),Jt=p(),L=a("h2"),Z=a("a"),Nt=a("span"),w(we.$$.fragment),ha=p(),$t=a("span"),pa=s("Resources"),Gt=p(),Be=a("p"),ma=s("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with NAT."),Yt=p(),w(Ne.$$.fragment),Qt=p(),Je=a("ul"),z=a("li"),Ge=a("a"),fa=s("NatForImageClassification"),ua=s(" is supported by this "),$e=a("a"),ga=s("example script"),_a=s(" and "),ye=a("a"),ba=s("notebook"),va=s("."),Xt=p(),Ye=a("p"),wa=s("If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Zt=p(),D=a("h2"),ee=a("a"),yt=a("span"),w(Te.$$.fragment),Na=p(),Tt=a("span"),$a=s("NatConfig"),eo=p(),x=a("div"),w(Ae.$$.fragment),ya=p(),W=a("p"),Ta=s("This is the configuration class to store the configuration of a "),Qe=a("a"),Aa=s("NatModel"),Ea=s(`. 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
`),Ee=a("a"),Ca=s("shi-labs/nat-mini-in1k-224"),xa=s(" architecture."),ka=p(),H=a("p"),Pa=s("Configuration objects inherit from "),Xe=a("a"),Ia=s("PretrainedConfig"),ja=s(` and can be used to control the model outputs. Read the
documentation from `),Ze=a("a"),Ma=s("PretrainedConfig"),qa=s(" for more information."),Fa=p(),w(te.$$.fragment),to=p(),U=a("h2"),oe=a("a"),At=a("span"),w(Ce.$$.fragment),Sa=p(),Et=a("span"),za=s("NatModel"),oo=p(),F=a("div"),w(xe.$$.fragment),Oa=p(),ke=a("p"),La=s(`The bare Nat Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Pe=a("a"),Da=s("torch.nn.Module"),Wa=s(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ha=p(),I=a("div"),w(Ie.$$.fragment),Ua=p(),R=a("p"),Ra=s("The "),et=a("a"),Va=s("NatModel"),Ka=s(" forward method, overrides the "),Ct=a("code"),Ba=s("__call__"),Ja=s(" special method."),Ga=p(),w(ae.$$.fragment),Ya=p(),w(ne.$$.fragment),ao=p(),V=a("h2"),se=a("a"),xt=a("span"),w(je.$$.fragment),Qa=p(),kt=a("span"),Xa=s("NatForImageClassification"),no=p(),k=a("div"),w(Me.$$.fragment),Za=p(),Pt=a("p"),en=s(`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.`),tn=p(),qe=a("p"),on=s("This model is a PyTorch "),Fe=a("a"),an=s("torch.nn.Module"),nn=s(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),sn=p(),j=a("div"),w(Se.$$.fragment),rn=p(),K=a("p"),ln=s("The "),tt=a("a"),dn=s("NatForImageClassification"),cn=s(" forward method, overrides the "),It=a("code"),hn=s("__call__"),pn=s(" special method."),mn=p(),w(re.$$.fragment),fn=p(),w(ie.$$.fragment),this.h()},l(e){const d=ys('[data-svelte="svelte-1phssyn"]',document.head);f=n(d,"META",{name:!0,content:!0}),d.forEach(o),v=m(e),_=n(e,"H1",{class:!0});var ze=i(_);u=n(ze,"A",{id:!0,class:!0,href:!0});var jt=i(u);b=n(jt,"SPAN",{});var Mt=i(b);N(l.$$.fragment,Mt),Mt.forEach(o),jt.forEach(o),g=m(ze),M=n(ze,"SPAN",{});var qt=i(M);bo=r(qt,"Neighborhood Attention Transformer"),qt.forEach(o),ze.forEach(o),St=m(e),O=n(e,"H2",{class:!0});var Oe=i(O);B=n(Oe,"A",{id:!0,class:!0,href:!0});var vn=i(B);dt=n(vn,"SPAN",{});var wn=i(dt);N(me.$$.fragment,wn),wn.forEach(o),vn.forEach(o),vo=m(Oe),ct=n(Oe,"SPAN",{});var Nn=i(ct);wo=r(Nn,"Overview"),Nn.forEach(o),Oe.forEach(o),zt=m(e),J=n(e,"P",{});var ro=i(J);No=r(ro,"NAT was proposed in "),fe=n(ro,"A",{href:!0,rel:!0});var $n=i(fe);$o=r($n,"Neighborhood Attention Transformer"),$n.forEach(o),yo=r(ro,`
by Ali Hassani, Steven Walton, Jiachen Li, Shen Li, and Humphrey Shi.`),ro.forEach(o),Ot=m(e),De=n(e,"P",{});var yn=i(De);To=r(yn,"It is a hierarchical vision transformer based on Neighborhood Attention, a sliding-window self attention pattern."),yn.forEach(o),Lt=m(e),We=n(e,"P",{});var Tn=i(We);Ao=r(Tn,"The abstract from the paper is the following:"),Tn.forEach(o),Dt=m(e),He=n(e,"P",{});var An=i(He);ht=n(An,"EM",{});var En=i(ht);Eo=r(En,`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.`),En.forEach(o),An.forEach(o),Wt=m(e),Ue=n(e,"P",{});var Cn=i(Ue);Co=r(Cn,"Tips:"),Cn.forEach(o),Ht=m(e),G=n(e,"UL",{});var io=i(G);ue=n(io,"LI",{});var lo=i(ue);xo=r(lo,"One can use the "),Re=n(lo,"A",{href:!0});var xn=i(Re);ko=r(xn,"AutoImageProcessor"),xn.forEach(o),Po=r(lo," API to prepare images for the model."),lo.forEach(o),Io=m(io),E=n(io,"LI",{});var C=i(E);jo=r(C,"NAT can be used as a "),pt=n(C,"EM",{});var kn=i(pt);Mo=r(kn,"backbone"),kn.forEach(o),qo=r(C,". When "),mt=n(C,"CODE",{});var Pn=i(mt);Fo=r(Pn,"output_hidden_states = True"),Pn.forEach(o),So=r(C,`,
it will output both `),ft=n(C,"CODE",{});var In=i(ft);zo=r(In,"hidden_states"),In.forEach(o),Oo=r(C," and "),ut=n(C,"CODE",{});var jn=i(ut);Lo=r(jn,"reshaped_hidden_states"),jn.forEach(o),Do=r(C,`.
The `),gt=n(C,"CODE",{});var Mn=i(gt);Wo=r(Mn,"reshaped_hidden_states"),Mn.forEach(o),Ho=r(C," have a shape of "),_t=n(C,"CODE",{});var qn=i(_t);Uo=r(qn,"(batch, num_channels, height, width)"),qn.forEach(o),Ro=r(C,` rather than
`),bt=n(C,"CODE",{});var Fn=i(bt);Vo=r(Fn,"(batch_size, height, width, num_channels)"),Fn.forEach(o),Ko=r(C,"."),C.forEach(o),io.forEach(o),Ut=m(e),Ve=n(e,"P",{});var Sn=i(Ve);Bo=r(Sn,"Notes:"),Sn.forEach(o),Rt=m(e),Y=n(e,"UL",{});var co=i(Y);q=n(co,"LI",{});var le=i(q);Jo=r(le,"NAT depends on "),ge=n(le,"A",{href:!0,rel:!0});var zn=i(ge);Go=r(zn,"NATTEN"),zn.forEach(o),Yo=r(le,`\u2019s implementation of Neighborhood Attention.
You can install it with pre-built wheels for Linux by referring to `),_e=n(le,"A",{href:!0,rel:!0});var On=i(_e);Qo=r(On,"shi-labs.com/natten"),On.forEach(o),Xo=r(le,`,
or build on your system by running `),vt=n(le,"CODE",{});var Ln=i(vt);Zo=r(Ln,"pip install natten"),Ln.forEach(o),ea=r(le,`.
Note that the latter will likely take time to compile. NATTEN does not support Windows devices yet.`),le.forEach(o),ta=m(co),wt=n(co,"LI",{});var Dn=i(wt);oa=r(Dn,"Patch size of 4 is only supported at the moment."),Dn.forEach(o),co.forEach(o),Vt=m(e),Q=n(e,"IMG",{src:!0,alt:!0,width:!0}),Kt=m(e),X=n(e,"SMALL",{});var ho=i(X);aa=r(ho,`Neighborhood Attention compared to other attention patterns.
Taken from the `),Ke=n(ho,"A",{href:!0});var Wn=i(Ke);na=r(Wn,"original paper"),Wn.forEach(o),sa=r(ho,"."),ho.forEach(o),Bt=m(e),S=n(e,"P",{});var ot=i(S);ra=r(ot,"This model was contributed by "),be=n(ot,"A",{href:!0,rel:!0});var Hn=i(be);ia=r(Hn,"Ali Hassani"),Hn.forEach(o),la=r(ot,`.
The original code can be found `),ve=n(ot,"A",{href:!0,rel:!0});var Un=i(ve);da=r(Un,"here"),Un.forEach(o),ca=r(ot,"."),ot.forEach(o),Jt=m(e),L=n(e,"H2",{class:!0});var po=i(L);Z=n(po,"A",{id:!0,class:!0,href:!0});var Rn=i(Z);Nt=n(Rn,"SPAN",{});var Vn=i(Nt);N(we.$$.fragment,Vn),Vn.forEach(o),Rn.forEach(o),ha=m(po),$t=n(po,"SPAN",{});var Kn=i($t);pa=r(Kn,"Resources"),Kn.forEach(o),po.forEach(o),Gt=m(e),Be=n(e,"P",{});var Bn=i(Be);ma=r(Bn,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with NAT."),Bn.forEach(o),Yt=m(e),N(Ne.$$.fragment,e),Qt=m(e),Je=n(e,"UL",{});var Jn=i(Je);z=n(Jn,"LI",{});var Le=i(z);Ge=n(Le,"A",{href:!0});var Gn=i(Ge);fa=r(Gn,"NatForImageClassification"),Gn.forEach(o),ua=r(Le," is supported by this "),$e=n(Le,"A",{href:!0,rel:!0});var Yn=i($e);ga=r(Yn,"example script"),Yn.forEach(o),_a=r(Le," and "),ye=n(Le,"A",{href:!0,rel:!0});var Qn=i(ye);ba=r(Qn,"notebook"),Qn.forEach(o),va=r(Le,"."),Le.forEach(o),Jn.forEach(o),Xt=m(e),Ye=n(e,"P",{});var Xn=i(Ye);wa=r(Xn,"If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Xn.forEach(o),Zt=m(e),D=n(e,"H2",{class:!0});var mo=i(D);ee=n(mo,"A",{id:!0,class:!0,href:!0});var Zn=i(ee);yt=n(Zn,"SPAN",{});var es=i(yt);N(Te.$$.fragment,es),es.forEach(o),Zn.forEach(o),Na=m(mo),Tt=n(mo,"SPAN",{});var ts=i(Tt);$a=r(ts,"NatConfig"),ts.forEach(o),mo.forEach(o),eo=m(e),x=n(e,"DIV",{class:!0});var de=i(x);N(Ae.$$.fragment,de),ya=m(de),W=n(de,"P",{});var at=i(W);Ta=r(at,"This is the configuration class to store the configuration of a "),Qe=n(at,"A",{href:!0});var os=i(Qe);Aa=r(os,"NatModel"),os.forEach(o),Ea=r(at,`. 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
`),Ee=n(at,"A",{href:!0,rel:!0});var as=i(Ee);Ca=r(as,"shi-labs/nat-mini-in1k-224"),as.forEach(o),xa=r(at," architecture."),at.forEach(o),ka=m(de),H=n(de,"P",{});var nt=i(H);Pa=r(nt,"Configuration objects inherit from "),Xe=n(nt,"A",{href:!0});var ns=i(Xe);Ia=r(ns,"PretrainedConfig"),ns.forEach(o),ja=r(nt,` and can be used to control the model outputs. Read the
documentation from `),Ze=n(nt,"A",{href:!0});var ss=i(Ze);Ma=r(ss,"PretrainedConfig"),ss.forEach(o),qa=r(nt," for more information."),nt.forEach(o),Fa=m(de),N(te.$$.fragment,de),de.forEach(o),to=m(e),U=n(e,"H2",{class:!0});var fo=i(U);oe=n(fo,"A",{id:!0,class:!0,href:!0});var rs=i(oe);At=n(rs,"SPAN",{});var is=i(At);N(Ce.$$.fragment,is),is.forEach(o),rs.forEach(o),Sa=m(fo),Et=n(fo,"SPAN",{});var ls=i(Et);za=r(ls,"NatModel"),ls.forEach(o),fo.forEach(o),oo=m(e),F=n(e,"DIV",{class:!0});var st=i(F);N(xe.$$.fragment,st),Oa=m(st),ke=n(st,"P",{});var uo=i(ke);La=r(uo,`The bare Nat Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Pe=n(uo,"A",{href:!0,rel:!0});var ds=i(Pe);Da=r(ds,"torch.nn.Module"),ds.forEach(o),Wa=r(uo,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),uo.forEach(o),Ha=m(st),I=n(st,"DIV",{class:!0});var ce=i(I);N(Ie.$$.fragment,ce),Ua=m(ce),R=n(ce,"P",{});var rt=i(R);Ra=r(rt,"The "),et=n(rt,"A",{href:!0});var cs=i(et);Va=r(cs,"NatModel"),cs.forEach(o),Ka=r(rt," forward method, overrides the "),Ct=n(rt,"CODE",{});var hs=i(Ct);Ba=r(hs,"__call__"),hs.forEach(o),Ja=r(rt," special method."),rt.forEach(o),Ga=m(ce),N(ae.$$.fragment,ce),Ya=m(ce),N(ne.$$.fragment,ce),ce.forEach(o),st.forEach(o),ao=m(e),V=n(e,"H2",{class:!0});var go=i(V);se=n(go,"A",{id:!0,class:!0,href:!0});var ps=i(se);xt=n(ps,"SPAN",{});var ms=i(xt);N(je.$$.fragment,ms),ms.forEach(o),ps.forEach(o),Qa=m(go),kt=n(go,"SPAN",{});var fs=i(kt);Xa=r(fs,"NatForImageClassification"),fs.forEach(o),go.forEach(o),no=m(e),k=n(e,"DIV",{class:!0});var he=i(k);N(Me.$$.fragment,he),Za=m(he),Pt=n(he,"P",{});var us=i(Pt);en=r(us,`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.`),us.forEach(o),tn=m(he),qe=n(he,"P",{});var _o=i(qe);on=r(_o,"This model is a PyTorch "),Fe=n(_o,"A",{href:!0,rel:!0});var gs=i(Fe);an=r(gs,"torch.nn.Module"),gs.forEach(o),nn=r(_o,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),_o.forEach(o),sn=m(he),j=n(he,"DIV",{class:!0});var pe=i(j);N(Se.$$.fragment,pe),rn=m(pe),K=n(pe,"P",{});var it=i(K);ln=r(it,"The "),tt=n(it,"A",{href:!0});var _s=i(tt);dn=r(_s,"NatForImageClassification"),_s.forEach(o),cn=r(it," forward method, overrides the "),It=n(it,"CODE",{});var bs=i(It);hn=r(bs,"__call__"),bs.forEach(o),pn=r(it," special method."),it.forEach(o),mn=m(pe),N(re.$$.fragment,pe),fn=m(pe),N(ie.$$.fragment,pe),pe.forEach(o),he.forEach(o),this.h()},h(){c(f,"name","hf:doc:metadata"),c(f,"content",JSON.stringify(Ms)),c(u,"id","neighborhood-attention-transformer"),c(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"),c(u,"href","#neighborhood-attention-transformer"),c(_,"class","relative group"),c(B,"id","overview"),c(B,"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"),c(B,"href","#overview"),c(O,"class","relative group"),c(fe,"href","https://arxiv.org/abs/2204.07143"),c(fe,"rel","nofollow"),c(Re,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor"),c(ge,"href","https://github.com/SHI-Labs/NATTEN/"),c(ge,"rel","nofollow"),c(_e,"href","https://shi-labs.com/natten"),c(_e,"rel","nofollow"),Ts(Q.src,bn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/neighborhood-attention-pattern.jpg")||c(Q,"src",bn),c(Q,"alt","drawing"),c(Q,"width","600"),c(Ke,"href","https://arxiv.org/abs/2204.07143"),c(be,"href","https://huggingface.co/alihassanijr"),c(be,"rel","nofollow"),c(ve,"href","https://github.com/SHI-Labs/Neighborhood-Attention-Transformer"),c(ve,"rel","nofollow"),c(Z,"id","resources"),c(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"),c(Z,"href","#resources"),c(L,"class","relative group"),c(Ge,"href","/docs/transformers/main/en/model_doc/nat#transformers.NatForImageClassification"),c($e,"href","https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification"),c($e,"rel","nofollow"),c(ye,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb"),c(ye,"rel","nofollow"),c(ee,"id","transformers.NatConfig"),c(ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ee,"href","#transformers.NatConfig"),c(D,"class","relative group"),c(Qe,"href","/docs/transformers/main/en/model_doc/nat#transformers.NatModel"),c(Ee,"href","https://huggingface.co/shi-labs/nat-mini-in1k-224"),c(Ee,"rel","nofollow"),c(Xe,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Ze,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(oe,"id","transformers.NatModel"),c(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"),c(oe,"href","#transformers.NatModel"),c(U,"class","relative group"),c(Pe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Pe,"rel","nofollow"),c(et,"href","/docs/transformers/main/en/model_doc/nat#transformers.NatModel"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(se,"id","transformers.NatForImageClassification"),c(se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(se,"href","#transformers.NatForImageClassification"),c(V,"class","relative group"),c(Fe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Fe,"rel","nofollow"),c(tt,"href","/docs/transformers/main/en/model_doc/nat#transformers.NatForImageClassification"),c(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(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(e,d){t(document.head,f),h(e,v,d),h(e,_,d),t(_,u),t(u,b),$(l,b,null),t(_,g),t(_,M),t(M,bo),h(e,St,d),h(e,O,d),t(O,B),t(B,dt),$(me,dt,null),t(O,vo),t(O,ct),t(ct,wo),h(e,zt,d),h(e,J,d),t(J,No),t(J,fe),t(fe,$o),t(J,yo),h(e,Ot,d),h(e,De,d),t(De,To),h(e,Lt,d),h(e,We,d),t(We,Ao),h(e,Dt,d),h(e,He,d),t(He,ht),t(ht,Eo),h(e,Wt,d),h(e,Ue,d),t(Ue,Co),h(e,Ht,d),h(e,G,d),t(G,ue),t(ue,xo),t(ue,Re),t(Re,ko),t(ue,Po),t(G,Io),t(G,E),t(E,jo),t(E,pt),t(pt,Mo),t(E,qo),t(E,mt),t(mt,Fo),t(E,So),t(E,ft),t(ft,zo),t(E,Oo),t(E,ut),t(ut,Lo),t(E,Do),t(E,gt),t(gt,Wo),t(E,Ho),t(E,_t),t(_t,Uo),t(E,Ro),t(E,bt),t(bt,Vo),t(E,Ko),h(e,Ut,d),h(e,Ve,d),t(Ve,Bo),h(e,Rt,d),h(e,Y,d),t(Y,q),t(q,Jo),t(q,ge),t(ge,Go),t(q,Yo),t(q,_e),t(_e,Qo),t(q,Xo),t(q,vt),t(vt,Zo),t(q,ea),t(Y,ta),t(Y,wt),t(wt,oa),h(e,Vt,d),h(e,Q,d),h(e,Kt,d),h(e,X,d),t(X,aa),t(X,Ke),t(Ke,na),t(X,sa),h(e,Bt,d),h(e,S,d),t(S,ra),t(S,be),t(be,ia),t(S,la),t(S,ve),t(ve,da),t(S,ca),h(e,Jt,d),h(e,L,d),t(L,Z),t(Z,Nt),$(we,Nt,null),t(L,ha),t(L,$t),t($t,pa),h(e,Gt,d),h(e,Be,d),t(Be,ma),h(e,Yt,d),$(Ne,e,d),h(e,Qt,d),h(e,Je,d),t(Je,z),t(z,Ge),t(Ge,fa),t(z,ua),t(z,$e),t($e,ga),t(z,_a),t(z,ye),t(ye,ba),t(z,va),h(e,Xt,d),h(e,Ye,d),t(Ye,wa),h(e,Zt,d),h(e,D,d),t(D,ee),t(ee,yt),$(Te,yt,null),t(D,Na),t(D,Tt),t(Tt,$a),h(e,eo,d),h(e,x,d),$(Ae,x,null),t(x,ya),t(x,W),t(W,Ta),t(W,Qe),t(Qe,Aa),t(W,Ea),t(W,Ee),t(Ee,Ca),t(W,xa),t(x,ka),t(x,H),t(H,Pa),t(H,Xe),t(Xe,Ia),t(H,ja),t(H,Ze),t(Ze,Ma),t(H,qa),t(x,Fa),$(te,x,null),h(e,to,d),h(e,U,d),t(U,oe),t(oe,At),$(Ce,At,null),t(U,Sa),t(U,Et),t(Et,za),h(e,oo,d),h(e,F,d),$(xe,F,null),t(F,Oa),t(F,ke),t(ke,La),t(ke,Pe),t(Pe,Da),t(ke,Wa),t(F,Ha),t(F,I),$(Ie,I,null),t(I,Ua),t(I,R),t(R,Ra),t(R,et),t(et,Va),t(R,Ka),t(R,Ct),t(Ct,Ba),t(R,Ja),t(I,Ga),$(ae,I,null),t(I,Ya),$(ne,I,null),h(e,ao,d),h(e,V,d),t(V,se),t(se,xt),$(je,xt,null),t(V,Qa),t(V,kt),t(kt,Xa),h(e,no,d),h(e,k,d),$(Me,k,null),t(k,Za),t(k,Pt),t(Pt,en),t(k,tn),t(k,qe),t(qe,on),t(qe,Fe),t(Fe,an),t(qe,nn),t(k,sn),t(k,j),$(Se,j,null),t(j,rn),t(j,K),t(K,ln),t(K,tt),t(tt,dn),t(K,cn),t(K,It),t(It,hn),t(K,pn),t(j,mn),$(re,j,null),t(j,fn),$(ie,j,null),so=!0},p(e,[d]){const ze={};d&2&&(ze.$$scope={dirty:d,ctx:e}),te.$set(ze);const jt={};d&2&&(jt.$$scope={dirty:d,ctx:e}),ae.$set(jt);const Mt={};d&2&&(Mt.$$scope={dirty:d,ctx:e}),ne.$set(Mt);const qt={};d&2&&(qt.$$scope={dirty:d,ctx:e}),re.$set(qt);const Oe={};d&2&&(Oe.$$scope={dirty:d,ctx:e}),ie.$set(Oe)},i(e){so||(y(l.$$.fragment,e),y(me.$$.fragment,e),y(we.$$.fragment,e),y(Ne.$$.fragment,e),y(Te.$$.fragment,e),y(Ae.$$.fragment,e),y(te.$$.fragment,e),y(Ce.$$.fragment,e),y(xe.$$.fragment,e),y(Ie.$$.fragment,e),y(ae.$$.fragment,e),y(ne.$$.fragment,e),y(je.$$.fragment,e),y(Me.$$.fragment,e),y(Se.$$.fragment,e),y(re.$$.fragment,e),y(ie.$$.fragment,e),so=!0)},o(e){T(l.$$.fragment,e),T(me.$$.fragment,e),T(we.$$.fragment,e),T(Ne.$$.fragment,e),T(Te.$$.fragment,e),T(Ae.$$.fragment,e),T(te.$$.fragment,e),T(Ce.$$.fragment,e),T(xe.$$.fragment,e),T(Ie.$$.fragment,e),T(ae.$$.fragment,e),T(ne.$$.fragment,e),T(je.$$.fragment,e),T(Me.$$.fragment,e),T(Se.$$.fragment,e),T(re.$$.fragment,e),T(ie.$$.fragment,e),so=!1},d(e){o(f),e&&o(v),e&&o(_),A(l),e&&o(St),e&&o(O),A(me),e&&o(zt),e&&o(J),e&&o(Ot),e&&o(De),e&&o(Lt),e&&o(We),e&&o(Dt),e&&o(He),e&&o(Wt),e&&o(Ue),e&&o(Ht),e&&o(G),e&&o(Ut),e&&o(Ve),e&&o(Rt),e&&o(Y),e&&o(Vt),e&&o(Q),e&&o(Kt),e&&o(X),e&&o(Bt),e&&o(S),e&&o(Jt),e&&o(L),A(we),e&&o(Gt),e&&o(Be),e&&o(Yt),A(Ne,e),e&&o(Qt),e&&o(Je),e&&o(Xt),e&&o(Ye),e&&o(Zt),e&&o(D),A(Te),e&&o(eo),e&&o(x),A(Ae),A(te),e&&o(to),e&&o(U),A(Ce),e&&o(oo),e&&o(F),A(xe),A(Ie),A(ae),A(ne),e&&o(ao),e&&o(V),A(je),e&&o(no),e&&o(k),A(Me),A(Se),A(re),A(ie)}}}const Ms={local:"neighborhood-attention-transformer",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.NatConfig",title:"NatConfig"},{local:"transformers.NatModel",title:"NatModel"},{local:"transformers.NatForImageClassification",title:"NatForImageClassification"}],title:"Neighborhood Attention Transformer"};function qs(P){return As(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Hs extends ws{constructor(f){super();Ns(this,f,qs,js,$s,{})}}export{Hs as default,Ms as metadata};
