import{s as $e,n as xe,o as Se}from"../chunks/scheduler.182ea377.js";import{S as ye,i as De,g as a,s as o,r as g,A as Te,h as d,f as t,c as i,j as P,u as _,x as k,k as L,y as n,a as c,v as b,d as v,t as $,w as x}from"../chunks/index.abf12888.js";import{D as z}from"../chunks/Docstring.93f6f462.js";import{H as ue}from"../chunks/Heading.16916d63.js";function He(pe){let u,j,A,K,S,B,y,fe='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>.',R,D,W,r,T,se,M,me="Scheduler with Heun steps for discrete beta schedules.",ne,E,he=`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.`,re,f,H,oe,q,ge=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ie,m,w,ae,I,_e="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",de,h,C,ce,U,be=`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).`,G,F,Y,p,O,le,V,ve="Base class for the output of a scheduler’s <code>step</code> function.",J,N,Q;return S=new ue({props:{title:"HeunDiscreteScheduler",local:"heundiscretescheduler",headingTag:"h1"}}),D=new ue({props:{title:"HeunDiscreteScheduler",local:"diffusers.HeunDiscreteScheduler",headingTag:"h2"}}),T=new z({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:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"use_karras_sigmas",val:": typing.Optional[bool] = False"},{name:"clip_sample",val:": typing.Optional[bool] = 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. You can use a combination of <code>offset=1</code> and
<code>set_alpha_to_one=False</code> to make the last step use step 0 for the previous alpha product like in Stable
Diffusion.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L71"}}),H=new z({props:{name:"scale_model_input",anchor:"diffusers.HeunDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</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/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L185",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.FloatTensor</code></p>
`}}),w=new z({props:{name:"set_timesteps",anchor:"diffusers.HeunDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"},{name:"num_train_timesteps",val:": typing.Optional[int] = 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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L211"}}),C=new z({props:{name:"step",anchor:"diffusers.HeunDiscreteScheduler.step",parameters:[{name:"model_output",val:": typing.Union[torch.FloatTensor, numpy.ndarray]"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": typing.Union[torch.FloatTensor, numpy.ndarray]"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</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.FloatTensor</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/main/en/api/schedulers/multistep_dpm_solver_inverse#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L350",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/multistep_dpm_solver_inverse#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/main/en/api/schedulers/multistep_dpm_solver_inverse#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),F=new ue({props:{title:"SchedulerOutput",local:"diffusers.schedulers.scheduling_utils.SchedulerOutput",headingTag:"h2"}}),O=new z({props:{name:"class diffusers.schedulers.scheduling_utils.SchedulerOutput",anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.FloatTensor</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/main/src/diffusers/schedulers/scheduling_utils.py#L50"}}),{c(){u=a("meta"),j=o(),A=a("p"),K=o(),g(S.$$.fragment),B=o(),y=a("p"),y.innerHTML=fe,R=o(),g(D.$$.fragment),W=o(),r=a("div"),g(T.$$.fragment),se=o(),M=a("p"),M.textContent=me,ne=o(),E=a("p"),E.innerHTML=he,re=o(),f=a("div"),g(H.$$.fragment),oe=o(),q=a("p"),q.textContent=ge,ie=o(),m=a("div"),g(w.$$.fragment),ae=o(),I=a("p"),I.textContent=_e,de=o(),h=a("div"),g(C.$$.fragment),ce=o(),U=a("p"),U.textContent=be,G=o(),g(F.$$.fragment),Y=o(),p=a("div"),g(O.$$.fragment),le=o(),V=a("p"),V.innerHTML=ve,J=o(),N=a("p"),this.h()},l(e){const s=Te("svelte-u9bgzb",document.head);u=d(s,"META",{name:!0,content:!0}),s.forEach(t),j=i(e),A=d(e,"P",{}),P(A).forEach(t),K=i(e),_(S.$$.fragment,e),B=i(e),y=d(e,"P",{"data-svelte-h":!0}),k(y)!=="svelte-1r9m54f"&&(y.innerHTML=fe),R=i(e),_(D.$$.fragment,e),W=i(e),r=d(e,"DIV",{class:!0});var l=P(r);_(T.$$.fragment,l),se=i(l),M=d(l,"P",{"data-svelte-h":!0}),k(M)!=="svelte-1k165jq"&&(M.textContent=me),ne=i(l),E=d(l,"P",{"data-svelte-h":!0}),k(E)!=="svelte-linuuh"&&(E.innerHTML=he),re=i(l),f=d(l,"DIV",{class:!0});var X=P(f);_(H.$$.fragment,X),oe=i(X),q=d(X,"P",{"data-svelte-h":!0}),k(q)!=="svelte-1rkfgpx"&&(q.textContent=ge),X.forEach(t),ie=i(l),m=d(l,"DIV",{class:!0});var Z=P(m);_(w.$$.fragment,Z),ae=i(Z),I=d(Z,"P",{"data-svelte-h":!0}),k(I)!=="svelte-1vzm9q"&&(I.textContent=_e),Z.forEach(t),de=i(l),h=d(l,"DIV",{class:!0});var ee=P(h);_(C.$$.fragment,ee),ce=i(ee),U=d(ee,"P",{"data-svelte-h":!0}),k(U)!=="svelte-hi84tp"&&(U.textContent=be),ee.forEach(t),l.forEach(t),G=i(e),_(F.$$.fragment,e),Y=i(e),p=d(e,"DIV",{class:!0});var te=P(p);_(O.$$.fragment,te),le=i(te),V=d(te,"P",{"data-svelte-h":!0}),k(V)!=="svelte-6ojmkw"&&(V.innerHTML=ve),te.forEach(t),J=i(e),N=d(e,"P",{}),P(N).forEach(t),this.h()},h(){L(u,"name","hf:doc:metadata"),L(u,"content",we),L(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(r,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(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,s){n(document.head,u),c(e,j,s),c(e,A,s),c(e,K,s),b(S,e,s),c(e,B,s),c(e,y,s),c(e,R,s),b(D,e,s),c(e,W,s),c(e,r,s),b(T,r,null),n(r,se),n(r,M),n(r,ne),n(r,E),n(r,re),n(r,f),b(H,f,null),n(f,oe),n(f,q),n(r,ie),n(r,m),b(w,m,null),n(m,ae),n(m,I),n(r,de),n(r,h),b(C,h,null),n(h,ce),n(h,U),c(e,G,s),b(F,e,s),c(e,Y,s),c(e,p,s),b(O,p,null),n(p,le),n(p,V),c(e,J,s),c(e,N,s),Q=!0},p:xe,i(e){Q||(v(S.$$.fragment,e),v(D.$$.fragment,e),v(T.$$.fragment,e),v(H.$$.fragment,e),v(w.$$.fragment,e),v(C.$$.fragment,e),v(F.$$.fragment,e),v(O.$$.fragment,e),Q=!0)},o(e){$(S.$$.fragment,e),$(D.$$.fragment,e),$(T.$$.fragment,e),$(H.$$.fragment,e),$(w.$$.fragment,e),$(C.$$.fragment,e),$(F.$$.fragment,e),$(O.$$.fragment,e),Q=!1},d(e){e&&(t(j),t(A),t(K),t(B),t(y),t(R),t(W),t(r),t(G),t(Y),t(p),t(J),t(N)),t(u),x(S,e),x(D,e),x(T),x(H),x(w),x(C),x(F,e),x(O)}}}const we='{"title":"HeunDiscreteScheduler","local":"heundiscretescheduler","sections":[{"title":"HeunDiscreteScheduler","local":"diffusers.HeunDiscreteScheduler","sections":[],"depth":2},{"title":"SchedulerOutput","local":"diffusers.schedulers.scheduling_utils.SchedulerOutput","sections":[],"depth":2}],"depth":1}';function Ce(pe){return Se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Le extends ye{constructor(u){super(),De(this,u,Ce,He,$e,{})}}export{Le as component};
