
    i|              	           d dl Z d dlmZ d dlmZmZmZmZmZ d dl	Z
d dlZddlmZmZ ddlmZmZ ddlmZmZ  e       rd dlZe G d	 d
e             Z	 	 ddededed   dej4                  fdZ G d dee      Zy)    N)	dataclass)ListLiteralOptionalTupleUnion   )ConfigMixinregister_to_config)
BaseOutputis_scipy_available   )KarrasDiffusionSchedulersSchedulerMixinc                   X    e Zd ZU dZej
                  ed<   dZeej
                     ed<   y)HeunDiscreteSchedulerOutputaq  
    Output class for the scheduler's `step` function output.

    Args:
        prev_sample (`torch.Tensor` of shape `(batch_size, num_channels, height, width)` for images):
            Computed sample `(x_{t-1})` of previous timestep. `prev_sample` should be used as next model input in the
            denoising loop.
        pred_original_sample (`torch.Tensor` of shape `(batch_size, num_channels, height, width)` for images):
            The predicted denoised sample `(x_{0})` based on the model output from the current timestep.
            `pred_original_sample` can be used to preview progress or for guidance.
    prev_sampleNpred_original_sample)	__name__
__module____qualname____doc__torchTensor__annotations__r   r        w/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/diffusers/schedulers/scheduling_heun_discrete.pyr   r      s'    
 37(5<<07r   r   num_diffusion_timestepsmax_betaalpha_transform_type)cosineexpreturnc           
      $   |dk(  rd }n|dk(  rd }nt        d|       g }t        |       D ]<  }|| z  }|dz   | z  }|j                  t        d ||       ||      z  z
  |             > t	        j
                  |t        j                        S )aB  
    Create a beta schedule that discretizes the given alpha_t_bar function, which defines the cumulative product of
    (1-beta) over time from t = [0,1].

    Contains a function alpha_bar that takes an argument t and transforms it to the cumulative product of (1-beta) up
    to that part of the diffusion process.

    Args:
        num_diffusion_timesteps (`int`):
            The number of betas to produce.
        max_beta (`float`, defaults to `0.999`):
            The maximum beta to use; use values lower than 1 to avoid numerical instability.
        alpha_transform_type (`"cosine"` or `"exp"`, defaults to `"cosine"`):
            The type of noise schedule for `alpha_bar`. Choose from `cosine` or `exp`.

    Returns:
        `torch.Tensor`:
            The betas used by the scheduler to step the model outputs.
    r"   c                 f    t        j                  | dz   dz  t         j                  z  dz        dz  S )NgMb?gT㥛 ?r	   )mathcospits    r   alpha_bar_fnz)betas_for_alpha_bar.<locals>.alpha_bar_fnM   s-    88QY%/$''9A=>!CCr   r#   c                 2    t        j                  | dz        S )Ng      ()r'   r#   r*   s    r   r,   z)betas_for_alpha_bar.<locals>.alpha_bar_fnR   s    88AI&&r   z"Unsupported alpha_transform_type: r   dtype)
ValueErrorrangeappendminr   tensorfloat32)r   r    r!   r,   betasit1t2s           r   betas_for_alpha_barr:   3   s    0 x'	D 
	&	' =>R=STUUE*+ M((!e..S\"-R0@@@(KLM <<U]]33r   c                      e Zd ZdZeD  cg c]  }|j
                   c}} ZdZe	 	 	 	 	 	 	 	 	 	 	 	 	 d6de	de
de
ded   d	eeej                  ee
   f      d
