import{s as Oe,n as ke,o as Ee}from"../chunks/scheduler.8c3d61f6.js";import{S as Le,i as Ie,g as d,s as r,r as m,A as Me,h as a,f as t,c as i,j as H,u as f,x as h,k as T,y as s,a as c,v as g,d as _,t as b,w as v}from"../chunks/index.589a98e8.js";import{D as K}from"../chunks/Docstring.27406313.js";import{H as Pe,E as qe}from"../chunks/EditOnGithub.e5a8d9cb.js";function Ne(ve){let l,R,B,W,y,J,w,xe='The Heun scheduler (Algorithm 1) is from the <a href="https://huggingface.co/papers/2206.00364" rel="nofollow">Elucidating the Design Space of Diffusion-Based Generative Models</a> paper by Karras et al. The scheduler is ported from the <a href="https://github.com/crowsonkb/k-diffusion" rel="nofollow">k-diffusion</a> library and created by <a href="https://github.com/crowsonkb/" rel="nofollow">Katherine Crowson</a>.',Q,C,X,o,P,ae,N,$e="Scheduler with Heun steps for discrete beta schedules.",ce,V,Se=`This model inherits from <a href="/docs/diffusers/pr_8492/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/pr_8492/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.`,ue,x,O,le,U,De=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,pe,$,k,me,A,He="Sets the begin index for the scheduler. This function should be run from pipeline before the inference.",fe,S,E,he,j,Te="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",ge,D,L,_e,z,ye=`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).`,Y,I,we="## SchedulerOutput[[diffusers.schedulers.scheduling_utils.SchedulerOutput]]",Z,p,M,be,F,Ce="Base class for the output of a scheduler’s <code>step</code> function.",ee,q,te,G,se;return y=new Pe({props:{title:"HeunDiscreteScheduler",local:"heundiscretescheduler",headingTag:"h1"}}),C=new Pe({props:{title:"HeunDiscreteScheduler",local:"diffusers.HeunDiscreteScheduler",headingTag:"h2"}}),P=new K({props:{name:"class diffusers.HeunDiscreteScheduler",anchor:"diffusers.HeunDiscreteScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.00085"},{name:"beta_end",val:": float = 0.012"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": Union = None"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"use_karras_sigmas",val:": Optional = False"},{name:"clip_sample",val:": Optional = False"},{name:"clip_sample_range",val:": float = 1.0"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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.HeunDiscreteScheduler.clip_sample",description:`<strong>clip_sample</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Clip the predicted sample for numerical stability.`,name:"clip_sample"},{anchor:"diffusers.HeunDiscreteScheduler.clip_sample_range",description:`<strong>clip_sample_range</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The maximum magnitude for sample clipping. Valid only when <code>clip_sample=True</code>.`,name:"clip_sample_range"},{anchor:"diffusers.HeunDiscreteScheduler.use_karras_sigmas",description:`<strong>use_karras_sigmas</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If <code>True</code>,
the sigmas are determined according to a sequence of noise levels {&#x3C3;i}.`,name:"use_karras_sigmas"},{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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"}],source:"https://github.com/huggingface/diffusers/blob/vr_8492/src/diffusers/schedulers/scheduling_heun_discrete.py#L70"}}),O=new K({props:{name:"scale_model_input",anchor:"diffusers.HeunDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": Union"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.HeunDiscreteScheduler.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/vr_8492/src/diffusers/schedulers/scheduling_heun_discrete.py#L199",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>
`}}),k=new K({props:{name:"set_begin_index",anchor:"diffusers.HeunDiscreteScheduler.set_begin_index",parameters:[{name:"begin_index",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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/vr_8492/src/diffusers/schedulers/scheduling_heun_discrete.py#L189"}}),E=new K({props:{name:"set_timesteps",anchor:"diffusers.HeunDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": Optional = None"},{name:"device",val:": Union = None"},{name:"num_train_timesteps",val:": Optional = None"},{name:"timesteps",val:": Optional = None"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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"},{anchor:"diffusers.HeunDiscreteScheduler.set_timesteps.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of diffusion steps used when training the model. If <code>None</code>, the default
<code>num_train_timesteps</code> attribute is used.`,name:"num_train_timesteps"},{anchor:"diffusers.HeunDiscreteScheduler.set_timesteps.timesteps",description:`<strong>timesteps</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps used to support arbitrary spacing between timesteps. If <code>None</code>, timesteps will be
generated based on the <code>timestep_spacing</code> attribute. If <code>timesteps</code> is passed, <code>num_inference_steps</code>
must be <code>None</code>, and <code>timestep_spacing</code> attribute will be ignored.`,name:"timesteps"}],source:"https://github.com/huggingface/diffusers/blob/vr_8492/src/diffusers/schedulers/scheduling_heun_discrete.py#L225"}}),L=new K({props:{name:"step",anchor:"diffusers.HeunDiscreteScheduler.step",parameters:[{name:"model_output",val:": Union"},{name:"timestep",val:": Union"},{name:"sample",val:": Union"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/pr_8492/en/api/schedulers/multistep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_8492/src/diffusers/schedulers/scheduling_heun_discrete.py#L370",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/pr_8492/en/api/schedulers/multistep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</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/pr_8492/en/api/schedulers/multistep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),M=new K({props:{name:"class diffusers.schedulers.scheduling_utils.SchedulerOutput",anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput",parameters:[{name:"prev_sample",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput.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"}],source:"https://github.com/huggingface/diffusers/blob/vr_8492/src/diffusers/schedulers/scheduling_utils.py#L60"}}),q=new qe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/schedulers/heun.md"}}),{c(){l=d("meta"),R=r(),B=d("p"),W=r(),m(y.$$.fragment),J=r(),w=d("p"),w.innerHTML=xe,Q=r(),m(C.$$.fragment),X=r(),o=d("div"),m(P.$$.fragment),ae=r(),N=d("p"),N.textContent=$e,ce=r(),V=d("p"),V.innerHTML=Se,ue=r(),x=d("div"),m(O.$$.fragment),le=r(),U=d("p"),U.textContent=De,pe=r(),$=d("div"),m(k.$$.fragment),me=r(),A=d("p"),A.textContent=He,fe=r(),S=d("div"),m(E.$$.fragment),he=r(),j=d("p"),j.textContent=Te,ge=r(),D=d("div"),m(L.$$.fragment),_e=r(),z=d("p"),z.textContent=ye,Y=r(),I=d("p"),I.textContent=we,Z=r(),p=d("div"),m(M.$$.fragment),be=r(),F=d("p"),F.innerHTML=Ce,ee=r(),m(q.$$.fragment),te=r(),G=d("p"),this.h()},l(e){const n=Me("svelte-u9bgzb",document.head);l=a(n,"META",{name:!0,content:!0}),n.forEach(t),R=i(e),B=a(e,"P",{}),H(B).forEach(t),W=i(e),f(y.$$.fragment,e),J=i(e),w=a(e,"P",{"data-svelte-h":!0}),h(w)!=="svelte-1r9m54f"&&(w.innerHTML=xe),Q=i(e),f(C.$$.fragment,e),X=i(e),o=a(e,"DIV",{class:!0});var u=H(o);f(P.$$.fragment,u),ae=i(u),N=a(u,"P",{"data-svelte-h":!0}),h(N)!=="svelte-1k165jq"&&(N.textContent=$e),ce=i(u),V=a(u,"P",{"data-svelte-h":!0}),h(V)!=="svelte-1bxkjyt"&&(V.innerHTML=Se),ue=i(u),x=a(u,"DIV",{class:!0});var ne=H(x);f(O.$$.fragment,ne),le=i(ne),U=a(ne,"P",{"data-svelte-h":!0}),h(U)!=="svelte-1rkfgpx"&&(U.textContent=De),ne.forEach(t),pe=i(u),$=a(u,"DIV",{class:!0});var re=H($);f(k.$$.fragment,re),me=i(re),A=a(re,"P",{"data-svelte-h":!0}),h(A)!=="svelte-1k141rk"&&(A.textContent=He),re.forEach(t),fe=i(u),S=a(u,"DIV",{class:!0});var ie=H(S);f(E.$$.fragment,ie),he=i(ie),j=a(ie,"P",{"data-svelte-h":!0}),h(j)!=="svelte-1vzm9q"&&(j.textContent=Te),ie.forEach(t),ge=i(u),D=a(u,"DIV",{class:!0});var oe=H(D);f(L.$$.fragment,oe),_e=i(oe),z=a(oe,"P",{"data-svelte-h":!0}),h(z)!=="svelte-hi84tp"&&(z.textContent=ye),oe.forEach(t),u.forEach(t),Y=i(e),I=a(e,"P",{"data-svelte-h":!0}),h(I)!=="svelte-jslqpb"&&(I.textContent=we),Z=i(e),p=a(e,"DIV",{class:!0});var de=H(p);f(M.$$.fragment,de),be=i(de),F=a(de,"P",{"data-svelte-h":!0}),h(F)!=="svelte-6ojmkw"&&(F.innerHTML=Ce),de.forEach(t),ee=i(e),f(q.$$.fragment,e),te=i(e),G=a(e,"P",{}),H(G).forEach(t),this.h()},h(){T(l,"name","hf:doc:metadata"),T(l,"content",Ve),T(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(p,"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){s(document.head,l),c(e,R,n),c(e,B,n),c(e,W,n),g(y,e,n),c(e,J,n),c(e,w,n),c(e,Q,n),g(C,e,n),c(e,X,n),c(e,o,n),g(P,o,null),s(o,ae),s(o,N),s(o,ce),s(o,V),s(o,ue),s(o,x),g(O,x,null),s(x,le),s(x,U),s(o,pe),s(o,$),g(k,$,null),s($,me),s($,A),s(o,fe),s(o,S),g(E,S,null),s(S,he),s(S,j),s(o,ge),s(o,D),g(L,D,null),s(D,_e),s(D,z),c(e,Y,n),c(e,I,n),c(e,Z,n),c(e,p,n),g(M,p,null),s(p,be),s(p,F),c(e,ee,n),g(q,e,n),c(e,te,n),c(e,G,n),se=!0},p:ke,i(e){se||(_(y.$$.fragment,e),_(C.$$.fragment,e),_(P.$$.fragment,e),_(O.$$.fragment,e),_(k.$$.fragment,e),_(E.$$.fragment,e),_(L.$$.fragment,e),_(M.$$.fragment,e),_(q.$$.fragment,e),se=!0)},o(e){b(y.$$.fragment,e),b(C.$$.fragment,e),b(P.$$.fragment,e),b(O.$$.fragment,e),b(k.$$.fragment,e),b(E.$$.fragment,e),b(L.$$.fragment,e),b(M.$$.fragment,e),b(q.$$.fragment,e),se=!1},d(e){e&&(t(R),t(B),t(W),t(J),t(w),t(Q),t(X),t(o),t(Y),t(I),t(Z),t(p),t(ee),t(te),t(G)),t(l),v(y,e),v(C,e),v(P),v(O),v(k),v(E),v(L),v(M),v(q,e)}}}const Ve='{"title":"HeunDiscreteScheduler","local":"heundiscretescheduler","sections":[{"title":"HeunDiscreteScheduler","local":"diffusers.HeunDiscreteScheduler","sections":[],"depth":2}],"depth":1}';function Ue(ve){return Ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ke extends Le{constructor(l){super(),Ie(this,l,Ue,Ne,Oe,{})}}export{Ke as component};
