

'''simple docstring'''






import unittest
from timeit import timeit


def 					__lowerCamelCase			(      SCREAMING_SNAKE_CASE_     :	int  ,  SCREAMING_SNAKE_CASE_     :	int    )							->   int:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_      :			Optional[Any]     =       first_num if first_num >= second_num else second_num
      SCREAMING_SNAKE_CASE_      :			str     =       max_num
      while (common_mult % first_num > 0) or (common_mult % second_num > 0):
            common_mult += max_num
      return common_mult


def 					__lowerCamelCase			(      SCREAMING_SNAKE_CASE_     :	int  ,  SCREAMING_SNAKE_CASE_     :	int    )							->   int:
      """simple docstring"""

      return b if a == 0 else greatest_common_divisor(b % a  ,  SCREAMING_SNAKE_CASE_    )


def 					__lowerCamelCase			(      SCREAMING_SNAKE_CASE_     :	int  ,  SCREAMING_SNAKE_CASE_     :	int    )							->   int:
      """simple docstring"""

      return first_num // greatest_common_divisor(SCREAMING_SNAKE_CASE_  ,  SCREAMING_SNAKE_CASE_    ) * second_num


def 					__lowerCamelCase			(      )							->   Optional[int]:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_      :			List[Any]     =       (
          "from __main__ import least_common_multiple_slow, least_common_multiple_fast"
      )
      print(
          "least_common_multiple_slow():"  ,  timeit("least_common_multiple_slow(1000, 999)"  ,  setup=SCREAMING_SNAKE_CASE_    )  ,  )
      print(
          "least_common_multiple_fast():"  ,  timeit("least_common_multiple_fast(1000, 999)"  ,  setup=SCREAMING_SNAKE_CASE_    )  ,  )
class 	SCREAMING_SNAKE_CASE__			(				unittest.TestCase      ):
    _A			    =							(
        (10, 20),
        (13, 15),
        (4, 31),
        (10, 42),
        (43, 34),
        (5, 12),
        (12, 25),
        (10, 25),
        (6, 9),
    )
    _A			    =							(20, 195, 124, 210, 1_462, 60, 300, 50, 18)




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          for i, (first_num, second_num) in enumerate(self.test_inputs			):
                SCREAMING_SNAKE_CASE_      :			List[Any]     =       least_common_multiple_slow(lowercase__				,     lowercase__			)
                SCREAMING_SNAKE_CASE_      :			List[str]     =       least_common_multiple_fast(lowercase__				,     lowercase__			)
                with self.subTest(i=lowercase__			):
                      self.assertEqual(lowercase__				,     self.expected_results[i]			)
                      self.assertEqual(lowercase__				,     self.expected_results[i]			)


if __name__ == "__main__":
      benchmark()
      unittest.main()




'''simple docstring'''






import torch