ed   dee   dee   dee   dee   de
ded   de	ddfd       Z	 d7dee
ej(                  f   deej(                     de	fdZed        Zed        Zed        Zd8de	ddfdZdej(                  dee
ej(                  f   dej(                  fdZ	 	 	 	 d9d ee	   d!eeej:                  f   dee	   d"eee	      ddf
d#Zd$ej                  d%ej                  dej                  fd&Zd'ej(                  d e	dej(                  fd(Z d'ej(                  d e	dej(                  fd)Z!	 d:d'ej(                  d e	d*e
d+e
dej(                  f
d,Z"ed-        Z#dee
ej(                  f   ddfd.Z$	 d;d/eej(                  ej                  f   dee
ej(                  f   deej(                  ej                  f   d0edee%e&f   f
d1Z'd2ej(                  d3ej(                  d"ej(                  dej(                  fd4Z(de	fd5Z)yc c}} w )<HeunDiscreteScheduleruE  
    Scheduler with Heun steps for discrete beta schedules.

    This model inherits from [`SchedulerMixin`] and [`ConfigMixin`]. Check the superclass documentation for the generic
    methods the library implements for all schedulers such as loading and saving.

    Args:
        num_train_timesteps (`int`, defaults to 1000):
            The number of diffusion steps to train the model.
        beta_start (`float`, defaults to 0.0001):
            The starting `beta` value of inference.
        beta_end (`float`, defaults to 0.02):
            The final `beta` value.
        beta_schedule (`"linear"`, `"scaled_linear"`, `"squaredcos_cap_v2"`, or `"exp"`, defaults to `"linear"`):
            The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
            `linear`, `scaled_linear`, `squaredcos_cap_v2`, or `exp`.
        trained_betas (`np.ndarray`, *optional*):
            Pass an array of betas directly to the constructor to bypass `beta_start` and `beta_end`.
        prediction_type (`"epsilon"`, `"sample"`, or `"v_prediction"`, defaults to `"epsilon"`, *optional*):
            Prediction type of the scheduler function; can be `epsilon` (predicts the noise of the diffusion process),
            `sample` (directly predicts the noisy sample`) or `v_prediction` (see section 2.4 of [Imagen
            Video](https://huggingface.co/papers/2210.02303) paper).
        clip_sample (`bool`, defaults to `True`):
            Clip the predicted sample for numerical stability.
        clip_sample_range (`float`, defaults to 1.0):
            The maximum magnitude for sample clipping. Valid only when `clip_sample=True`.
        use_karras_sigmas (`bool`, *optional*, defaults to `False`):
            Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`,
            the sigmas are determined according to a sequence of noise levels {σi}.
        use_exponential_sigmas (`bool`, *optional*, defaults to `False`):
            Whether to use exponential sigmas for step sizes in the noise schedule during the sampling process.
        use_beta_sigmas (`bool`, *optional*, defaults to `False`):
            Whether to use beta sigmas for step sizes in the noise schedule during the sampling process. Refer to [Beta
            Sampling is All You Need](https://huggingface.co/papers/2407.12173) for more information.
        timestep_spacing (`"linspace"`, `"leading"`, or `"trailing"`, defaults to `"linspace"`):
            The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and
            Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information.
        steps_offset (`int`, defaults to 0):
            An offset added to the inference steps, as required by some model families.
    r	   Nnum_train_timesteps
beta_startbeta_endbeta_schedule)linearscaled_linearsquaredcos_cap_v2r#   trained_betasprediction_type)epsilonsamplev_predictionuse_karras_sigmasuse_exponential_sigmasuse_beta_sigmasclip_sampleclip_sample_rangetimestep_spacing)linspaceleadingtrailingsteps_offsetr$   c                    | j                   j                  rt               st        d      t	        | j                   j                  | j                   j
                  | j                   j                  g      dkD  rt        d      |+t        j                  |t        j                        | _        n|dk(  r-t        j                  |||t        j                        | _        n|dk(  r6t        j                  |dz  |dz  |t        j                        dz  | _        nJ|d	k(  rt        |d
      | _        n2|dk(  rt        |d      | _        nt        | d| j                         d| j                  z
  | _        t        j"                  | j                   d      | _        | j'                  |d |       || _        d | _        d | _        | j,                  j/                  d      | _        y )Nz:Make sure to install scipy if you want to use beta sigmas.r   znOnly one of `config.use_beta_sigmas`, `config.use_exponential_sigmas`, `config.use_karras_sigmas` can be used.r.   rA   rB         ?r	   rC   r"   )r!   r#   z is not implemented for       ?r   )dimcpu)configrK   r   ImportErrorsumrJ   rI   r0   r   r4   r5   r6   rO   r:   NotImplementedError	__class__alphascumprodalphas_cumprodset_timesteps_step_index_begin_indexsigmasto)selfr=   r>   r?   r@   rD   rE   rI   rJ   rK   rL   rM   rN   rR   s                 r   __init__zHeunDiscreteScheduler.__init__   s   " ;;&&/A/CZ[[++T[[-O-OQUQ\Q\QnQnopstt A  $m5==IDJh&
H>QY^YfYfgDJo-
C3H[chcpcpquvvDJ11,-@W_`DJe#,-@W\]DJ%7OPTP^P^O_&`aaDJJ&#mmDKKQ? 	.6IJ!2 kknnU+r   timestepschedule_timestepsc                     || j                   }||k(  j                         }t        |      dkD  rdnd}||   j                         S )ak  
        Find the index of a given timestep in the timestep schedule.

        Args:
            timestep (`float` or `torch.Tensor`):
                The timestep value to find in the schedule.
            schedule_timesteps (`torch.Tensor`, *optional*):
                The timestep schedule to search in. If `None`, uses `self.timesteps`.

        Returns:
            `int`:
                The index of the timestep in the schedule. For the very first step, returns the second index if
                multiple matches exist to avoid skipping a sigma when starting mid-schedule (e.g., for image-to-image).
        r   r   )	timestepsnonzerolenitem)re   rg   rh   indicesposs        r   index_for_timestepz(HeunDiscreteScheduler.index_for_timestep   sN    " %!%%1::< w<!#as|  ""r   c                     | j                   j                  dv r| j                  j                         S | j                  j                         dz  dz   dz  S )N)rO   rQ   r	   r   rT   )rX   rN   rc   maxre   s    r   init_noise_sigmaz&HeunDiscreteScheduler.init_noise_sigma   sH     ;;''+CC;;??$$!Q&*s22r   c                     | j                   S )zg
        The index counter for current timestep. It will increase 1 after each scheduler step.
        )ra   rs   s    r   
step_indexz HeunDiscreteScheduler.step_index   s    
 r   c                     | j                   S )zq
        The index for the first timestep. It should be set from pipeline with `set_begin_index` method.
        rb   rs   s    r   begin_indexz!HeunDiscreteScheduler.begin_index   s    
    r   ry   c                     || _         y)z
        Sets the begin index for the scheduler. This function should be run from pipeline before the inference.

        Args:
            begin_index (`int`, defaults to `0`):
                The begin index for the scheduler.
        Nrx   )re   ry   s     r   set_begin_indexz%HeunDiscreteScheduler.set_begin_index   s     (r   rG   c                     | j                   | j                  |       | j                  | j                      }||dz  dz   dz  z  }|S )a  
        Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
        current timestep.

        Args:
            sample (`torch.Tensor`):
                The input sample.
            timestep (`float` or `torch.Tensor`):
                The current timestep in the diffusion chain.

        Returns:
            `torch.Tensor`:
                A scaled input sample.
        r	   r   rT   )rv   _init_step_indexrc   )re   rG   rg   sigmas       r   scale_model_inputz'HeunDiscreteScheduler.scale_model_input   sJ    & ??"!!(+DOO,E1HqLS01r   num_inference_stepsdevicerj   c           	      
   ||t        d      ||t        d      |!| j                  j                  rt        d      |!| j                  j                  rt        d      |!| j                  j                  rt        d      |xs t        |      }|| _        |xs | j                  j                  }|'t        j                  |t        j                        }n| j                  j                  dk(  r@t        j                  d	|d
z
  |t        j                        ddd   j                         }n;| j                  j                  dk(  r|| j                  z  }t        j                  d	|      |z  j                         ddd   j                         j!                  t        j                        }|| j                  j"                  z  }n| j                  j                  dk(  rf|| j                  z  }t        j                  |d	|       j                         j                         j!                  t        j                        }|d
z  }n"t        | j                  j                   d      t        j                  d
| j$                  z
  | j$                  z  dz        }t        j&                  |      }t        j(                  |t        j                  d	t        |            |      }| j                  j                  rQ| j+                  || j                        }t        j                  |D cg c]  }| j-                  ||       c}      }n| j                  j                  rG| j/                  ||      }t        j                  |D cg c]  }| j-                  ||       c}      }n\| j                  j                  rF| j1                  ||      }t        j                  |D cg c]  }| j-                  ||       c}      }t        j2                  |dgg      j!                  t        j                        }t5        j6                  |      j9                  |      }t5        j:                  |dd
 |d
