import{S as ks,i as js,s as xs,e as s,k as p,w,t as a,M as Fs,c as r,d as o,m as f,a as i,x as y,h as n,b as d,N as Ws,G as t,g as h,y as T,q as $,o as M,B as E,v as Us,L as Cn}from"../../chunks/vendor-hf-doc-builder.js";import{T as Is}from"../../chunks/Tip-hf-doc-builder.js";import{D as Pt}from"../../chunks/Docstring-hf-doc-builder.js";import{C as An}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ht}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Dn}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Js}from"../../chunks/PipelineTag-hf-doc-builder.js";function Ps(I){let m,v,_,u,b;return u=new An({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpbmF0Q29uZmlnJTJDJTIwRGluYXRNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBEaW5hdCUyMHNoaS1sYWJzJTJGZGluYXQtbWluaS1pbjFrLTIyNCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBEaW5hdENvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBzaGktbGFicyUyRmRpbmF0LW1pbmktaW4xay0yMjQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMERpbmF0TW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DinatConfig, DinatModel

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the shi-labs/dinat-mini-in1k-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DinatModel(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=s("p"),v=a("Example:"),_=p(),w(u.$$.fragment)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Example:"),g.forEach(o),_=f(l),y(u.$$.fragment,l)},m(l,g){h(l,m,g),t(m,v),h(l,_,g),T(u,l,g),b=!0},p:Cn,i(l){b||($(u.$$.fragment,l),b=!0)},o(l){M(u.$$.fragment,l),b=!1},d(l){l&&o(m),l&&o(_),E(u,l)}}}function Zs(I){let m,v,_,u,b;return{c(){m=s("p"),v=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s("code"),u=a("Module"),b=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(g,"CODE",{});var x=i(_);u=n(x,"Module"),x.forEach(o),b=n(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(o)},m(l,g){h(l,m,g),t(m,v),t(m,_),t(_,u),t(m,b)},d(l){l&&o(m)}}}function zs(I){let m,v,_,u,b;return u=new An({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMERpbmF0TW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMnNoaS1sYWJzJTJGZGluYXQtbWluaS1pbjFrLTIyNCUyMiklMEFtb2RlbCUyMCUzRCUyMERpbmF0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnNoaS1sYWJzJTJGZGluYXQtbWluaS1pbjFrLTIyNCUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZSUwQWxpc3QobGFzdF9oaWRkZW5fc3RhdGVzLnNoYXBlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, DinatModel
<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/dinat-mini-in1k-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DinatModel.from_pretrained(<span class="hljs-string">&quot;shi-labs/dinat-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=s("p"),v=a("Example:"),_=p(),w(u.$$.fragment)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Example:"),g.forEach(o),_=f(l),y(u.$$.fragment,l)},m(l,g){h(l,m,g),t(m,v),h(l,_,g),T(u,l,g),b=!0},p:Cn,i(l){b||($(u.$$.fragment,l),b=!0)},o(l){M(u.$$.fragment,l),b=!1},d(l){l&&o(m),l&&o(_),E(u,l)}}}function Ss(I){let m,v,_,u,b;return{c(){m=s("p"),v=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s("code"),u=a("Module"),b=a(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(g,"CODE",{});var x=i(_);u=n(x,"Module"),x.forEach(o),b=n(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(o)},m(l,g){h(l,m,g),t(m,v),t(m,_),t(_,u),t(m,b)},d(l){l&&o(m)}}}function Gs(I){let m,v,_,u,b;return u=new An({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMERpbmF0Rm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJodWdnaW5nZmFjZSUyRmNhdHMtaW1hZ2UlMjIpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCU1QiUyMmltYWdlJTIyJTVEJTVCMCU1RCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyc2hpLWxhYnMlMkZkaW5hdC1taW5pLWluMWstMjI0JTIyKSUwQW1vZGVsJTIwJTNEJTIwRGluYXRGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJzaGktbGFicyUyRmRpbmF0LW1pbmktaW4xay0yMjQlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQSUyMyUyMG1vZGVsJTIwcHJlZGljdHMlMjBvbmUlMjBvZiUyMHRoZSUyMDEwMDAlMjBJbWFnZU5ldCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfbGFiZWwlMjAlM0QlMjBsb2dpdHMuYXJnbWF4KC0xKS5pdGVtKCklMEFwcmludChtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfbGFiZWwlNUQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, DinatForImageClassification
<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/dinat-mini-in1k-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DinatForImageClassification.from_pretrained(<span class="hljs-string">&quot;shi-labs/dinat-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])
tabby, tabby cat`}}),{c(){m=s("p"),v=a("Example:"),_=p(),w(u.$$.fragment)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Example:"),g.forEach(o),_=f(l),y(u.$$.fragment,l)},m(l,g){h(l,m,g),t(m,v),h(l,_,g),T(u,l,g),b=!0},p:Cn,i(l){b||($(u.$$.fragment,l),b=!0)},o(l){M(u.$$.fragment,l),b=!1},d(l){l&&o(m),l&&o(_),E(u,l)}}}function Rs(I){let m,v,_,u,b,l,g,x,$o,Zt,P,O,pt,ue,Mo,ft,Eo,zt,Q,Do,ge,Co,Ao,St,X,No,Ge,Io,ko,Gt,Re,jo,Rt,qe,mt,xo,qt,Be,Fo,Bt,Y,_e,Wo,Le,Uo,Jo,Po,D,Zo,ut,zo,So,gt,Go,Ro,_t,qo,Bo,bt,Lo,Oo,vt,Qo,Xo,wt,Yo,Vo,yt,Ho,Ko,Lt,Oe,ea,Ot,V,F,ta,be,oa,aa,ve,na,sa,Tt,ra,ia,la,$t,da,Qt,H,Nn,Xt,K,ca,Qe,ha,pa,Yt,U,fa,we,ma,ua,ye,ga,_a,Vt,Z,ee,Mt,Te,ba,Et,va,Ht,Xe,wa,Kt,$e,eo,te,J,Ye,ya,Ta,Me,$a,Ma,Ee,Ea,Da,Ca,Ve,Aa,He,Na,to,Ke,Ia,oo,z,oe,Dt,De,ka,Ct,ja,ao,A,Ce,xa,S,Fa,et,Wa,Ua,Ae,Ja,Pa,Za,G,za,tt,Sa,Ga,ot,Ra,qa,Ba,ae,no,R,ne,At,Ne,La,Nt,Oa,so,W,Ie,Qa,ke,Xa,je,Ya,Va,Ha,k,xe,Ka,q,en,at,tn,on,It,an,nn,sn,se,rn,re,ro,B,ie,kt,Fe,ln,jt,dn,io,N,We,cn,xt,hn,pn,Ue,fn,Je,mn,un,gn,j,Pe,_n,L,bn,nt,vn,wn,Ft,yn,Tn,$n,le,Mn,de,lo;return l=new ht({}),ue=new ht({}),Te=new ht({}),$e=new Js({props:{pipeline:"image-classification"}}),De=new ht({}),Ce=new Pt({props:{name:"class transformers.DinatConfig",anchor:"transformers.DinatConfig",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:"dilations",val:" = [[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]"},{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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.dilations",description:`<strong>dilations</strong> (<code>List[List[int]]</code>, <em>optional</em>, defaults to <code>[[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]</code>) &#x2014;
Dilation value of each NA layer in the Transformer encoder.`,name:"dilations"},{anchor:"transformers.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.DinatConfig.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.30.0/src/transformers/models/dinat/configuration_dinat.py#L30"}}),ae=new Dn({props:{anchor:"transformers.DinatConfig.example",$$slots:{default:[Ps]},$$scope:{ctx:I}}}),Ne=new ht({}),Ie=new Pt({props:{name:"class transformers.DinatModel",anchor:"transformers.DinatModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.DinatModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/dinat#transformers.DinatConfig">DinatConfig</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.30.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.30.0/src/transformers/models/dinat/modeling_dinat.py#L700"}}),xe=new Pt({props:{name:"forward",anchor:"transformers.DinatModel.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.DinatModel.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.30.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.DinatModel.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.DinatModel.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.DinatModel.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.30.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.30.0/src/transformers/models/dinat/modeling_dinat.py#L730",returnDescription:`
<p>A <code>transformers.models.dinat.modeling_dinat.DinatModelOutput</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.30.0/en/model_doc/dinat#transformers.DinatConfig"
>DinatConfig</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.dinat.modeling_dinat.DinatModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),se=new Is({props:{$$slots:{default:[Zs]},$$scope:{ctx:I}}}),re=new Dn({props:{anchor:"transformers.DinatModel.forward.example",$$slots:{default:[zs]},$$scope:{ctx:I}}}),Fe=new ht({}),We=new Pt({props:{name:"class transformers.DinatForImageClassification",anchor:"transformers.DinatForImageClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.DinatForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/dinat#transformers.DinatConfig">DinatConfig</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.30.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.30.0/src/transformers/models/dinat/modeling_dinat.py#L792"}}),Pe=new Pt({props:{name:"forward",anchor:"transformers.DinatForImageClassification.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.DinatForImageClassification.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.30.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.DinatForImageClassification.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.DinatForImageClassification.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.DinatForImageClassification.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.30.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.DinatForImageClassification.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.30.0/src/transformers/models/dinat/modeling_dinat.py#L809",returnDescription:`
<p>A <code>transformers.models.dinat.modeling_dinat.DinatImageClassifierOutput</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.30.0/en/model_doc/dinat#transformers.DinatConfig"
>DinatConfig</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.dinat.modeling_dinat.DinatImageClassifierOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),le=new Is({props:{$$slots:{default:[Ss]},$$scope:{ctx:I}}}),de=new Dn({props:{anchor:"transformers.DinatForImageClassification.forward.example",$$slots:{default:[Gs]},$$scope:{ctx:I}}}),{c(){m=s("meta"),v=p(),_=s("h1"),u=s("a"),b=s("span"),w(l.$$.fragment),g=p(),x=s("span"),$o=a("Dilated Neighborhood Attention Transformer"),Zt=p(),P=s("h2"),O=s("a"),pt=s("span"),w(ue.$$.fragment),Mo=p(),ft=s("span"),Eo=a("Overview"),zt=p(),Q=s("p"),Do=a("DiNAT was proposed in "),ge=s("a"),Co=a("Dilated Neighborhood Attention Transformer"),Ao=a(`
by Ali Hassani and Humphrey Shi.`),St=p(),X=s("p"),No=a("It extends "),Ge=s("a"),Io=a("NAT"),ko=a(` by adding a Dilated Neighborhood Attention pattern to capture global context,
and shows significant performance improvements over it.`),Gt=p(),Re=s("p"),jo=a("The abstract from the paper is the following:"),Rt=p(),qe=s("p"),mt=s("em"),xo=a(`Transformers are quickly becoming one of the most heavily applied deep learning architectures across modalities,
domains, and tasks. In vision, on top of ongoing efforts into plain transformers, hierarchical transformers have
also gained significant attention, thanks to their performance and easy integration into existing frameworks.
These models typically employ localized attention mechanisms, such as the sliding-window Neighborhood Attention (NA)
or Swin Transformer\u2019s Shifted Window Self Attention. While effective at reducing self attention\u2019s quadratic complexity,
local attention weakens two of the most desirable properties of self attention: long range inter-dependency modeling,
and global receptive field. In this paper, we introduce Dilated Neighborhood Attention (DiNA), a natural, flexible and
efficient extension to NA that can capture more global context and expand receptive fields exponentially at no
additional cost. NA\u2019s local attention and DiNA\u2019s sparse global attention complement each other, and therefore we
introduce Dilated Neighborhood Attention Transformer (DiNAT), a new hierarchical vision transformer built upon both.
DiNAT variants enjoy significant improvements over strong baselines such as NAT, Swin, and ConvNeXt.
Our large model is faster and ahead of its Swin counterpart by 1.5% box AP in COCO object detection,
1.3% mask AP in COCO instance segmentation, and 1.1% mIoU in ADE20K semantic segmentation.
Paired with new frameworks, our large variant is the new state of the art panoptic segmentation model on COCO (58.2 PQ)
and ADE20K (48.5 PQ), and instance segmentation model on Cityscapes (44.5 AP) and ADE20K (35.4 AP) (no extra data).
It also matches the state of the art specialized semantic segmentation models on ADE20K (58.2 mIoU),
and ranks second on Cityscapes (84.5 mIoU) (no extra data).`),qt=p(),Be=s("p"),Fo=a("Tips:"),Bt=p(),Y=s("ul"),_e=s("li"),Wo=a("One can use the "),Le=s("a"),Uo=a("AutoImageProcessor"),Jo=a(" API to prepare images for the model."),Po=p(),D=s("li"),Zo=a("DiNAT can be used as a "),ut=s("em"),zo=a("backbone"),So=a(". When "),gt=s("code"),Go=a("output_hidden_states = True"),Ro=a(`,
it will output both `),_t=s("code"),qo=a("hidden_states"),Bo=a(" and "),bt=s("code"),Lo=a("reshaped_hidden_states"),Oo=a(". The "),vt=s("code"),Qo=a("reshaped_hidden_states"),Xo=a(" have a shape of "),wt=s("code"),Yo=a("(batch, num_channels, height, width)"),Vo=a(" rather than "),yt=s("code"),Ho=a("(batch_size, height, width, num_channels)"),Ko=a("."),Lt=p(),Oe=s("p"),ea=a("Notes:"),Ot=p(),V=s("ul"),F=s("li"),ta=a("DiNAT depends on "),be=s("a"),oa=a("NATTEN"),aa=a(`\u2019s implementation of Neighborhood Attention and Dilated Neighborhood Attention.
You can install it with pre-built wheels for Linux by referring to `),ve=s("a"),na=a("shi-labs.com/natten"),sa=a(", or build on your system by running "),Tt=s("code"),ra=a("pip install natten"),ia=a(`.
Note that the latter will likely take time to compile. NATTEN does not support Windows devices yet.`),la=p(),$t=s("li"),da=a("Patch size of 4 is only supported at the moment."),Qt=p(),H=s("img"),Xt=p(),K=s("small"),ca=a(`Neighborhood Attention with different dilation values.
Taken from the `),Qe=s("a"),ha=a("original paper"),pa=a("."),Yt=p(),U=s("p"),fa=a("This model was contributed by "),we=s("a"),ma=a("Ali Hassani"),ua=a(`.
The original code can be found `),ye=s("a"),ga=a("here"),_a=a("."),Vt=p(),Z=s("h2"),ee=s("a"),Mt=s("span"),w(Te.$$.fragment),ba=p(),Et=s("span"),va=a("Resources"),Ht=p(),Xe=s("p"),wa=a("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with DiNAT."),Kt=p(),w($e.$$.fragment),eo=p(),te=s("ul"),J=s("li"),Ye=s("a"),ya=a("DinatForImageClassification"),Ta=a(" is supported by this "),Me=s("a"),$a=a("example script"),Ma=a(" and "),Ee=s("a"),Ea=a("notebook"),Da=a("."),Ca=p(),Ve=s("li"),Aa=a("See also: "),He=s("a"),Na=a("Image classification task guide"),to=p(),Ke=s("p"),Ia=a("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."),oo=p(),z=s("h2"),oe=s("a"),Dt=s("span"),w(De.$$.fragment),ka=p(),Ct=s("span"),ja=a("DinatConfig"),ao=p(),A=s("div"),w(Ce.$$.fragment),xa=p(),S=s("p"),Fa=a("This is the configuration class to store the configuration of a "),et=s("a"),Wa=a("DinatModel"),Ua=a(`. It is used to instantiate a Dinat
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 Dinat
`),Ae=s("a"),Ja=a("shi-labs/dinat-mini-in1k-224"),Pa=a(" architecture."),Za=p(),G=s("p"),za=a("Configuration objects inherit from "),tt=s("a"),Sa=a("PretrainedConfig"),Ga=a(` and can be used to control the model outputs. Read the
documentation from `),ot=s("a"),Ra=a("PretrainedConfig"),qa=a(" for more information."),Ba=p(),w(ae.$$.fragment),no=p(),R=s("h2"),ne=s("a"),At=s("span"),w(Ne.$$.fragment),La=p(),Nt=s("span"),Oa=a("DinatModel"),so=p(),W=s("div"),w(Ie.$$.fragment),Qa=p(),ke=s("p"),Xa=a(`The bare Dinat Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),je=s("a"),Ya=a("torch.nn.Module"),Va=a(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ha=p(),k=s("div"),w(xe.$$.fragment),Ka=p(),q=s("p"),en=a("The "),at=s("a"),tn=a("DinatModel"),on=a(" forward method, overrides the "),It=s("code"),an=a("__call__"),nn=a(" special method."),sn=p(),w(se.$$.fragment),rn=p(),w(re.$$.fragment),ro=p(),B=s("h2"),ie=s("a"),kt=s("span"),w(Fe.$$.fragment),ln=p(),jt=s("span"),dn=a("DinatForImageClassification"),io=p(),N=s("div"),w(We.$$.fragment),cn=p(),xt=s("p"),hn=a(`Dinat 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.`),pn=p(),Ue=s("p"),fn=a("This model is a PyTorch "),Je=s("a"),mn=a("torch.nn.Module"),un=a(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),gn=p(),j=s("div"),w(Pe.$$.fragment),_n=p(),L=s("p"),bn=a("The "),nt=s("a"),vn=a("DinatForImageClassification"),wn=a(" forward method, overrides the "),Ft=s("code"),yn=a("__call__"),Tn=a(" special method."),$n=p(),w(le.$$.fragment),Mn=p(),w(de.$$.fragment),this.h()},l(e){const c=Fs('[data-svelte="svelte-1phssyn"]',document.head);m=r(c,"META",{name:!0,content:!0}),c.forEach(o),v=f(e),_=r(e,"H1",{class:!0});var Ze=i(_);u=r(Ze,"A",{id:!0,class:!0,href:!0});var Wt=i(u);b=r(Wt,"SPAN",{});var Ut=i(b);y(l.$$.fragment,Ut),Ut.forEach(o),Wt.forEach(o),g=f(Ze),x=r(Ze,"SPAN",{});var Jt=i(x);$o=n(Jt,"Dilated Neighborhood Attention Transformer"),Jt.forEach(o),Ze.forEach(o),Zt=f(e),P=r(e,"H2",{class:!0});var ze=i(P);O=r(ze,"A",{id:!0,class:!0,href:!0});var In=i(O);pt=r(In,"SPAN",{});var kn=i(pt);y(ue.$$.fragment,kn),kn.forEach(o),In.forEach(o),Mo=f(ze),ft=r(ze,"SPAN",{});var jn=i(ft);Eo=n(jn,"Overview"),jn.forEach(o),ze.forEach(o),zt=f(e),Q=r(e,"P",{});var co=i(Q);Do=n(co,"DiNAT was proposed in "),ge=r(co,"A",{href:!0,rel:!0});var xn=i(ge);Co=n(xn,"Dilated Neighborhood Attention Transformer"),xn.forEach(o),Ao=n(co,`
by Ali Hassani and Humphrey Shi.`),co.forEach(o),St=f(e),X=r(e,"P",{});var ho=i(X);No=n(ho,"It extends "),Ge=r(ho,"A",{href:!0});var Fn=i(Ge);Io=n(Fn,"NAT"),Fn.forEach(o),ko=n(ho,` by adding a Dilated Neighborhood Attention pattern to capture global context,
and shows significant performance improvements over it.`),ho.forEach(o),Gt=f(e),Re=r(e,"P",{});var Wn=i(Re);jo=n(Wn,"The abstract from the paper is the following:"),Wn.forEach(o),Rt=f(e),qe=r(e,"P",{});var Un=i(qe);mt=r(Un,"EM",{});var Jn=i(mt);xo=n(Jn,`Transformers are quickly becoming one of the most heavily applied deep learning architectures across modalities,
domains, and tasks. In vision, on top of ongoing efforts into plain transformers, hierarchical transformers have
also gained significant attention, thanks to their performance and easy integration into existing frameworks.
These models typically employ localized attention mechanisms, such as the sliding-window Neighborhood Attention (NA)
or Swin Transformer\u2019s Shifted Window Self Attention. While effective at reducing self attention\u2019s quadratic complexity,
local attention weakens two of the most desirable properties of self attention: long range inter-dependency modeling,
and global receptive field. In this paper, we introduce Dilated Neighborhood Attention (DiNA), a natural, flexible and
efficient extension to NA that can capture more global context and expand receptive fields exponentially at no
additional cost. NA\u2019s local attention and DiNA\u2019s sparse global attention complement each other, and therefore we
introduce Dilated Neighborhood Attention Transformer (DiNAT), a new hierarchical vision transformer built upon both.
DiNAT variants enjoy significant improvements over strong baselines such as NAT, Swin, and ConvNeXt.
Our large model is faster and ahead of its Swin counterpart by 1.5% box AP in COCO object detection,
1.3% mask AP in COCO instance segmentation, and 1.1% mIoU in ADE20K semantic segmentation.
Paired with new frameworks, our large variant is the new state of the art panoptic segmentation model on COCO (58.2 PQ)
and ADE20K (48.5 PQ), and instance segmentation model on Cityscapes (44.5 AP) and ADE20K (35.4 AP) (no extra data).
It also matches the state of the art specialized semantic segmentation models on ADE20K (58.2 mIoU),
and ranks second on Cityscapes (84.5 mIoU) (no extra data).`),Jn.forEach(o),Un.forEach(o),qt=f(e),Be=r(e,"P",{});var Pn=i(Be);Fo=n(Pn,"Tips:"),Pn.forEach(o),Bt=f(e),Y=r(e,"UL",{});var po=i(Y);_e=r(po,"LI",{});var fo=i(_e);Wo=n(fo,"One can use the "),Le=r(fo,"A",{href:!0});var Zn=i(Le);Uo=n(Zn,"AutoImageProcessor"),Zn.forEach(o),Jo=n(fo," API to prepare images for the model."),fo.forEach(o),Po=f(po),D=r(po,"LI",{});var C=i(D);Zo=n(C,"DiNAT can be used as a "),ut=r(C,"EM",{});var zn=i(ut);zo=n(zn,"backbone"),zn.forEach(o),So=n(C,". When "),gt=r(C,"CODE",{});var Sn=i(gt);Go=n(Sn,"output_hidden_states = True"),Sn.forEach(o),Ro=n(C,`,
it will output both `),_t=r(C,"CODE",{});var Gn=i(_t);qo=n(Gn,"hidden_states"),Gn.forEach(o),Bo=n(C," and "),bt=r(C,"CODE",{});var Rn=i(bt);Lo=n(Rn,"reshaped_hidden_states"),Rn.forEach(o),Oo=n(C,". The "),vt=r(C,"CODE",{});var qn=i(vt);Qo=n(qn,"reshaped_hidden_states"),qn.forEach(o),Xo=n(C," have a shape of "),wt=r(C,"CODE",{});var Bn=i(wt);Yo=n(Bn,"(batch, num_channels, height, width)"),Bn.forEach(o),Vo=n(C," rather than "),yt=r(C,"CODE",{});var Ln=i(yt);Ho=n(Ln,"(batch_size, height, width, num_channels)"),Ln.forEach(o),Ko=n(C,"."),C.forEach(o),po.forEach(o),Lt=f(e),Oe=r(e,"P",{});var On=i(Oe);ea=n(On,"Notes:"),On.forEach(o),Ot=f(e),V=r(e,"UL",{});var mo=i(V);F=r(mo,"LI",{});var ce=i(F);ta=n(ce,"DiNAT depends on "),be=r(ce,"A",{href:!0,rel:!0});var Qn=i(be);oa=n(Qn,"NATTEN"),Qn.forEach(o),aa=n(ce,`\u2019s implementation of Neighborhood Attention and Dilated Neighborhood Attention.
You can install it with pre-built wheels for Linux by referring to `),ve=r(ce,"A",{href:!0,rel:!0});var Xn=i(ve);na=n(Xn,"shi-labs.com/natten"),Xn.forEach(o),sa=n(ce,", or build on your system by running "),Tt=r(ce,"CODE",{});var Yn=i(Tt);ra=n(Yn,"pip install natten"),Yn.forEach(o),ia=n(ce,`.
Note that the latter will likely take time to compile. NATTEN does not support Windows devices yet.`),ce.forEach(o),la=f(mo),$t=r(mo,"LI",{});var Vn=i($t);da=n(Vn,"Patch size of 4 is only supported at the moment."),Vn.forEach(o),mo.forEach(o),Qt=f(e),H=r(e,"IMG",{src:!0,alt:!0,width:!0}),Xt=f(e),K=r(e,"SMALL",{});var uo=i(K);ca=n(uo,`Neighborhood Attention with different dilation values.
Taken from the `),Qe=r(uo,"A",{href:!0});var Hn=i(Qe);ha=n(Hn,"original paper"),Hn.forEach(o),pa=n(uo,"."),uo.forEach(o),Yt=f(e),U=r(e,"P",{});var st=i(U);fa=n(st,"This model was contributed by "),we=r(st,"A",{href:!0,rel:!0});var Kn=i(we);ma=n(Kn,"Ali Hassani"),Kn.forEach(o),ua=n(st,`.
The original code can be found `),ye=r(st,"A",{href:!0,rel:!0});var es=i(ye);ga=n(es,"here"),es.forEach(o),_a=n(st,"."),st.forEach(o),Vt=f(e),Z=r(e,"H2",{class:!0});var go=i(Z);ee=r(go,"A",{id:!0,class:!0,href:!0});var ts=i(ee);Mt=r(ts,"SPAN",{});var os=i(Mt);y(Te.$$.fragment,os),os.forEach(o),ts.forEach(o),ba=f(go),Et=r(go,"SPAN",{});var as=i(Et);va=n(as,"Resources"),as.forEach(o),go.forEach(o),Ht=f(e),Xe=r(e,"P",{});var ns=i(Xe);wa=n(ns,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with DiNAT."),ns.forEach(o),Kt=f(e),y($e.$$.fragment,e),eo=f(e),te=r(e,"UL",{});var _o=i(te);J=r(_o,"LI",{});var Se=i(J);Ye=r(Se,"A",{href:!0});var ss=i(Ye);ya=n(ss,"DinatForImageClassification"),ss.forEach(o),Ta=n(Se," is supported by this "),Me=r(Se,"A",{href:!0,rel:!0});var rs=i(Me);$a=n(rs,"example script"),rs.forEach(o),Ma=n(Se," and "),Ee=r(Se,"A",{href:!0,rel:!0});var is=i(Ee);Ea=n(is,"notebook"),is.forEach(o),Da=n(Se,"."),Se.forEach(o),Ca=f(_o),Ve=r(_o,"LI",{});var En=i(Ve);Aa=n(En,"See also: "),He=r(En,"A",{href:!0});var ls=i(He);Na=n(ls,"Image classification task guide"),ls.forEach(o),En.forEach(o),_o.forEach(o),to=f(e),Ke=r(e,"P",{});var ds=i(Ke);Ia=n(ds,"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."),ds.forEach(o),oo=f(e),z=r(e,"H2",{class:!0});var bo=i(z);oe=r(bo,"A",{id:!0,class:!0,href:!0});var cs=i(oe);Dt=r(cs,"SPAN",{});var hs=i(Dt);y(De.$$.fragment,hs),hs.forEach(o),cs.forEach(o),ka=f(bo),Ct=r(bo,"SPAN",{});var ps=i(Ct);ja=n(ps,"DinatConfig"),ps.forEach(o),bo.forEach(o),ao=f(e),A=r(e,"DIV",{class:!0});var he=i(A);y(Ce.$$.fragment,he),xa=f(he),S=r(he,"P",{});var rt=i(S);Fa=n(rt,"This is the configuration class to store the configuration of a "),et=r(rt,"A",{href:!0});var fs=i(et);Wa=n(fs,"DinatModel"),fs.forEach(o),Ua=n(rt,`. It is used to instantiate a Dinat
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 Dinat
`),Ae=r(rt,"A",{href:!0,rel:!0});var ms=i(Ae);Ja=n(ms,"shi-labs/dinat-mini-in1k-224"),ms.forEach(o),Pa=n(rt," architecture."),rt.forEach(o),Za=f(he),G=r(he,"P",{});var it=i(G);za=n(it,"Configuration objects inherit from "),tt=r(it,"A",{href:!0});var us=i(tt);Sa=n(us,"PretrainedConfig"),us.forEach(o),Ga=n(it,` and can be used to control the model outputs. Read the
documentation from `),ot=r(it,"A",{href:!0});var gs=i(ot);Ra=n(gs,"PretrainedConfig"),gs.forEach(o),qa=n(it," for more information."),it.forEach(o),Ba=f(he),y(ae.$$.fragment,he),he.forEach(o),no=f(e),R=r(e,"H2",{class:!0});var vo=i(R);ne=r(vo,"A",{id:!0,class:!0,href:!0});var _s=i(ne);At=r(_s,"SPAN",{});var bs=i(At);y(Ne.$$.fragment,bs),bs.forEach(o),_s.forEach(o),La=f(vo),Nt=r(vo,"SPAN",{});var vs=i(Nt);Oa=n(vs,"DinatModel"),vs.forEach(o),vo.forEach(o),so=f(e),W=r(e,"DIV",{class:!0});var lt=i(W);y(Ie.$$.fragment,lt),Qa=f(lt),ke=r(lt,"P",{});var wo=i(ke);Xa=n(wo,`The bare Dinat Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),je=r(wo,"A",{href:!0,rel:!0});var ws=i(je);Ya=n(ws,"torch.nn.Module"),ws.forEach(o),Va=n(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),Ha=f(lt),k=r(lt,"DIV",{class:!0});var pe=i(k);y(xe.$$.fragment,pe),Ka=f(pe),q=r(pe,"P",{});var dt=i(q);en=n(dt,"The "),at=r(dt,"A",{href:!0});var ys=i(at);tn=n(ys,"DinatModel"),ys.forEach(o),on=n(dt," forward method, overrides the "),It=r(dt,"CODE",{});var Ts=i(It);an=n(Ts,"__call__"),Ts.forEach(o),nn=n(dt," special method."),dt.forEach(o),sn=f(pe),y(se.$$.fragment,pe),rn=f(pe),y(re.$$.fragment,pe),pe.forEach(o),lt.forEach(o),ro=f(e),B=r(e,"H2",{class:!0});var yo=i(B);ie=r(yo,"A",{id:!0,class:!0,href:!0});var $s=i(ie);kt=r($s,"SPAN",{});var Ms=i(kt);y(Fe.$$.fragment,Ms),Ms.forEach(o),$s.forEach(o),ln=f(yo),jt=r(yo,"SPAN",{});var Es=i(jt);dn=n(Es,"DinatForImageClassification"),Es.forEach(o),yo.forEach(o),io=f(e),N=r(e,"DIV",{class:!0});var fe=i(N);y(We.$$.fragment,fe),cn=f(fe),xt=r(fe,"P",{});var Ds=i(xt);hn=n(Ds,`Dinat 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.`),Ds.forEach(o),pn=f(fe),Ue=r(fe,"P",{});var To=i(Ue);fn=n(To,"This model is a PyTorch "),Je=r(To,"A",{href:!0,rel:!0});var Cs=i(Je);mn=n(Cs,"torch.nn.Module"),Cs.forEach(o),un=n(To,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),To.forEach(o),gn=f(fe),j=r(fe,"DIV",{class:!0});var me=i(j);y(Pe.$$.fragment,me),_n=f(me),L=r(me,"P",{});var ct=i(L);bn=n(ct,"The "),nt=r(ct,"A",{href:!0});var As=i(nt);vn=n(As,"DinatForImageClassification"),As.forEach(o),wn=n(ct," forward method, overrides the "),Ft=r(ct,"CODE",{});var Ns=i(Ft);yn=n(Ns,"__call__"),Ns.forEach(o),Tn=n(ct," special method."),ct.forEach(o),$n=f(me),y(le.$$.fragment,me),Mn=f(me),y(de.$$.fragment,me),me.forEach(o),fe.forEach(o),this.h()},h(){d(m,"name","hf:doc:metadata"),d(m,"content",JSON.stringify(qs)),d(u,"id","dilated-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","#dilated-neighborhood-attention-transformer"),d(_,"class","relative group"),d(O,"id","overview"),d(O,"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(O,"href","#overview"),d(P,"class","relative group"),d(ge,"href","https://arxiv.org/abs/2209.15001"),d(ge,"rel","nofollow"),d(Ge,"href","nat"),d(Le,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.AutoImageProcessor"),d(be,"href","https://github.com/SHI-Labs/NATTEN/"),d(be,"rel","nofollow"),d(ve,"href","https://shi-labs.com/natten"),d(ve,"rel","nofollow"),Ws(H.src,Nn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dilated-neighborhood-attention-pattern.jpg")||d(H,"src",Nn),d(H,"alt","drawing"),d(H,"width","600"),d(Qe,"href","https://arxiv.org/abs/2209.15001"),d(we,"href","https://huggingface.co/alihassanijr"),d(we,"rel","nofollow"),d(ye,"href","https://github.com/SHI-Labs/Neighborhood-Attention-Transformer"),d(ye,"rel","nofollow"),d(ee,"id","resources"),d(ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(ee,"href","#resources"),d(Z,"class","relative group"),d(Ye,"href","/docs/transformers/v4.30.0/en/model_doc/dinat#transformers.DinatForImageClassification"),d(Me,"href","https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification"),d(Me,"rel","nofollow"),d(Ee,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb"),d(Ee,"rel","nofollow"),d(He,"href","../tasks/image_classification"),d(oe,"id","transformers.DinatConfig"),d(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(oe,"href","#transformers.DinatConfig"),d(z,"class","relative group"),d(et,"href","/docs/transformers/v4.30.0/en/model_doc/dinat#transformers.DinatModel"),d(Ae,"href","https://huggingface.co/shi-labs/dinat-mini-in1k-224"),d(Ae,"rel","nofollow"),d(tt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(ot,"href","/docs/transformers/v4.30.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(ne,"id","transformers.DinatModel"),d(ne,"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(ne,"href","#transformers.DinatModel"),d(R,"class","relative group"),d(je,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(je,"rel","nofollow"),d(at,"href","/docs/transformers/v4.30.0/en/model_doc/dinat#transformers.DinatModel"),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(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ie,"id","transformers.DinatForImageClassification"),d(ie,"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(ie,"href","#transformers.DinatForImageClassification"),d(B,"class","relative group"),d(Je,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(Je,"rel","nofollow"),d(nt,"href","/docs/transformers/v4.30.0/en/model_doc/dinat#transformers.DinatForImageClassification"),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(N,"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),T(l,b,null),t(_,g),t(_,x),t(x,$o),h(e,Zt,c),h(e,P,c),t(P,O),t(O,pt),T(ue,pt,null),t(P,Mo),t(P,ft),t(ft,Eo),h(e,zt,c),h(e,Q,c),t(Q,Do),t(Q,ge),t(ge,Co),t(Q,Ao),h(e,St,c),h(e,X,c),t(X,No),t(X,Ge),t(Ge,Io),t(X,ko),h(e,Gt,c),h(e,Re,c),t(Re,jo),h(e,Rt,c),h(e,qe,c),t(qe,mt),t(mt,xo),h(e,qt,c),h(e,Be,c),t(Be,Fo),h(e,Bt,c),h(e,Y,c),t(Y,_e),t(_e,Wo),t(_e,Le),t(Le,Uo),t(_e,Jo),t(Y,Po),t(Y,D),t(D,Zo),t(D,ut),t(ut,zo),t(D,So),t(D,gt),t(gt,Go),t(D,Ro),t(D,_t),t(_t,qo),t(D,Bo),t(D,bt),t(bt,Lo),t(D,Oo),t(D,vt),t(vt,Qo),t(D,Xo),t(D,wt),t(wt,Yo),t(D,Vo),t(D,yt),t(yt,Ho),t(D,Ko),h(e,Lt,c),h(e,Oe,c),t(Oe,ea),h(e,Ot,c),h(e,V,c),t(V,F),t(F,ta),t(F,be),t(be,oa),t(F,aa),t(F,ve),t(ve,na),t(F,sa),t(F,Tt),t(Tt,ra),t(F,ia),t(V,la),t(V,$t),t($t,da),h(e,Qt,c),h(e,H,c),h(e,Xt,c),h(e,K,c),t(K,ca),t(K,Qe),t(Qe,ha),t(K,pa),h(e,Yt,c),h(e,U,c),t(U,fa),t(U,we),t(we,ma),t(U,ua),t(U,ye),t(ye,ga),t(U,_a),h(e,Vt,c),h(e,Z,c),t(Z,ee),t(ee,Mt),T(Te,Mt,null),t(Z,ba),t(Z,Et),t(Et,va),h(e,Ht,c),h(e,Xe,c),t(Xe,wa),h(e,Kt,c),T($e,e,c),h(e,eo,c),h(e,te,c),t(te,J),t(J,Ye),t(Ye,ya),t(J,Ta),t(J,Me),t(Me,$a),t(J,Ma),t(J,Ee),t(Ee,Ea),t(J,Da),t(te,Ca),t(te,Ve),t(Ve,Aa),t(Ve,He),t(He,Na),h(e,to,c),h(e,Ke,c),t(Ke,Ia),h(e,oo,c),h(e,z,c),t(z,oe),t(oe,Dt),T(De,Dt,null),t(z,ka),t(z,Ct),t(Ct,ja),h(e,ao,c),h(e,A,c),T(Ce,A,null),t(A,xa),t(A,S),t(S,Fa),t(S,et),t(et,Wa),t(S,Ua),t(S,Ae),t(Ae,Ja),t(S,Pa),t(A,Za),t(A,G),t(G,za),t(G,tt),t(tt,Sa),t(G,Ga),t(G,ot),t(ot,Ra),t(G,qa),t(A,Ba),T(ae,A,null),h(e,no,c),h(e,R,c),t(R,ne),t(ne,At),T(Ne,At,null),t(R,La),t(R,Nt),t(Nt,Oa),h(e,so,c),h(e,W,c),T(Ie,W,null),t(W,Qa),t(W,ke),t(ke,Xa),t(ke,je),t(je,Ya),t(ke,Va),t(W,Ha),t(W,k),T(xe,k,null),t(k,Ka),t(k,q),t(q,en),t(q,at),t(at,tn),t(q,on),t(q,It),t(It,an),t(q,nn),t(k,sn),T(se,k,null),t(k,rn),T(re,k,null),h(e,ro,c),h(e,B,c),t(B,ie),t(ie,kt),T(Fe,kt,null),t(B,ln),t(B,jt),t(jt,dn),h(e,io,c),h(e,N,c),T(We,N,null),t(N,cn),t(N,xt),t(xt,hn),t(N,pn),t(N,Ue),t(Ue,fn),t(Ue,Je),t(Je,mn),t(Ue,un),t(N,gn),t(N,j),T(Pe,j,null),t(j,_n),t(j,L),t(L,bn),t(L,nt),t(nt,vn),t(L,wn),t(L,Ft),t(Ft,yn),t(L,Tn),t(j,$n),T(le,j,null),t(j,Mn),T(de,j,null),lo=!0},p(e,[c]){const Ze={};c&2&&(Ze.$$scope={dirty:c,ctx:e}),ae.$set(Ze);const Wt={};c&2&&(Wt.$$scope={dirty:c,ctx:e}),se.$set(Wt);const Ut={};c&2&&(Ut.$$scope={dirty:c,ctx:e}),re.$set(Ut);const Jt={};c&2&&(Jt.$$scope={dirty:c,ctx:e}),le.$set(Jt);const ze={};c&2&&(ze.$$scope={dirty:c,ctx:e}),de.$set(ze)},i(e){lo||($(l.$$.fragment,e),$(ue.$$.fragment,e),$(Te.$$.fragment,e),$($e.$$.fragment,e),$(De.$$.fragment,e),$(Ce.$$.fragment,e),$(ae.$$.fragment,e),$(Ne.$$.fragment,e),$(Ie.$$.fragment,e),$(xe.$$.fragment,e),$(se.$$.fragment,e),$(re.$$.fragment,e),$(Fe.$$.fragment,e),$(We.$$.fragment,e),$(Pe.$$.fragment,e),$(le.$$.fragment,e),$(de.$$.fragment,e),lo=!0)},o(e){M(l.$$.fragment,e),M(ue.$$.fragment,e),M(Te.$$.fragment,e),M($e.$$.fragment,e),M(De.$$.fragment,e),M(Ce.$$.fragment,e),M(ae.$$.fragment,e),M(Ne.$$.fragment,e),M(Ie.$$.fragment,e),M(xe.$$.fragment,e),M(se.$$.fragment,e),M(re.$$.fragment,e),M(Fe.$$.fragment,e),M(We.$$.fragment,e),M(Pe.$$.fragment,e),M(le.$$.fragment,e),M(de.$$.fragment,e),lo=!1},d(e){o(m),e&&o(v),e&&o(_),E(l),e&&o(Zt),e&&o(P),E(ue),e&&o(zt),e&&o(Q),e&&o(St),e&&o(X),e&&o(Gt),e&&o(Re),e&&o(Rt),e&&o(qe),e&&o(qt),e&&o(Be),e&&o(Bt),e&&o(Y),e&&o(Lt),e&&o(Oe),e&&o(Ot),e&&o(V),e&&o(Qt),e&&o(H),e&&o(Xt),e&&o(K),e&&o(Yt),e&&o(U),e&&o(Vt),e&&o(Z),E(Te),e&&o(Ht),e&&o(Xe),e&&o(Kt),E($e,e),e&&o(eo),e&&o(te),e&&o(to),e&&o(Ke),e&&o(oo),e&&o(z),E(De),e&&o(ao),e&&o(A),E(Ce),E(ae),e&&o(no),e&&o(R),E(Ne),e&&o(so),e&&o(W),E(Ie),E(xe),E(se),E(re),e&&o(ro),e&&o(B),E(Fe),e&&o(io),e&&o(N),E(We),E(Pe),E(le),E(de)}}}const qs={local:"dilated-neighborhood-attention-transformer",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.DinatConfig",title:"DinatConfig"},{local:"transformers.DinatModel",title:"DinatModel"},{local:"transformers.DinatForImageClassification",title:"DinatForImageClassification"}],title:"Dilated Neighborhood Attention Transformer"};function Bs(I){return Us(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ks extends ks{constructor(m){super();js(this,m,Bs,Rs,xs,{})}}export{Ks as default,qs as metadata};
