import{s as Oe,n as Pe,o as Me}from"../chunks/scheduler.53228c21.js";import{S as ke,i as ze,e as a,s as n,c as u,h as He,a as c,d as t,b as i,f as E,g as p,j as S,k as y,l as s,m as l,n as f,t as m,o as h,p as g}from"../chunks/index.100fac89.js";import{C as Ie}from"../chunks/CopyLLMTxtMenu.0ee1b69b.js";import{D as W}from"../chunks/Docstring.db856a1e.js";import{H as xe,E as qe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function Ne(De){let _,B,j,J,A,Q,T,X,w,Ee='A scheduler that uses ancestral sampling with Euler method steps. This is a fast scheduler which can often generate good outputs in 20-30 steps. The scheduler is based on the original <a href="https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L72" rel="nofollow">k-diffusion</a> implementation by <a href="https://github.com/crowsonkb/" rel="nofollow">Katherine Crowson</a>.',Y,C,Z,o,L,de,q,Se="Ancestral sampling with Euler method steps.",ue,N,ye=`This model inherits from <a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin">ConfigMixin</a>. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`,pe,v,O,fe,V,Ae=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep. Scales the denoising model input by <code>(sigma**2 + 1) ** 0.5</code> to match the Euler algorithm.`,me,$,P,he,U,Te="Sets the begin index for the scheduler. This function should be run from pipeline before the inference.",ge,x,M,_e,F,we="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",be,D,k,ve,G,Ce=`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`,ee,z,te,b,H,$e,R,Le="Output class for the scheduler’s <code>step</code> function output.",re,I,se,K,ne;return A=new Ie({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new xe({props:{title:"EulerAncestralDiscreteScheduler",local:"eulerancestraldiscretescheduler",headingTag:"h1"}}),C=new xe({props:{title:"EulerAncestralDiscreteScheduler",local:"diffusers.EulerAncestralDiscreteScheduler",headingTag:"h2"}}),L=new W({props:{name:"class diffusers.EulerAncestralDiscreteScheduler",anchor:"diffusers.EulerAncestralDiscreteScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"},{name:"rescale_betas_zero_snr",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, defaults to 1000) &#x2014;
The number of diffusion steps to train the model.`,name:"num_train_timesteps"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.beta_start",description:`<strong>beta_start</strong> (<code>float</code>, defaults to 0.0001) &#x2014;
The starting <code>beta</code> value of inference.`,name:"beta_start"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.beta_end",description:`<strong>beta_end</strong> (<code>float</code>, defaults to 0.02) &#x2014;
The final <code>beta</code> value.`,name:"beta_end"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</code>, defaults to <code>&quot;linear&quot;</code>) &#x2014;
The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
<code>linear</code> or <code>scaled_linear</code>.`,name:"beta_schedule"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, <em>optional</em>) &#x2014;
Pass an array of betas directly to the constructor to bypass <code>beta_start</code> and <code>beta_end</code>.`,name:"trained_betas"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, defaults to <code>epsilon</code>, <em>optional</em>) &#x2014;
Prediction type of the scheduler function; can be <code>epsilon</code> (predicts the noise of the diffusion process),
<code>sample</code> (directly predicts the noisy sample<code>) or </code>v_prediction\` (see section 2.4 of <a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">Imagen
Video</a> paper).`,name:"prediction_type"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, defaults to <code>&quot;linspace&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2 of the <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and
Sample Steps are Flawed</a> for more information.`,name:"timestep_spacing"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, defaults to 0) &#x2014;
An offset added to the inference steps, as required by some model families.`,name:"steps_offset"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.rescale_betas_zero_snr",description:`<strong>rescale_betas_zero_snr</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to rescale the betas to have zero terminal SNR. This enables the model to generate very bright and
dark samples instead of limiting it to samples with medium brightness. Loosely related to
<a href="https://github.com/huggingface/diffusers/blob/74fd735eb073eb1d774b1ab4154a0876eb82f055/examples/dreambooth/train_dreambooth.py#L506" rel="nofollow"><code>--offset_noise</code></a>.`,name:"rescale_betas_zero_snr"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L132"}}),O=new W({props:{name:"scale_model_input",anchor:"diffusers.EulerAncestralDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Union[float, torch.Tensor]"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.scale_model_input.timestep",description:`<strong>timestep</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The current timestep in the diffusion chain.`,name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L253",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A scaled input sample.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.Tensor</code></p>
`}}),P=new W({props:{name:"set_begin_index",anchor:"diffusers.EulerAncestralDiscreteScheduler.set_begin_index",parameters:[{name:"begin_index",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.set_begin_index.begin_index",description:`<strong>begin_index</strong> (<code>int</code>) &#x2014;
The begin index for the scheduler.`,name:"begin_index"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L243"}}),M=new W({props:{name:"set_timesteps",anchor:"diffusers.EulerAncestralDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.set_timesteps.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
The number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, <em>optional</em>) &#x2014;
The device to which the timesteps should be moved to. If <code>None</code>, the timesteps are not moved.`,name:"device"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L277"}}),k=new W({props:{name:"step",anchor:"diffusers.EulerAncestralDiscreteScheduler.step",parameters:[{name:"model_output",val:": Tensor"},{name:"timestep",val:": typing.Union[float, torch.Tensor]"},{name:"sample",val:": Tensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.Tensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>) &#x2014;
Whether or not to return a
<a href="/docs/diffusers/main/en/api/schedulers/euler_ancestral#diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput">EulerAncestralDiscreteSchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L345",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>,
<a
  href="/docs/diffusers/main/en/api/schedulers/euler_ancestral#diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput"
>EulerAncestralDiscreteSchedulerOutput</a> is returned,
otherwise a tuple is returned where the first element is the sample tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/schedulers/euler_ancestral#diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput"
>EulerAncestralDiscreteSchedulerOutput</a> or <code>tuple</code></p>
`}}),z=new xe({props:{title:"EulerAncestralDiscreteSchedulerOutput",local:"diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput",headingTag:"h2"}}),H=new W({props:{name:"class diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput",anchor:"diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput",parameters:[{name:"prev_sample",val:": Tensor"},{name:"pred_original_sample",val:": typing.Optional[torch.Tensor] = None"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
Computed sample <code>(x_{t-1})</code> of previous timestep. <code>prev_sample</code> should be used as next model input in the
denoising loop.`,name:"prev_sample"},{anchor:"diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput.pred_original_sample",description:`<strong>pred_original_sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
The predicted denoised sample <code>(x_{0})</code> based on the model output from the current timestep.
<code>pred_original_sample</code> can be used to preview progress or for guidance.`,name:"pred_original_sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L33"}}),I=new qe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/schedulers/euler_ancestral.md"}}),{c(){_=a("meta"),B=n(),j=a("p"),J=n(),u(A.$$.fragment),Q=n(),u(T.$$.fragment),X=n(),w=a("p"),w.innerHTML=Ee,Y=n(),u(C.$$.fragment),Z=n(),o=a("div"),u(L.$$.fragment),de=n(),q=a("p"),q.textContent=Se,ue=n(),N=a("p"),N.innerHTML=ye,pe=n(),v=a("div"),u(O.$$.fragment),fe=n(),V=a("p"),V.innerHTML=Ae,me=n(),$=a("div"),u(P.$$.fragment),he=n(),U=a("p"),U.textContent=Te,ge=n(),x=a("div"),u(M.$$.fragment),_e=n(),F=a("p"),F.textContent=we,be=n(),D=a("div"),u(k.$$.fragment),ve=n(),G=a("p"),G.textContent=Ce,ee=n(),u(z.$$.fragment),te=n(),b=a("div"),u(H.$$.fragment),$e=n(),R=a("p"),R.innerHTML=Le,re=n(),u(I.$$.fragment),se=n(),K=a("p"),this.h()},l(e){const r=He("svelte-u9bgzb",document.head);_=c(r,"META",{name:!0,content:!0}),r.forEach(t),B=i(e),j=c(e,"P",{}),E(j).forEach(t),J=i(e),p(A.$$.fragment,e),Q=i(e),p(T.$$.fragment,e),X=i(e),w=c(e,"P",{"data-svelte-h":!0}),S(w)!=="svelte-mxywa3"&&(w.innerHTML=Ee),Y=i(e),p(C.$$.fragment,e),Z=i(e),o=c(e,"DIV",{class:!0});var d=E(o);p(L.$$.fragment,d),de=i(d),q=c(d,"P",{"data-svelte-h":!0}),S(q)!=="svelte-15vtfhh"&&(q.textContent=Se),ue=i(d),N=c(d,"P",{"data-svelte-h":!0}),S(N)!=="svelte-linuuh"&&(N.innerHTML=ye),pe=i(d),v=c(d,"DIV",{class:!0});var ie=E(v);p(O.$$.fragment,ie),fe=i(ie),V=c(ie,"P",{"data-svelte-h":!0}),S(V)!=="svelte-1hew89w"&&(V.innerHTML=Ae),ie.forEach(t),me=i(d),$=c(d,"DIV",{class:!0});var oe=E($);p(P.$$.fragment,oe),he=i(oe),U=c(oe,"P",{"data-svelte-h":!0}),S(U)!=="svelte-1k141rk"&&(U.textContent=Te),oe.forEach(t),ge=i(d),x=c(d,"DIV",{class:!0});var ae=E(x);p(M.$$.fragment,ae),_e=i(ae),F=c(ae,"P",{"data-svelte-h":!0}),S(F)!=="svelte-1vzm9q"&&(F.textContent=we),ae.forEach(t),be=i(d),D=c(d,"DIV",{class:!0});var ce=E(D);p(k.$$.fragment,ce),ve=i(ce),G=c(ce,"P",{"data-svelte-h":!0}),S(G)!=="svelte-hi84tp"&&(G.textContent=Ce),ce.forEach(t),d.forEach(t),ee=i(e),p(z.$$.fragment,e),te=i(e),b=c(e,"DIV",{class:!0});var le=E(b);p(H.$$.fragment,le),$e=i(le),R=c(le,"P",{"data-svelte-h":!0}),S(R)!=="svelte-id9kic"&&(R.innerHTML=Le),le.forEach(t),re=i(e),p(I.$$.fragment,e),se=i(e),K=c(e,"P",{}),E(K).forEach(t),this.h()},h(){y(_,"name","hf:doc:metadata"),y(_,"content",Ve),y(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(b,"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,r){s(document.head,_),l(e,B,r),l(e,j,r),l(e,J,r),f(A,e,r),l(e,Q,r),f(T,e,r),l(e,X,r),l(e,w,r),l(e,Y,r),f(C,e,r),l(e,Z,r),l(e,o,r),f(L,o,null),s(o,de),s(o,q),s(o,ue),s(o,N),s(o,pe),s(o,v),f(O,v,null),s(v,fe),s(v,V),s(o,me),s(o,$),f(P,$,null),s($,he),s($,U),s(o,ge),s(o,x),f(M,x,null),s(x,_e),s(x,F),s(o,be),s(o,D),f(k,D,null),s(D,ve),s(D,G),l(e,ee,r),f(z,e,r),l(e,te,r),l(e,b,r),f(H,b,null),s(b,$e),s(b,R),l(e,re,r),f(I,e,r),l(e,se,r),l(e,K,r),ne=!0},p:Pe,i(e){ne||(m(A.$$.fragment,e),m(T.$$.fragment,e),m(C.$$.fragment,e),m(L.$$.fragment,e),m(O.$$.fragment,e),m(P.$$.fragment,e),m(M.$$.fragment,e),m(k.$$.fragment,e),m(z.$$.fragment,e),m(H.$$.fragment,e),m(I.$$.fragment,e),ne=!0)},o(e){h(A.$$.fragment,e),h(T.$$.fragment,e),h(C.$$.fragment,e),h(L.$$.fragment,e),h(O.$$.fragment,e),h(P.$$.fragment,e),h(M.$$.fragment,e),h(k.$$.fragment,e),h(z.$$.fragment,e),h(H.$$.fragment,e),h(I.$$.fragment,e),ne=!1},d(e){e&&(t(B),t(j),t(J),t(Q),t(X),t(w),t(Y),t(Z),t(o),t(ee),t(te),t(b),t(re),t(se),t(K)),t(_),g(A,e),g(T,e),g(C,e),g(L),g(O),g(P),g(M),g(k),g(z,e),g(H),g(I,e)}}}const Ve='{"title":"EulerAncestralDiscreteScheduler","local":"eulerancestraldiscretescheduler","sections":[{"title":"EulerAncestralDiscreteScheduler","local":"diffusers.EulerAncestralDiscreteScheduler","sections":[],"depth":2},{"title":"EulerAncestralDiscreteSchedulerOutput","local":"diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteSchedulerOutput","sections":[],"depth":2}],"depth":1}';function Ue(De){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ke extends ke{constructor(_){super(),ze(this,_,Ue,Ne,Oe,{})}}export{Ke as component};
