import{s as K,n as Q,o as X}from"../chunks/scheduler.8c3d61f6.js";import{S as Y,i as ee,g as m,s,r as $,A as ne,h as l,f as t,c as a,j as S,u as w,x as V,k as F,y as g,a as r,v as M,d as y,t as z,w as L}from"../chunks/index.589a98e8.js";import{D as B}from"../chunks/Docstring.27406313.js";import{H as J,E as te}from"../chunks/EditOnGithub.e5a8d9cb.js";function oe(G){let i,k,v,A,f,N,c,R='A Transformer model for image-like data from <a href="https://huggingface.co/papers/2212.09748" rel="nofollow">DiT</a>.',O,u,P,o,p,U,T,W='A 2D Transformer model as introduced in DiT (<a href="https://arxiv.org/abs/2212.09748" rel="nofollow">https://arxiv.org/abs/2212.09748</a>).',j,d,h,q,D,Z='The <a href="/docs/diffusers/pr_7944/en/api/models/dit_transformer2d#diffusers.DiTTransformer2DModel">DiTTransformer2DModel</a> forward method.',C,_,E,x,H;return f=new J({props:{title:"DiTTransformer2DModel",local:"dittransformer2dmodel",headingTag:"h1"}}),u=new J({props:{title:"DiTTransformer2DModel",local:"diffusers.DiTTransformer2DModel",headingTag:"h2"}}),p=new B({props:{name:"class diffusers.DiTTransformer2DModel",anchor:"diffusers.DiTTransformer2DModel",parameters:[{name:"num_attention_heads",val:": int = 16"},{name:"attention_head_dim",val:": int = 72"},{name:"in_channels",val:": int = 4"},{name:"out_channels",val:": Optional = None"},{name:"num_layers",val:": int = 28"},{name:"dropout",val:": float = 0.0"},{name:"norm_num_groups",val:": int = 32"},{name:"attention_bias",val:": bool = True"},{name:"sample_size",val:": int = 32"},{name:"patch_size",val:": int = 2"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"num_embeds_ada_norm",val:": Optional = 1000"},{name:"upcast_attention",val:": bool = False"},{name:"norm_type",val:": str = 'ada_norm_zero'"},{name:"norm_elementwise_affine",val:": bool = False"},{name:"norm_eps",val:": float = 1e-05"}],parametersDescription:[{anchor:"diffusers.DiTTransformer2DModel.num_attention_heads",description:"<strong>num_attention_heads</strong> (int, optional, defaults to 16) &#x2014; The number of heads to use for multi-head attention.",name:"num_attention_heads"},{anchor:"diffusers.DiTTransformer2DModel.attention_head_dim",description:"<strong>attention_head_dim</strong> (int, optional, defaults to 72) &#x2014; The number of channels in each head.",name:"attention_head_dim"},{anchor:"diffusers.DiTTransformer2DModel.in_channels",description:"<strong>in_channels</strong> (int, defaults to 4) &#x2014; The number of channels in the input.",name:"in_channels"},{anchor:"diffusers.DiTTransformer2DModel.out_channels",description:`<strong>out_channels</strong> (int, optional) &#x2014;
The number of channels in the output. Specify this parameter if the output channel number differs from the
input.`,name:"out_channels"},{anchor:"diffusers.DiTTransformer2DModel.num_layers",description:"<strong>num_layers</strong> (int, optional, defaults to 28) &#x2014; The number of layers of Transformer blocks to use.",name:"num_layers"},{anchor:"diffusers.DiTTransformer2DModel.dropout",description:"<strong>dropout</strong> (float, optional, defaults to 0.0) &#x2014; The dropout probability to use within the Transformer blocks.",name:"dropout"},{anchor:"diffusers.DiTTransformer2DModel.norm_num_groups",description:`<strong>norm_num_groups</strong> (int, optional, defaults to 32) &#x2014;
Number of groups for group normalization within Transformer blocks.`,name:"norm_num_groups"},{anchor:"diffusers.DiTTransformer2DModel.attention_bias",description:`<strong>attention_bias</strong> (bool, optional, defaults to True) &#x2014;
Configure if the Transformer blocks&#x2019; attention should contain a bias parameter.`,name:"attention_bias"},{anchor:"diffusers.DiTTransformer2DModel.sample_size",description:`<strong>sample_size</strong> (int, defaults to 32) &#x2014;
The width of the latent images. This parameter is fixed during training.`,name:"sample_size"},{anchor:"diffusers.DiTTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (int, defaults to 2) &#x2014;
Size of the patches the model processes, relevant for architectures working on non-sequential data.`,name:"patch_size"},{anchor:"diffusers.DiTTransformer2DModel.activation_fn",description:`<strong>activation_fn</strong> (str, optional, defaults to &#x201C;gelu-approximate&#x201D;) &#x2014;
Activation function to use in feed-forward networks within Transformer blocks.`,name:"activation_fn"},{anchor:"diffusers.DiTTransformer2DModel.num_embeds_ada_norm",description:`<strong>num_embeds_ada_norm</strong> (int, optional, defaults to 1000) &#x2014;
Number of embeddings for AdaLayerNorm, fixed during training and affects the maximum denoising steps during
inference.`,name:"num_embeds_ada_norm"},{anchor:"diffusers.DiTTransformer2DModel.upcast_attention",description:`<strong>upcast_attention</strong> (bool, optional, defaults to False) &#x2014;
If true, upcasts the attention mechanism dimensions for potentially improved performance.`,name:"upcast_attention"},{anchor:"diffusers.DiTTransformer2DModel.norm_type",description:`<strong>norm_type</strong> (str, optional, defaults to &#x201C;ada_norm_zero&#x201D;) &#x2014;
Specifies the type of normalization used, can be &#x2018;ada_norm_zero&#x2019;.`,name:"norm_type"},{anchor:"diffusers.DiTTransformer2DModel.norm_elementwise_affine",description:`<strong>norm_elementwise_affine</strong> (bool, optional, defaults to False) &#x2014;
If true, enables element-wise affine parameters in the normalization layers.`,name:"norm_elementwise_affine"},{anchor:"diffusers.DiTTransformer2DModel.norm_eps",description:`<strong>norm_eps</strong> (float, optional, defaults to 1e-5) &#x2014;
A small constant added to the denominator in normalization layers to prevent division by zero.`,name:"norm_eps"}],source:"https://github.com/huggingface/diffusers/blob/vr_7944/src/diffusers/models/transformers/dit_transformer_2d.py#L31"}}),h=new B({props:{name:"forward",anchor:"diffusers.DiTTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"timestep",val:": Optional = None"},{name:"class_labels",val:": Optional = None"},{name:"cross_attention_kwargs",val:": Dict = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DiTTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.LongTensor</code> of shape <code>(batch size, num latent pixels)</code> if discrete, <code>torch.FloatTensor</code> of shape <code>(batch size, channel, height, width)</code> if continuous) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.DiTTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>, <em>optional</em>) &#x2014;
Used to indicate denoising step. Optional timestep to be applied as an embedding in <code>AdaLayerNorm</code>.`,name:"timestep"},{anchor:"diffusers.DiTTransformer2DModel.forward.class_labels",description:`<strong>class_labels</strong> ( <code>torch.LongTensor</code> of shape <code>(batch size, num classes)</code>, <em>optional</em>) &#x2014;
Used to indicate class labels conditioning. Optional class labels to be applied as an embedding in
<code>AdaLayerZeroNorm</code>.`,name:"class_labels"},{anchor:"diffusers.DiTTransformer2DModel.forward.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> ( <code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.DiTTransformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/pr_7944/en/api/models/unet2d-cond#diffusers.models.unets.unet_2d_condition.UNet2DConditionOutput">UNet2DConditionOutput</a> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_7944/src/diffusers/models/transformers/dit_transformer_2d.py#L150",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is True, an <code>~models.transformer_2d.Transformer2DModelOutput</code> is returned, otherwise a
<code>tuple</code> where the first element is the sample tensor.</p>
`}}),_=new te({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/dit_transformer2d.md"}}),{c(){i=m("meta"),k=s(),v=m("p"),A=s(),$(f.$$.fragment),N=s(),c=m("p"),c.innerHTML=R,O=s(),$(u.$$.fragment),P=s(),o=m("div"),$(p.$$.fragment),U=s(),T=m("p"),T.innerHTML=W,j=s(),d=m("div"),$(h.$$.fragment),q=s(),D=m("p"),D.innerHTML=Z,C=s(),$(_.$$.fragment),E=s(),x=m("p"),this.h()},l(e){const n=ne("svelte-u9bgzb",document.head);i=l(n,"META",{name:!0,content:!0}),n.forEach(t),k=a(e),v=l(e,"P",{}),S(v).forEach(t),A=a(e),w(f.$$.fragment,e),N=a(e),c=l(e,"P",{"data-svelte-h":!0}),V(c)!=="svelte-14u6i1s"&&(c.innerHTML=R),O=a(e),w(u.$$.fragment,e),P=a(e),o=l(e,"DIV",{class:!0});var b=S(o);w(p.$$.fragment,b),U=a(b),T=l(b,"P",{"data-svelte-h":!0}),V(T)!=="svelte-3jxxjc"&&(T.innerHTML=W),j=a(b),d=l(b,"DIV",{class:!0});var I=S(d);w(h.$$.fragment,I),q=a(I),D=l(I,"P",{"data-svelte-h":!0}),V(D)!=="svelte-yjdo02"&&(D.innerHTML=Z),I.forEach(t),b.forEach(t),C=a(e),w(_.$$.fragment,e),E=a(e),x=l(e,"P",{}),S(x).forEach(t),this.h()},h(){F(i,"name","hf:doc:metadata"),F(i,"content",re),F(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(o,"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,n){g(document.head,i),r(e,k,n),r(e,v,n),r(e,A,n),M(f,e,n),r(e,N,n),r(e,c,n),r(e,O,n),M(u,e,n),r(e,P,n),r(e,o,n),M(p,o,null),g(o,U),g(o,T),g(o,j),g(o,d),M(h,d,null),g(d,q),g(d,D),r(e,C,n),M(_,e,n),r(e,E,n),r(e,x,n),H=!0},p:Q,i(e){H||(y(f.$$.fragment,e),y(u.$$.fragment,e),y(p.$$.fragment,e),y(h.$$.fragment,e),y(_.$$.fragment,e),H=!0)},o(e){z(f.$$.fragment,e),z(u.$$.fragment,e),z(p.$$.fragment,e),z(h.$$.fragment,e),z(_.$$.fragment,e),H=!1},d(e){e&&(t(k),t(v),t(A),t(N),t(c),t(O),t(P),t(o),t(C),t(E),t(x)),t(i),L(f,e),L(u,e),L(p),L(h),L(_,e)}}}const re='{"title":"DiTTransformer2DModel","local":"dittransformer2dmodel","sections":[{"title":"DiTTransformer2DModel","local":"diffusers.DiTTransformer2DModel","sections":[],"depth":2}],"depth":1}';function se(G){return X(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class le extends Y{constructor(i){super(),ee(this,i,se,oe,K,{})}}export{le as component};
