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