d j=                  d      |dd g      | _        t5        j6                  |      }t5        j:                  |dd
 |d
d j=                  d      g      }|j9                  |t4        j                        | _         d| _!        d| _"        d| _#        d| _$        | j>                  j9                  d      | _        yc c}w c c}w c c}w )aC  
        Sets the discrete timesteps used for the diffusion chain (to be run before inference).

        Args:
            num_inference_steps (`int`, *optional*, defaults to `None`):
                The number of diffusion steps used when generating samples with a pre-trained model.
            device (`str`, `torch.device`, *optional*, defaults to `None`):
                The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
            num_train_timesteps (`int`, *optional*, defaults to `None`):
                The number of diffusion steps used when training the model. If `None`, the default
                `num_train_timesteps` attribute is used.
            timesteps (`List[int]`, *optional*, defaults to `None`):
                Custom timesteps used to support arbitrary spacing between timesteps. If `None`, timesteps will be
                generated based on the `timestep_spacing` attribute. If `timesteps` is passed, `num_inference_steps`
                must be `None`, and `timestep_spacing` attribute will be ignored.
        NzEMust pass exactly one of `num_inference_steps` or `custom_timesteps`.zACan only pass one of `num_inference_steps` or `custom_timesteps`.z=Cannot use `timesteps` with `config.use_karras_sigmas = True`zCCannot set `timesteps` with `config.use_exponential_sigmas = True`.z<Cannot set `timesteps` with `config.use_beta_sigmas = True`.r.   rO   r   r   rP   rQ   zY is not supported. Please make sure to choose one of 'linspace', 'leading' or 'trailing'.rT   )	in_sigmasr   g        )r   r	   r   r/   rW   )%r0   rX   rI   rJ   rK   rl   r   r=   nparrayr5   rN   rO   copyarangeroundastyperR   r_   loginterp_convert_to_karras_sigma_to_t_convert_to_exponential_convert_to_betaconcatenater   
