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