code: 
  
  
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  import torch
  
  from diffusers import LMSDiscreteScheduler
  from diffusers.utils import torch_device
  
  from .test_schedulers import SchedulerCommonTest
  
  
  
  
  
  
  
  class 							UpperCAmelCase_     (		__lowerCamelCase		):
       __lowerCamelCase										=     (LMSDiscreteScheduler,)
       __lowerCamelCase										=     10
  
  
  
  
       def      __UpperCAmelCase     (							self  ,	**_lowerCAmelCase		):
            UpperCAmelCase__			:     Tuple										= {
                """num_train_timesteps""": 1100,
                """beta_start""": 0.0_0_0_1,
                """beta_end""": 0.0_2,
                """beta_schedule""": """linear""",
            }
  
            config.update(**_lowerCAmelCase		)
            return config
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            for timesteps in [10, 50, 100, 1000]:
                 self.check_over_configs(num_train_timesteps=_lowerCAmelCase		)
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            for beta_start, beta_end in zip([0.0_0_0_0_1, 0.0_0_0_1, 0.0_0_1]  ,	[0.0_0_0_2, 0.0_0_2, 0.0_2]		):
                 self.check_over_configs(beta_start=_lowerCAmelCase  ,	beta_end=_lowerCAmelCase		)
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            for schedule in ["linear", "scaled_linear"]:
                 self.check_over_configs(beta_schedule=_lowerCAmelCase		)
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            for prediction_type in ["epsilon", "v_prediction"]:
                 self.check_over_configs(prediction_type=_lowerCAmelCase		)
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            for t in [0, 500, 800]:
                 self.check_over_forward(time_step=_lowerCAmelCase		)
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            UpperCAmelCase__			:     Optional[Any]										= self.scheduler_classes[0]
            UpperCAmelCase__			:     Dict										= self.get_scheduler_config()
            UpperCAmelCase__			:     Optional[int]										= scheduler_class(**_lowerCAmelCase		)
  
            scheduler.set_timesteps(self.num_inference_steps		)
  
            UpperCAmelCase__			:     Tuple										= self.dummy_model()
            UpperCAmelCase__			:     str										= self.dummy_sample_deter * scheduler.init_noise_sigma
  
            for i, t in enumerate(scheduler.timesteps		):
                 UpperCAmelCase__			:     Union[str, Any]										= scheduler.scale_model_input(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     Optional[Any]										= model(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     Union[str, Any]										= scheduler.step(_lowerCAmelCase  ,	_lowerCAmelCase  ,	_lowerCAmelCase		)
                 UpperCAmelCase__			:     str										= output.prev_sample
  
            UpperCAmelCase__			:     List[Any]										= torch.sum(torch.abs(_lowerCAmelCase		)		)
            UpperCAmelCase__			:     Any										= torch.mean(torch.abs(_lowerCAmelCase		)		)
  
            assert abs(result_sum.item() - 1006.388		) < 1e-2
            assert abs(result_mean.item() - 1.3_1		) < 1e-3
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            UpperCAmelCase__			:     Union[str, Any]										= self.scheduler_classes[0]
            UpperCAmelCase__			:     Optional[Any]										= self.get_scheduler_config(prediction_type="""v_prediction"""		)
            UpperCAmelCase__			:     Tuple										= scheduler_class(**_lowerCAmelCase		)
  
            scheduler.set_timesteps(self.num_inference_steps		)
  
            UpperCAmelCase__			:     List[str]										= self.dummy_model()
            UpperCAmelCase__			:     int										= self.dummy_sample_deter * scheduler.init_noise_sigma
  
            for i, t in enumerate(scheduler.timesteps		):
                 UpperCAmelCase__			:     Optional[int]										= scheduler.scale_model_input(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     List[str]										= model(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     Tuple										= scheduler.step(_lowerCAmelCase  ,	_lowerCAmelCase  ,	_lowerCAmelCase		)
                 UpperCAmelCase__			:     Any										= output.prev_sample
  
            UpperCAmelCase__			:     Optional[Any]										= torch.sum(torch.abs(_lowerCAmelCase		)		)
            UpperCAmelCase__			:     Optional[int]										= torch.mean(torch.abs(_lowerCAmelCase		)		)
  
            assert abs(result_sum.item() - 0.0_0_1_7		) < 1e-2
            assert abs(result_mean.item() - 2.2676e-06		) < 1e-3
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            UpperCAmelCase__			:     int										= self.scheduler_classes[0]
            UpperCAmelCase__			:     Union[str, Any]										= self.get_scheduler_config()
            UpperCAmelCase__			:     Any										= scheduler_class(**_lowerCAmelCase		)
  
            scheduler.set_timesteps(self.num_inference_steps  ,	device=_lowerCAmelCase		)
  
            UpperCAmelCase__			:     Any										= self.dummy_model()
            UpperCAmelCase__			:     Optional[int]										= self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
            UpperCAmelCase__			:     List[str]										= sample.to(_lowerCAmelCase		)
  
            for i, t in enumerate(scheduler.timesteps		):
                 UpperCAmelCase__			:     Optional[Any]										= scheduler.scale_model_input(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     Optional[Any]										= model(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     Optional[Any]										= scheduler.step(_lowerCAmelCase  ,	_lowerCAmelCase  ,	_lowerCAmelCase		)
                 UpperCAmelCase__			:     Dict										= output.prev_sample
  
            UpperCAmelCase__			:     Dict										= torch.sum(torch.abs(_lowerCAmelCase		)		)
            UpperCAmelCase__			:     Union[str, Any]										= torch.mean(torch.abs(_lowerCAmelCase		)		)
  
            assert abs(result_sum.item() - 1006.388		) < 1e-2
            assert abs(result_mean.item() - 1.3_1		) < 1e-3
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            UpperCAmelCase__			:     Union[str, Any]										= self.scheduler_classes[0]
            UpperCAmelCase__			:     Dict										= self.get_scheduler_config()
            UpperCAmelCase__			:     Dict										= scheduler_class(**_lowerCAmelCase  ,	use_karras_sigmas=_lowerCAmelCase		)
  
            scheduler.set_timesteps(self.num_inference_steps  ,	device=_lowerCAmelCase		)
  
            UpperCAmelCase__			:     str										= self.dummy_model()
            UpperCAmelCase__			:     Optional[int]										= self.dummy_sample_deter.to(_lowerCAmelCase		) * scheduler.init_noise_sigma
            UpperCAmelCase__			:     Optional[int]										= sample.to(_lowerCAmelCase		)
  
            for t in scheduler.timesteps:
                 UpperCAmelCase__			:     List[Any]										= scheduler.scale_model_input(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     str										= model(_lowerCAmelCase  ,	_lowerCAmelCase		)
  
                 UpperCAmelCase__			:     int										= scheduler.step(_lowerCAmelCase  ,	_lowerCAmelCase  ,	_lowerCAmelCase		)
                 UpperCAmelCase__			:     Any										= output.prev_sample
  
            UpperCAmelCase__			:     Optional[int]										= torch.sum(torch.abs(_lowerCAmelCase		)		)
            UpperCAmelCase__			:     Union[str, Any]										= torch.mean(torch.abs(_lowerCAmelCase		)		)
  
            assert abs(result_sum.item() - 3812.9927		) < 2e-2
            assert abs(result_mean.item() - 4.9_6_4_8		) < 1e-3
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  
  import random
  
  
  
  
  
  
  
  class 							UpperCAmelCase_     :
  
  
  
  
       def __init__(							self  ,	_lowerCAmelCase  ,	_lowerCAmelCase		):
            UpperCAmelCase__			:     Union[str, Any]										= x
            UpperCAmelCase__			:     Union[str, Any]										= y
  
  
  
  
       def      __UpperCAmelCase     (							self		):
            return (self.x**2 + self.y**2) <= 1
  
  
  
  
       @classmethod
       def      __UpperCAmelCase     (							cls		):
            return cls(x=random.random()  ,	y=random.random()		)
  
  
  
  
  
  def    _lowerCamelCase	(	__lowerCamelCase					)   -> float:
  
       '''simple docstring'''
       if number_of_simulations < 1:
            raise ValueError("""At least one simulation is necessary to estimate PI."""					)
  
       UpperCAmelCase__			:     Dict										= 0
       for _ in range(__lowerCamelCase					):
            UpperCAmelCase__			:     Union[str, Any]										= Point.random_unit_square()
  
            if random_point.is_in_unit_circle():
                 number_in_unit_circle += 1
  
       return 4 * number_in_unit_circle / number_of_simulations
  
  
  if __name__ == "__main__":
        # import doctest
  
        # doctest.testmod()
        from math import pi
  
        SCREAMING_SNAKE_CASE__		:       List[str]   							=							"""Please enter the desired number of Monte Carlo simulations: """
        SCREAMING_SNAKE_CASE__		:       int   							=							estimate_pi(int(input(prompt).strip()))
        print(f'''An estimate of PI is {my_pi} with an error of {abs(my_pi - pi)}''')
  
  
  
  
  
  
  