from_numpyrd   catrepeat_interleaverc   rj   prev_derivativedtra   rb   )	re   r   r   r=   rj   
step_ratiorc   
log_sigmasr~   s	            r   r`   z#HeunDiscreteScheduler.set_timesteps  sy   . &9+<dee*y/D`aa T[[%B%B\]] T[[%G%Gbcc T[[%@%@[\\1CS^#6 1TT[[5T5T "**=I {{++z9KK+>+BDW_a_i_ijkomokopuuw	--:0D4L4LL
  YYq*=>KRRTUYWYUYZ__ahhikisist	T[[555	--;043K3KK
  YY':A
{KRRTYY[bbcecmcmn	Q	 {{334  5N  O  A 3 33t7J7JJsRSVVF^
9bii3v;&?H;;((,,vSWSkSk,lFSY!Z%$"2"25*"E!Z[I[[//11FXk1lFSY!Z%$"2"25*"E!Z[I[[((**VQd*eFSY!Z%$"2"25*"E!Z[I#077

C!!&),,F,;iiVAb\-K-KA-NPVWYWZP[ \]$$Y/	IIy!}im.M.Ma.PQR	"V5==I  $ kknnU+/ "[ "[ "[s   6UU0Ur~   r   c                    t        j                  t        j                  |d            }||ddt         j                  f   z
  }t        j                  |dk\  d      j                  d      j                  |j                  d   dz
        }|dz   }||   }||   }||z
  ||z
  z  }	t        j                  |	dd      }	d|	z
  |z  |	|z  z   }
|
j                  |j                        }
|
S )a  
        Convert sigma values to corresponding timestep values through interpolation.

        Args:
            sigma (`np.ndarray`):
                The sigma value(s) to convert to timestep(s).
            log_sigmas (`np.ndarray`):
                The logarithm of the sigma schedule used for interpolation.

        Returns:
            `np.ndarray`:
                The interpolated timestep value(s) corresponding to the input sigma(s).
        g|=Nr   )axisr	   )rr   r   )	r   r   maximumnewaxiscumsumargmaxclipshapereshape)re   r~   r   	log_sigmadistslow_idxhigh_idxlowhighwr+   s              r   r   z!HeunDiscreteScheduler._sigma_to_tu  s     FF2::eU34	 Jq"**}55 ))UaZq188a8@EE*JZJZ[\J]`aJaEbQ;!(# 9_t,GGAq! UgH,IIekk"r   r   c                    t        | j                  d      r| j                  j                  }nd}t        | j                  d      r| j                  j                  }nd}||n|d   j	                         }||n|d   j	                         }d}t        j                  dd|      }|d|z  z  }|d|z  z  }||||z
  z  z   |z  }	|	S )a  
        Construct the noise schedule as proposed in [Elucidating the Design Space of Diffusion-Based Generative
        Models](https://huggingface.co/papers/2206.00364).

        Args:
            in_sigmas (`torch.Tensor`):
                The input sigma values to be converted.
            num_inference_steps (`int`):
                The number of inference steps to generate the noise schedule for.

        Returns:
            `torch.Tensor`:
                The converted sigma values following the Karras noise schedule.
        	sigma_minN	sigma_maxr   r   g      @r   )hasattrrX   r   r   rm   r   rO   )
