




'''simple docstring'''






import tempfile

import torch

from diffusers import PNDMScheduler

from .test_schedulers import SchedulerCommonTest






class        lowercase_      (						UpperCAmelCase__							):
     A_											=			(PNDMScheduler,)
     A_											=			(('''num_inference_steps''', 5_0),)





     def 			_lowerCAmelCase      (     self     :					Tuple     ,							**__lowerCamelCase     :					Tuple			):
           snake_case__       :   List[str]	      =    {
               'num_train_timesteps': 1000,
               'beta_start': 0.0_0_0_1,
               'beta_end': 0.0_2,
               'beta_schedule': 'linear',
           }

           config.update(**__lowerCAmelCase			)
           return config





     def 			_lowerCAmelCase      (     self     :					Optional[Any]     ,							__lowerCamelCase     :					int=0     ,							**__lowerCamelCase     :					List[str]			):
           snake_case__       :   int	      =    dict(self.forward_default_kwargs			)
           snake_case__       :   Dict	      =    kwargs.pop('num_inference_steps'     ,							__lowerCAmelCase			)
           snake_case__       :   List[str]	      =    self.dummy_sample
           snake_case__       :   List[str]	      =    0.1 * sample
           snake_case__       :   Optional[int]	      =    [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]

           for scheduler_class in self.scheduler_classes:
                 snake_case__       :   Optional[int]	      =    self.get_scheduler_config(**__lowerCAmelCase			)
                 snake_case__       :   Tuple	      =    scheduler_class(**__lowerCAmelCase			)
                 scheduler.set_timesteps(__lowerCAmelCase			)
                 # copy over dummy past residuals
                 snake_case__       :   Dict	      =    dummy_past_residuals[:]

                 with tempfile.TemporaryDirectory() as tmpdirname:
                       scheduler.save_config(__lowerCAmelCase			)
                       snake_case__       :   Tuple	      =    scheduler_class.from_pretrained(__lowerCAmelCase			)
                       new_scheduler.set_timesteps(__lowerCAmelCase			)
                       # copy over dummy past residuals
                       snake_case__       :   Optional[Any]	      =    dummy_past_residuals[:]

                 snake_case__       :   Dict	      =    scheduler.step_prk(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample
                 snake_case__       :   str	      =    new_scheduler.step_prk(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample

                 assert torch.sum(torch.abs(output - new_output			)			) < 1E-5, "Scheduler outputs are not identical"

                 snake_case__       :   int	      =    scheduler.step_plms(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample
                 snake_case__       :   Optional[Any]	      =    new_scheduler.step_plms(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample

                 assert torch.sum(torch.abs(output - new_output			)			) < 1E-5, "Scheduler outputs are not identical"





     def 			_lowerCAmelCase      (     self     :					str			):
           pass





     def 			_lowerCAmelCase      (     self     :					Any     ,							__lowerCamelCase     :					List[str]=0     ,							**__lowerCamelCase     :					int			):
           snake_case__       :   List[str]	      =    dict(self.forward_default_kwargs			)
           snake_case__       :   List[Any]	      =    kwargs.pop('num_inference_steps'     ,							__lowerCAmelCase			)
           snake_case__       :   int	      =    self.dummy_sample
           snake_case__       :   List[Any]	      =    0.1 * sample
           snake_case__       :   Optional[int]	      =    [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]

           for scheduler_class in self.scheduler_classes:
                 snake_case__       :   Any	      =    self.get_scheduler_config()
                 snake_case__       :   List[Any]	      =    scheduler_class(**__lowerCAmelCase			)
                 scheduler.set_timesteps(__lowerCAmelCase			)

                 # copy over dummy past residuals (must be after setting timesteps)
                 snake_case__       :   List[str]	      =    dummy_past_residuals[:]

                 with tempfile.TemporaryDirectory() as tmpdirname:
                       scheduler.save_config(__lowerCAmelCase			)
                       snake_case__       :   str	      =    scheduler_class.from_pretrained(__lowerCAmelCase			)
                       # copy over dummy past residuals
                       new_scheduler.set_timesteps(__lowerCAmelCase			)

                       # copy over dummy past residual (must be after setting timesteps)
                       snake_case__       :   Optional[Any]	      =    dummy_past_residuals[:]

                 snake_case__       :   Optional[Any]	      =    scheduler.step_prk(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample
                 snake_case__       :   Dict	      =    new_scheduler.step_prk(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample

                 assert torch.sum(torch.abs(output - new_output			)			) < 1E-5, "Scheduler outputs are not identical"

                 snake_case__       :   List[Any]	      =    scheduler.step_plms(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample
                 snake_case__       :   int	      =    new_scheduler.step_plms(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample

                 assert torch.sum(torch.abs(output - new_output			)			) < 1E-5, "Scheduler outputs are not identical"





     def 			_lowerCAmelCase      (     self     :					Optional[int]     ,							**__lowerCamelCase     :					Dict			):
           snake_case__       :   Union[str, Any]	      =    self.scheduler_classes[0]
           snake_case__       :   Any	      =    self.get_scheduler_config(**__lowerCAmelCase			)
           snake_case__       :   List[Any]	      =    scheduler_class(**__lowerCAmelCase			)

           snake_case__       :   List[str]	      =    10
           snake_case__       :   Optional[Any]	      =    self.dummy_model()
           snake_case__       :   Optional[Any]	      =    self.dummy_sample_deter
           scheduler.set_timesteps(__lowerCAmelCase			)

           for i, t in enumerate(scheduler.prk_timesteps			):
                 snake_case__       :   List[str]	      =    model(__lowerCAmelCase     ,							__lowerCAmelCase			)
                 snake_case__       :   int	      =    scheduler.step_prk(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase			).prev_sample

           for i, t in enumerate(scheduler.plms_timesteps			):
                 snake_case__       :   int	      =    model(__lowerCAmelCase     ,							__lowerCAmelCase			)
                 snake_case__       :   List[str]	      =    scheduler.step_plms(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase			).prev_sample

           return sample





     def 			_lowerCAmelCase      (     self     :					Tuple			):
           snake_case__       :   Union[str, Any]	      =    dict(self.forward_default_kwargs			)

           snake_case__       :   Union[str, Any]	      =    kwargs.pop('num_inference_steps'     ,							__lowerCAmelCase			)

           for scheduler_class in self.scheduler_classes:
                 snake_case__       :   Union[str, Any]	      =    self.get_scheduler_config()
                 snake_case__       :   List[str]	      =    scheduler_class(**__lowerCAmelCase			)

                 snake_case__       :   str	      =    self.dummy_sample
                 snake_case__       :   Optional[int]	      =    0.1 * sample

                 if num_inference_steps is not None and hasattr(__lowerCAmelCase     ,							'set_timesteps'			):
                       scheduler.set_timesteps(__lowerCAmelCase			)
                 elif num_inference_steps is not None and not hasattr(__lowerCAmelCase     ,							'set_timesteps'			):
                       snake_case__       :   Any	      =    num_inference_steps

                 # copy over dummy past residuals (must be done after set_timesteps)
                 snake_case__       :   str	      =    [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]
                 snake_case__       :   List[Any]	      =    dummy_past_residuals[:]

                 snake_case__       :   List[Any]	      =    scheduler.step_prk(__lowerCAmelCase     ,							0     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample
                 snake_case__       :   List[str]	      =    scheduler.step_prk(__lowerCAmelCase     ,							1     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample

                 self.assertEqual(output_a.shape     ,							sample.shape			)
                 self.assertEqual(output_a.shape     ,							output_a.shape			)

                 snake_case__       :   Union[str, Any]	      =    scheduler.step_plms(__lowerCAmelCase     ,							0     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample
                 snake_case__       :   List[Any]	      =    scheduler.step_plms(__lowerCAmelCase     ,							1     ,							__lowerCAmelCase     ,							**__lowerCAmelCase			).prev_sample

                 self.assertEqual(output_a.shape     ,							sample.shape			)
                 self.assertEqual(output_a.shape     ,							output_a.shape			)





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           for timesteps in [100, 1000]:
                 self.check_over_configs(num_train_timesteps=__lowerCAmelCase			)





     def 			_lowerCAmelCase      (     self     :					Optional[int]			):
           for steps_offset in [0, 1]:
                 self.check_over_configs(steps_offset=__lowerCAmelCase			)

           snake_case__       :   Any	      =    self.scheduler_classes[0]
           snake_case__       :   str	      =    self.get_scheduler_config(steps_offset=1			)
           snake_case__       :   List[str]	      =    scheduler_class(**__lowerCAmelCase			)
           scheduler.set_timesteps(10			)
           assert torch.equal(
               scheduler.timesteps     ,							torch.LongTensor(
                   [901, 851, 851, 801, 801, 751, 751, 701, 701, 651, 651, 601, 601, 501, 401, 301, 201, 101, 1]			)     ,							)





     def 			_lowerCAmelCase      (     self     :					Any			):
           for beta_start, beta_end in zip([0.0_0_0_1, 0.0_0_1]     ,							[0.0_0_2, 0.0_2]			):
                 self.check_over_configs(beta_start=__lowerCAmelCase     ,							beta_end=__lowerCAmelCase			)





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           for schedule in ["linear", "squaredcos_cap_v2"]:
                 self.check_over_configs(beta_schedule=__lowerCAmelCase			)





     def 			_lowerCAmelCase      (     self     :					Optional[int]			):
           for prediction_type in ["epsilon", "v_prediction"]:
                 self.check_over_configs(prediction_type=__lowerCAmelCase			)





     def 			_lowerCAmelCase      (     self     :					Any			):
           for t in [1, 5, 10]:
                 self.check_over_forward(time_step=__lowerCAmelCase			)





     def 			_lowerCAmelCase      (     self     :					Dict			):
           for t, num_inference_steps in zip([1, 5, 10]     ,							[10, 50, 100]			):
                 self.check_over_forward(num_inference_steps=__lowerCAmelCase			)





     def 			_lowerCAmelCase      (     self     :					Dict			):
           # earlier version of set_timesteps() caused an error indexing alpha's with inference steps as power of 3
           snake_case__       :   Union[str, Any]	      =    27

           for scheduler_class in self.scheduler_classes:
                 snake_case__       :   Tuple	      =    self.dummy_sample
                 snake_case__       :   str	      =    0.1 * sample

                 snake_case__       :   Any	      =    self.get_scheduler_config()
                 snake_case__       :   Tuple	      =    scheduler_class(**__lowerCAmelCase			)

                 scheduler.set_timesteps(__lowerCAmelCase			)

                 # before power of 3 fix, would error on first step, so we only need to do two
                 for i, t in enumerate(scheduler.prk_timesteps[:2]			):
                       snake_case__       :   Optional[int]	      =    scheduler.step_prk(__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase			).prev_sample





     def 			_lowerCAmelCase      (     self     :					Any			):
           with self.assertRaises(__lowerCAmelCase			):
                 snake_case__       :   Optional[int]	      =    self.scheduler_classes[0]
                 snake_case__       :   Any	      =    self.get_scheduler_config()
                 snake_case__       :   str	      =    scheduler_class(**__lowerCAmelCase			)

                 scheduler.step_plms(self.dummy_sample     ,							1     ,							self.dummy_sample			).prev_sample





     def 			_lowerCAmelCase      (     self     :					int			):
           snake_case__       :   int	      =    self.full_loop()
           snake_case__       :   Tuple	      =    torch.sum(torch.abs(__lowerCAmelCase			)			)
           snake_case__       :   Union[str, Any]	      =    torch.mean(torch.abs(__lowerCAmelCase			)			)

           assert abs(result_sum.item() - 1_9_8.1_3_1_8			) < 1E-2
           assert abs(result_mean.item() - 0.2_5_8_0			) < 1E-3





     def 			_lowerCAmelCase      (     self     :					Optional[int]			):
           snake_case__       :   Any	      =    self.full_loop(prediction_type='v_prediction'			)
           snake_case__       :   int	      =    torch.sum(torch.abs(__lowerCAmelCase			)			)
           snake_case__       :   Dict	      =    torch.mean(torch.abs(__lowerCAmelCase			)			)

           assert abs(result_sum.item() - 6_7.3_9_8_6			) < 1E-2
           assert abs(result_mean.item() - 0.0_8_7_8			) < 1E-3





     def 			_lowerCAmelCase      (     self     :					Optional[int]			):
           # We specify different beta, so that the first alpha is 0.99
           snake_case__       :   Any	      =    self.full_loop(set_alpha_to_one=__lowerCAmelCase     ,							beta_start=0.0_1			)
           snake_case__       :   Tuple	      =    torch.sum(torch.abs(__lowerCAmelCase			)			)
           snake_case__       :   Optional[Any]	      =    torch.mean(torch.abs(__lowerCAmelCase			)			)

           assert abs(result_sum.item() - 2_3_0.0_3_9_9			) < 1E-2
           assert abs(result_mean.item() - 0.2_9_9_5			) < 1E-3





     def 			_lowerCAmelCase      (     self     :					Optional[Any]			):
           # We specify different beta, so that the first alpha is 0.99
           snake_case__       :   Union[str, Any]	      =    self.full_loop(set_alpha_to_one=__lowerCAmelCase     ,							beta_start=0.0_1			)
           snake_case__       :   Any	      =    torch.sum(torch.abs(__lowerCAmelCase			)			)
           snake_case__       :   List[str]	      =    torch.mean(torch.abs(__lowerCAmelCase			)			)

           assert abs(result_sum.item() - 1_8_6.9_4_8_2			) < 1E-2
           assert abs(result_mean.item() - 0.2_4_3_4			) < 1E-3






'''simple docstring'''


from collections import defaultdict
def 						lowerCamelCase__   (				a    ,	a							):
						__snake_case						 =   first_str.lower().strip()
						__snake_case						 =   second_str.lower().strip()

						# Remove whitespace
						__snake_case						 =   first_str.replace(' '    ,	''							)
						__snake_case						 =   second_str.replace(' '    ,	''							)

						# Strings of different lengths are not anagrams
						if len(a							) != len(a							):
												return False

						# Default values for count should be 0
						__snake_case						 =   defaultdict(a							)

						# For each character in input strings,
						# increment count in the corresponding
						for i in range(len(a							)							):
												count[first_str[i]] += 1
												count[second_str[i]] -= 1

						return all(_count == 0 for _count in count.values()							)


if __name__ == "__main__":
	from doctest import testmod

	testmod()
	_lowercase  =			input("""Enter the first string """).strip()
	_lowercase  =			input("""Enter the second string """).strip()

	_lowercase  =			check_anagrams(input_a, input_b)
	print(f'''{input_a} and {input_b} are {'' if status else 'not '}anagrams.''')

