import{S as Ps,i as Ns,s as js,e as s,k as f,w,t as a,M as Ms,c as r,d as o,m as p,a as i,x as $,h as n,b as d,N as qs,G as t,g as h,y,q as D,o as T,B as A,v as Fs,L as Cn}from"../../chunks/vendor-hf-doc-builder.js";import{T as Is}from"../../chunks/Tip-hf-doc-builder.js";import{D as Ot}from"../../chunks/Docstring-hf-doc-builder.js";import{C as kn}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ht}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as En}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as zs}from"../../chunks/PipelineTag-hf-doc-builder.js";function Os(I){let m,v,_,u,b;return u=new kn({props:{code:`from transformers import DinatConfig, DinatModel

# Initializing a Dinat shi-labs/dinat-mini-in1k-224 style configuration
configuration = DinatConfig()

# Initializing a model (with random weights) from the shi-labs/dinat-mini-in1k-224 style configuration
model = DinatModel(configuration)

# Accessing the model configuration
configuration = model.config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> 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:"),_=f(),w(u.$$.fragment)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Example:"),g.forEach(o),_=p(l),$(u.$$.fragment,l)},m(l,g){h(l,m,g),t(m,v),h(l,_,g),y(u,l,g),b=!0},p:Cn,i(l){b||(D(u.$$.fragment,l),b=!0)},o(l){T(u.$$.fragment,l),b=!1},d(l){l&&o(m),l&&o(_),A(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 j=i(_);u=n(j,"Module"),j.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 Ls(I){let m,v,_,u,b;return u=new kn({props:{code:`from transformers import AutoImageProcessor, DinatModel
import torch
from datasets import load_dataset

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

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

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

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

last_hidden_states = outputs.last_hidden_state
list(last_hidden_states.shape)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, 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:"),_=f(),w(u.$$.fragment)},l(l){m=r(l,"P",{});var g=i(m);v=n(g,"Example:"),g.forEach(o),_=p(l),$(u.$$.fragment,l)},m(l,g){h(l,m,g),t(m,v),h(l,_,g),y(u,l,g),b=!0},p:Cn,i(l){b||(D(u.$$.fragment,l),b=!0)},o(l){T(u.$$.fragment,l),b=!1},d(l){l&&o(m),l&&o(_),A(u,l)}}}function Hs(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 j=i(_);u=n(j,"Module"),j.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 Ws(I){let m,v,_,u,b;return u=new kn({props:{code:`from transformers import AutoImageProcessor, DinatForImageClassification
import torch
from datasets import load_dataset

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

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

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

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

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