re   r   r   r   r   rhorampmin_inv_rhomax_inv_rhorc   s
             r   r   z(HeunDiscreteScheduler._convert_to_karras  s    $ 4;;,--II4;;,--II!*!6IIbM<N<N<P	!*!6IIaL<M<M<O	{{1a!45AG,AG,k(A BBsJr   c                    t        | j                  d      r| j                  j                  }nd}t        | j                  d      r| j                  j                  }nd}||n|d   j	                         }||n|d   j	                         }t        j                  t        j                  t        j                  |      t        j                  |      |            }|S )a  
        Construct an exponential noise schedule.

        Args:
            in_sigmas (`torch.Tensor`):
                The input sigma values to be converted.
            num_inference_steps (`int`):
                The number of inference steps to generate the noise schedule for.

        Returns:
            `torch.Tensor`:
                The converted sigma values following an exponential schedule.
        r   Nr   r   r   )
r   rX   r   r   rm   r   r#   rO   r'   r   )re   r   r   r   r   rc   s         r   r   z-HeunDiscreteScheduler._convert_to_exponential  s    " 4;;,--II4;;,--II!*!6IIbM<N<N<P	!*!6IIaL<M<M<O	DHHY$7)9LNabcr   alphabetac           
      (   t        | j                  d      r| j                  j                  }nd}t        | j                  d      r| j                  j                  }nd}||n|d   j	                         }||n|d   j	                         }t        j                  dt        j                  dd|      z
  D cg c]-  }t        j                  j                  j                  |||      / c}D cg c]  }||||z
  z  z    c}      }	|	S c c}w c c}w )a  
        Construct a beta noise schedule as proposed in [Beta Sampling is All You
        Need](https://huggingface.co/papers/2407.12173).

        Args:
            in_sigmas (`torch.Tensor`):
                The input sigma values to be converted.
            num_inference_steps (`int`):
                The number of inference steps to generate the noise schedule for.
            alpha (`float`, *optional*, defaults to `0.6`):
                The alpha parameter for the beta distribution.
            beta (`float`, *optional*, defaults to `0.6`):
                The beta parameter for the beta distribution.

        Returns:
            `torch.Tensor`:
                The converted sigma values following a beta distribution schedule.
        r   Nr   r   r   r   )r   rX   r   r   rm   r   r   rO   scipystatsr   ppf)
