code: 
  
  
  
  
  
  
  """simple docstring"""
  import torch
  
  from diffusers import HeunDiscreteScheduler
  from diffusers.utils import torch_device
  
  from .test_schedulers import SchedulerCommonTest
  
  
  
  class 					UpperCamelCase__   (							__UpperCAmelCase):
  
  
  
  
  
  
  
      """simple docstring"""
      __UpperCAmelCase											=   (HeunDiscreteScheduler,)
      __UpperCAmelCase											=   10
  
  
  
  
  
  
  
      def 							a__ (		self   :  Union[str, Any]							,						**UpperCamelCase_   :  Tuple   ):
  
  
  
  
  
             '''simple docstring'''
  
             __magic_name__										=						{
                 '''num_train_timesteps''': 1_1_0_0,
                 '''beta_start''': 0.0_001,
                 '''beta_end''': 0.02,
                 '''beta_schedule''': '''linear''',
             }
  
             config.update(**lowercase_   )
             return config
  
  
  
  
  
  
  
      def 							a__ (		self   :  Any   ):
  
  
  
  
  
             '''simple docstring'''
  
             for timesteps in [1_0, 5_0, 1_0_0, 1_0_0_0]:
                    self.check_over_configs(num_train_timesteps=lowercase_   )
  
  
  
  
  
  
  
      def 							a__ (		self   :  Union[str, Any]   ):
  
  
  
  
  
             '''simple docstring'''
  
             for beta_start, beta_end in zip([0.00_001, 0.0_001, 0.001]							,						[0.0_002, 0.002, 0.02]   ):
                    self.check_over_configs(beta_start=lowercase_							,						beta_end=lowercase_   )
  
  
  
  
  
  
  
      def 							a__ (		self   :  str   ):
  
  
  
  
  
             '''simple docstring'''
  
             for schedule in ["linear", "scaled_linear", "exp"]:
                    self.check_over_configs(beta_schedule=lowercase_   )
  
  
  
  
  
  
  
      def 							a__ (		self   :  Any   ):
  
  
  
  
  
             '''simple docstring'''
  
             for clip_sample_range in [1.0, 2.0, 3.0]:
                    self.check_over_configs(clip_sample_range=lowercase_							,						clip_sample=lowercase_   )
  
  
  
  
  
  
  
      def 							a__ (		self   :  Union[str, Any]   ):
  
  
  
  
  
             '''simple docstring'''
  
             for prediction_type in ["epsilon", "v_prediction", "sample"]:
                    self.check_over_configs(prediction_type=lowercase_   )
  
  
  
  
  
  
  
      def 							a__ (		self   :  Optional[int]   ):
  
  
  
  
  
             '''simple docstring'''
  
             __magic_name__										=						self.scheduler_classes[0]
             __magic_name__										=						self.get_scheduler_config()
             __magic_name__										=						scheduler_class(**lowercase_   )
  
             scheduler.set_timesteps(self.num_inference_steps   )
  
             __magic_name__										=						self.dummy_model()
             __magic_name__										=						self.dummy_sample_deter * scheduler.init_noise_sigma
             __magic_name__										=						sample.to(lowercase_   )
  
             for i, t in enumerate(scheduler.timesteps   ):
                    __magic_name__										=						scheduler.scale_model_input(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						model(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						scheduler.step(lowercase_							,						lowercase_							,						lowercase_   )
                    __magic_name__										=						output.prev_sample
  
             __magic_name__										=						torch.sum(torch.abs(lowercase_   )   )
             __magic_name__										=						torch.mean(torch.abs(lowercase_   )   )
  
             if torch_device in ["cpu", "mps"]:
                    assert abs(result_sum.item() - 0.1_233   ) < 1e-2
                    assert abs(result_mean.item() - 0.0_002   ) < 1e-3
             else:
                    # CUDA
                    assert abs(result_sum.item() - 0.1_233   ) < 1e-2
                    assert abs(result_mean.item() - 0.0_002   ) < 1e-3
  
  
  
  
  
  
  
      def 							a__ (		self   :  List[str]   ):
  
  
  
  
  
             '''simple docstring'''
  
             __magic_name__										=						self.scheduler_classes[0]
             __magic_name__										=						self.get_scheduler_config(prediction_type='v_prediction'   )
             __magic_name__										=						scheduler_class(**lowercase_   )
  
             scheduler.set_timesteps(self.num_inference_steps   )
  
             __magic_name__										=						self.dummy_model()
             __magic_name__										=						self.dummy_sample_deter * scheduler.init_noise_sigma
             __magic_name__										=						sample.to(lowercase_   )
  
             for i, t in enumerate(scheduler.timesteps   ):
                    __magic_name__										=						scheduler.scale_model_input(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						model(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						scheduler.step(lowercase_							,						lowercase_							,						lowercase_   )
                    __magic_name__										=						output.prev_sample
  
             __magic_name__										=						torch.sum(torch.abs(lowercase_   )   )
             __magic_name__										=						torch.mean(torch.abs(lowercase_   )   )
  
             if torch_device in ["cpu", "mps"]:
                    assert abs(result_sum.item() - 4.6_9_3_4e-0_7   ) < 1e-2
                    assert abs(result_mean.item() - 6.1_1_1_2e-1_0   ) < 1e-3
             else:
                    # CUDA
                    assert abs(result_sum.item() - 4.6_9_3_4_2_8_6_5_0_1_7_0_9_7_2e-0_7   ) < 1e-2
                    assert abs(result_mean.item() - 0.0_002   ) < 1e-3
  
  
  
  
  
  
  
      def 							a__ (		self   :  Any   ):
  
  
  
  
  
             '''simple docstring'''
  
             __magic_name__										=						self.scheduler_classes[0]
             __magic_name__										=						self.get_scheduler_config()
             __magic_name__										=						scheduler_class(**lowercase_   )
  
             scheduler.set_timesteps(self.num_inference_steps							,						device=lowercase_   )
  
             __magic_name__										=						self.dummy_model()
             __magic_name__										=						self.dummy_sample_deter.to(lowercase_   ) * scheduler.init_noise_sigma
  
             for t in scheduler.timesteps:
                    __magic_name__										=						scheduler.scale_model_input(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						model(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						scheduler.step(lowercase_							,						lowercase_							,						lowercase_   )
                    __magic_name__										=						output.prev_sample
  
             __magic_name__										=						torch.sum(torch.abs(lowercase_   )   )
             __magic_name__										=						torch.mean(torch.abs(lowercase_   )   )
  
             if str(lowercase_   ).startswith('cpu'   ):
                    # The following sum varies between 148 and 156 on mps. Why?
                    assert abs(result_sum.item() - 0.1_233   ) < 1e-2
                    assert abs(result_mean.item() - 0.0_002   ) < 1e-3
             elif str(lowercase_   ).startswith('mps'   ):
                    # Larger tolerance on mps
                    assert abs(result_mean.item() - 0.0_002   ) < 1e-2
             else:
                    # CUDA
                    assert abs(result_sum.item() - 0.1_233   ) < 1e-2
                    assert abs(result_mean.item() - 0.0_002   ) < 1e-3
  
  
  
  
  
  
  
      def 							a__ (		self   :  Optional[int]   ):
  
  
  
  
  
             '''simple docstring'''
  
             __magic_name__										=						self.scheduler_classes[0]
             __magic_name__										=						self.get_scheduler_config()
             __magic_name__										=						scheduler_class(**lowercase_							,						use_karras_sigmas=lowercase_   )
  
             scheduler.set_timesteps(self.num_inference_steps							,						device=lowercase_   )
  
             __magic_name__										=						self.dummy_model()
             __magic_name__										=						self.dummy_sample_deter.to(lowercase_   ) * scheduler.init_noise_sigma
             __magic_name__										=						sample.to(lowercase_   )
  
             for t in scheduler.timesteps:
                    __magic_name__										=						scheduler.scale_model_input(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						model(lowercase_							,						lowercase_   )
  
                    __magic_name__										=						scheduler.step(lowercase_							,						lowercase_							,						lowercase_   )
                    __magic_name__										=						output.prev_sample
  
             __magic_name__										=						torch.sum(torch.abs(lowercase_   )   )
             __magic_name__										=						torch.mean(torch.abs(lowercase_   )   )
  
             assert abs(result_sum.item() - 0.00_015   ) < 1e-2
             assert abs(result_mean.item() - 1.9_8_6_9_5_5_4_5_3_5_0_3_4_6_9_5e-0_7   ) < 1e-2
  
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
  
  
  snake_case   :   Optional[int]    		=		{
      """configuration_splinter""": ["""SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SplinterConfig"""],
      """tokenization_splinter""": ["""SplinterTokenizer"""],
  }
  
  try:
   if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
   pass
  else:
   snake_case   :   Dict    		=		["""SplinterTokenizerFast"""]
  
  try:
   if not is_torch_available():
    raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
   pass
  else:
   snake_case   :   Dict    		=		[
       """SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """SplinterForQuestionAnswering""",
       """SplinterForPreTraining""",
       """SplinterLayer""",
       """SplinterModel""",
       """SplinterPreTrainedModel""",
   ]
  
  
  if TYPE_CHECKING:
   from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
   from .tokenization_splinter import SplinterTokenizer
  
   try:
    if not is_tokenizers_available():
     raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
    pass
   else:
    from .tokenization_splinter_fast import SplinterTokenizerFast
  
   try:
    if not is_torch_available():
     raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
    pass
   else:
    from .modeling_splinter import (
        SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
        SplinterForPreTraining,
        SplinterForQuestionAnswering,
        SplinterLayer,
        SplinterModel,
        SplinterPreTrainedModel,
    )
  
  
  else:
   import sys
  
   snake_case   :   List[str]    		=		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)