from diffusers import EulerAncestralDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest
class 	SCREAMING_SNAKE_CASE__			(				_UpperCAmelCase      ):
    _A			    =							(EulerAncestralDiscreteScheduler,)
    _A			    =							10




    def   __lowerCamelCase      (					self				,     **lowercase__			):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_      :			List[Any]     =       {
              "num_train_timesteps": 1100,
              "beta_start": 0.0001,
              "beta_end": 0.02,
              "beta_schedule": "linear",
          }

          config.update(**lowercase__			)
          return config




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          for timesteps in [10, 50, 100, 1000]:
                self.check_over_configs(num_train_timesteps=lowercase__			)




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          for beta_start, beta_end in zip([0.00001, 0.0001, 0.001]				,     [0.0002, 0.002, 0.02]			):
                self.check_over_configs(beta_start=lowercase__				,     beta_end=lowercase__			)




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          for schedule in ["linear", "scaled_linear"]:
                self.check_over_configs(beta_schedule=lowercase__			)




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          for prediction_type in ["epsilon", "v_prediction"]:
                self.check_over_configs(prediction_type=lowercase__			)




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_      :			int     =       self.scheduler_classes[0]
          SCREAMING_SNAKE_CASE_      :			Optional[int]     =       self.get_scheduler_config()
          SCREAMING_SNAKE_CASE_      :			Any     =       scheduler_class(**lowercase__			)

          scheduler.set_timesteps(self.num_inference_steps			)

          SCREAMING_SNAKE_CASE_      :			int     =       torch.manual_seed(0			)

          SCREAMING_SNAKE_CASE_      :			Optional[Any]     =       self.dummy_model()
          SCREAMING_SNAKE_CASE_      :			List[Any]     =       self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
          SCREAMING_SNAKE_CASE_      :			List[Any]     =       sample.to(lowercase__			)

          for i, t in enumerate(scheduler.timesteps			):
                SCREAMING_SNAKE_CASE_      :			Tuple     =       scheduler.scale_model_input(lowercase__				,     lowercase__			)

                SCREAMING_SNAKE_CASE_      :			List[str]     =       model(lowercase__				,     lowercase__			)

                SCREAMING_SNAKE_CASE_      :			Dict     =       scheduler.step(lowercase__				,     lowercase__				,     lowercase__				,     generator=lowercase__			)
                SCREAMING_SNAKE_CASE_      :			Tuple     =       output.prev_sample

          SCREAMING_SNAKE_CASE_      :			List[str]     =       torch.sum(torch.abs(lowercase__			)			)
          SCREAMING_SNAKE_CASE_      :			Tuple     =       torch.mean(torch.abs(lowercase__			)			)

          assert abs(result_sum.item() - 152.3192			) < 1e-2
          assert abs(result_mean.item() - 0.1983			) < 1e-3




    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_      :			int     =       self.scheduler_classes[0]
          SCREAMING_SNAKE_CASE_      :			Tuple     =       self.get_scheduler_config(prediction_type="v_prediction"			)
          SCREAMING_SNAKE_CASE_      :			str     =       scheduler_class(**lowercase__			)

          scheduler.set_timesteps(self.num_inference_steps			)

          SCREAMING_SNAKE_CASE_      :			Dict     =       torch.manual_seed(0			)

          SCREAMING_SNAKE_CASE_      :			Tuple     =       self.dummy_model()
          SCREAMING_SNAKE_CASE_      :			List[Any]     =       self.dummy_sample_deter * scheduler.init_noise_sigma
          SCREAMING_SNAKE_CASE_      :			Union[str, Any]     =       sample.to(lowercase__			)

          for i, t in enumerate(scheduler.timesteps			):
                SCREAMING_SNAKE_CASE_      :			List[str]     =       scheduler.scale_model_input(lowercase__				,     lowercase__			)

                SCREAMING_SNAKE_CASE_      :			List[Any]     =       model(lowercase__				,     lowercase__			)

                SCREAMING_SNAKE_CASE_      :			Union[str, Any]     =       scheduler.step(lowercase__				,     lowercase__				,     lowercase__				,     generator=lowercase__			)
                SCREAMING_SNAKE_CASE_      :			List[Any]     =       output.prev_sample

          SCREAMING_SNAKE_CASE_      :			List[Any]     =       torch.sum(torch.abs(lowercase__			)			)
          SCREAMING_SNAKE_CASE_      :			Dict     =       torch.mean(torch.abs(lowercase__			)			)

          assert abs(result_sum.item() - 108.4439			) < 1e-2
          assert abs(result_mean.item() - 0.1412			) < 1e-3







    def   __lowerCamelCase      (					self			):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_      :			Union[str, Any]     =       self.scheduler_classes[0]
          SCREAMING_SNAKE_CASE_      :			List[str]     =       self.get_scheduler_config()
          SCREAMING_SNAKE_CASE_      :			Tuple     =       scheduler_class(**lowercase__			)

          scheduler.set_timesteps(self.num_inference_steps				,     device=lowercase__			)
          SCREAMING_SNAKE_CASE_      :			Any     =       torch.manual_seed(0			)

          SCREAMING_SNAKE_CASE_      :			List[Any]     =       self.dummy_model()
          SCREAMING_SNAKE_CASE_      :			Optional[int]     =       self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
          SCREAMING_SNAKE_CASE_      :			List[Any]     =       sample.to(lowercase__			)

          for t in scheduler.timesteps:
                SCREAMING_SNAKE_CASE_      :			Dict     =       scheduler.scale_model_input(lowercase__				,     lowercase__			)

                SCREAMING_SNAKE_CASE_      :			Optional[Any]     =       model(lowercase__				,     lowercase__			)

                SCREAMING_SNAKE_CASE_      :			Optional[Any]     =       scheduler.step(lowercase__				,     lowercase__				,     lowercase__				,     generator=lowercase__			)
                SCREAMING_SNAKE_CASE_      :			List[str]     =       output.prev_sample

          SCREAMING_SNAKE_CASE_      :			Any     =       torch.sum(torch.abs(lowercase__			)			)
          SCREAMING_SNAKE_CASE_      :			Union[str, Any]     =       torch.mean(torch.abs(lowercase__			)			)

          assert abs(result_sum.item() - 152.3192			) < 1e-2
          assert abs(result_mean.item() - 0.1983			) < 1e-3