re   r   r   r   r   r   r   rg   r   rc   s
             r   r   z&HeunDiscreteScheduler._convert_to_beta  s    0 4;;,--II4;;,--II!*!6IIbM<N<N<P	!*!6IIaL<M<M<O	
 %&Aq:M(N$N  KK$$((5$? SI	$9:;
 s   82D
/Dc                     | j                   d u S N)r   rs   s    r   state_in_first_orderz*HeunDiscreteScheduler.state_in_first_order  s    ww$r   c                     | j                   Vt        |t        j                        r%|j	                  | j
                  j                        }| j                  |      | _        y| j                  | _        y)z
        Initialize the step index for the scheduler based on the given timestep.

        Args:
            timestep (`float` or `torch.Tensor`):
                The current timestep to initialize the step index from.
        N)
ry   
isinstancer   r   rd   rj   r   rp   ra   rb   )re   rg   s     r   r}   z&HeunDiscreteScheduler._init_step_index  sW     #(ELL1#;;t~~'<'<=#66x@D#00Dr   model_outputreturn_dictc                    | j                   | j                  |       | j                  r6| j                  | j                      }| j                  | j                   dz      }n5| j                  | j                   dz
     }| j                  | j                      }d}||dz   z  }| j                  j
                  dk(  r| j                  r|n|}	||	|z  z
  }
n| j                  j
                  dk(  r/| j                  r|n|}	||	 |	dz  dz   dz  z  z  ||	dz  dz   z  z   }
n?| j                  j
                  dk(  r|}
n#t        d	| j                  j
                   d
      | j                  j                  r;|
j                  | j                  j                   | j                  j                        }
| j                  r#||
z
  |z  }||z
  }|| _
        || _        || _        nG||
z
  |z  }| j                  |z   dz  }| j                  }| j                  }d| _
        d| _        d| _        |||z  z   }| xj                  dz  c_        |s||
fS t        ||
      S )a  
        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).

        Args:
            model_output (`torch.Tensor`):
                The direct output from learned diffusion model.
            timestep (`float`):
                The current discrete timestep in the diffusion chain.
            sample (`torch.Tensor`):
                A current instance of a sample created by the diffusion process.
            return_dict (`bool`):
                Whether or not to return a [`~schedulers.scheduling_heun_discrete.HeunDiscreteSchedulerOutput`] or
                tuple.

        Returns:
            [`~schedulers.scheduling_heun_discrete.HeunDiscreteSchedulerOutput`] or `tuple`:
                If return_dict is `True`, [`~schedulers.scheduling_heun_discrete.HeunDiscreteSchedulerOutput`] is
                returned, otherwise a tuple is returned where the first element is the sample tensor.
        Nr   r   rF   rH   r	   rT   rG   zprediction_type given as z, must be one of `epsilon`, or `v_prediction`)r   r   )rv   r}   r   rc   rX   rE   r0   rL   clamprM   r   r   rG   ra   r   )re   r   rg   rG   r   r~   
sigma_nextgamma	sigma_hatsigma_inputr   
derivativer   r   s                 r   stepzHeunDiscreteScheduler.step'  sj   6 ??"!!(+$$KK0ET__q%89J KK! 34ET__5J
 UQY'	 ;;&&)3'+'@'@)jK#)K,,F#F [[((N:'+'@'@)jK#/K<;PQ>TUCUZ]B]3]#^+q.1,-$  [[((H4#/ +DKK,G,G+HHtu  ;;""#7#=#=...0M0M$  $$ #779DJi'B $.D DG DK !#77:EJ..;q@J B[[F $(D DGDKzB. 	A$ 
 +{Ymnnr   original_samplesnoisec                    | j                   j                  |j                  |j                        }|j                  j                  dk(  rvt        j                  |      ra| j                  j                  |j                  t
        j                        }|j                  |j                  t
        j                        }n@| j                  j                  |j                        }|j                  |j                        }| j                   |D cg c]  }| j                  ||       }}nG| j                  | j                  g|j                  d   z  }n| j                  g|j                  d   z  }||   j                         }t        |j                        t        |j                        k  r=|j                  d      }t        |j                        t        |j                        k  r=|||z  z   }	|	S c c}w )am  
        Add noise to the original samples according to the noise schedule at the specified timesteps.

        Args:
            original_samples (`torch.Tensor`):
                The original samples to which noise will be added.
            noise (`torch.Tensor`):
                The noise tensor to add to the original samples.
            timesteps (`torch.Tensor`):
                The timesteps at which to add noise, determining the noise level from the schedule.

        Returns:
            `torch.Tensor`:
                The noisy samples with added noise scaled according to the timestep schedule.
        r   mpsr.   r   r   )rc   rd   r   r/   typer   is_floating_pointrj   r5   ry   rp   rv   r   flattenrl   	unsqueeze)
re   r   r   rj   rc   rh   r+   step_indicesr~   noisy_sampless
             r   	add_noisezHeunDiscreteScheduler.add_noise  s   , '7'>'>FVF\F\]""''50U5L5LY5W!%!2!23C3J3JRWR_R_!2!`!%5%<%<EMMRI!%!2!23C3J3J!K!%5%<%<=I #T]^qD33A7IJ^L^__( OO,yq/AAL !,,-	0BBL|$,,.%++%5%;%;!<<OOB'E %++%5%;%;!<< )55=8 _s   G9c                 .    | j                   j                  S r   )rX   r=   rs   s    r   __len__zHeunDiscreteScheduler.__len__  s    {{...r   )i  g_QK?g~jt?rA   NrF   FFFFrU   rO   r   r   )r   )NNNN)333333?r   )T)*r   r   r   r   r   name_compatiblesorderr   intfloatr   r   r   r   ndarrayr   boolrf   r   r   rp   propertyrt   rv   ry   r{   r   strr   r`   r   r   r   r   r   r}   r   r   r   r   r   ).0es   00r   r<   r<   `   s   'R %>>qAFF>LE $(#X`BFHQ,116*/&+#&GQ., ., ., 	.,
 TU.,  bjj$u+&= >?., !!DE., $D>., !)., "$., d^., !., ""CD., ., 
., .,d bf#eU\\12#HPQVQ]Q]H^#	#< 3 3     ! !(3 (t ( u||+, 
	8 .2+/-1)-Z,%c]Z, c5<<'(Z, &c]	Z,
 DI&Z, 
Z,z" " "

 "J$ELL $s $W\WcWc $N TW \a\h\h F dg..<?.HM.[`.	.`  1uell/B)C 1 1( !eoELL"**45eo u||+,eo ellBJJ./	eo
 eo 
*E1	2eoP.,,. ||. <<	.
 
.`/ /k ?s   Ir<   )g+?r"   )r'   dataclassesr   typingr   r   r   r   r   numpyr   r   configuration_utilsr
   r   utilsr   r   scheduling_utilsr   r   scipy.statsr   r   r   r   r   r:   r<   r   r   r   <module>r      s     ! 8 8   A 2 G  8* 8 8( 5=*4 *4*4 "/2*4 \\	*4Z`	/NK `	/r   