

def 		SCREAMING_SNAKE_CASE__				(							_UpperCAmelCase,      _UpperCAmelCase				)					-> str:



				'''simple docstring'''






				if not isinstance(_UpperCAmelCase,      _UpperCAmelCase				):
								raise TypeError('plaintext must be a string'				)
				if not isinstance(_UpperCAmelCase,      _UpperCAmelCase				):
								raise TypeError('key must be a string'				)

				if not plaintext:
								raise ValueError('plaintext is empty'				)
				if not key:
								raise ValueError('key is empty'				)

				key += plaintext
				lowerCAmelCase				:			List[str]    			=      plaintext.lower()
				lowerCAmelCase				:			Tuple    			=      key.lower()
				lowerCAmelCase				:			Optional[Any]    			=      0
				lowerCAmelCase				:			List[Any]    			=      0
				lowerCAmelCase				:			List[Any]    			=      ''
				while plaintext_iterator < len(_UpperCAmelCase				):
								if (
								    ord(plaintext[plaintext_iterator]				) < 97
								    or ord(plaintext[plaintext_iterator]				) > 122
								):
												ciphertext += plaintext[plaintext_iterator]
												plaintext_iterator += 1
								elif ord(key[key_iterator]				) < 97 or ord(key[key_iterator]				) > 122:
												key_iterator += 1
								else:
												ciphertext += chr(
												    (
												        (ord(plaintext[plaintext_iterator]				) - 97 + ord(key[key_iterator]				))
												        - 97
												    )
												    % 26
												    + 97				)
												key_iterator += 1
												plaintext_iterator += 1
				return ciphertext
def 		SCREAMING_SNAKE_CASE__				(							_UpperCAmelCase,      _UpperCAmelCase				)					-> str:



				'''simple docstring'''






				if not isinstance(_UpperCAmelCase,      _UpperCAmelCase				):
								raise TypeError('ciphertext must be a string'				)
				if not isinstance(_UpperCAmelCase,      _UpperCAmelCase				):
								raise TypeError('key must be a string'				)

				if not ciphertext:
								raise ValueError('ciphertext is empty'				)
				if not key:
								raise ValueError('key is empty'				)

				lowerCAmelCase				:			List[Any]    			=      key.lower()
				lowerCAmelCase				:			Any    			=      0
				lowerCAmelCase				:			Optional[Any]    			=      0
				lowerCAmelCase				:			Tuple    			=      ''
				while ciphertext_iterator < len(_UpperCAmelCase				):
								if (
								    ord(ciphertext[ciphertext_iterator]				) < 97
								    or ord(ciphertext[ciphertext_iterator]				) > 122
								):
												plaintext += ciphertext[ciphertext_iterator]
								else:
												plaintext += chr(
												    (ord(ciphertext[ciphertext_iterator]				) - ord(key[key_iterator]				)) % 26
												    + 97				)
												key += chr(
												    (ord(ciphertext[ciphertext_iterator]				) - ord(key[key_iterator]				)) % 26
												    + 97				)
												key_iterator += 1
								ciphertext_iterator += 1
				return plaintext


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	__A   :     Any      =			int(input('''Type 1 to encrypt or 2 to decrypt:'''))
	if operation == 1:
		__A   :     Tuple      =			input('''Typeplaintext to be encrypted:\n''')
		__A   :     str      =			input('''Type the key:\n''')
		print(encrypt(plaintext, key))
	elif operation == 2:
		__A   :     List[str]      =			input('''Type the ciphertext to be decrypted:\n''')
		__A   :     List[str]      =			input('''Type the key:\n''')
		print(decrypt(ciphertext, key))
	decrypt('''jsqqs avvwo''', '''coffee''')








import torch

from diffusers import KDPMaAncestralDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest






class    __A				(							lowerCAmelCase ):
    lowerCAmelCase_							:		List[str]						=							(KDPMaAncestralDiscreteScheduler,)
    lowerCAmelCase_							:		Dict						=							10






    def 	lowercase__ (	self			:    Any    ,				**UpperCAmelCase_			:    List[Any]    ):
        lowerCAmelCase				:			int    			=      {
            'num_train_timesteps': 1100,
            'beta_start': 0.00_01,
            'beta_end': 0.02,
            'beta_schedule': 'linear',
        }

        config.update(**UpperCAmelCase_    )
        return config






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






    def 	lowercase__ (	self			:    List[str]    ):
        for beta_start, beta_end in zip([0.0_00_01, 0.00_01, 0.0_01]    ,				[0.00_02, 0.0_02, 0.02]    ):
            self.check_over_configs(beta_start=UpperCAmelCase_    ,				beta_end=UpperCAmelCase_    )






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






    def 	lowercase__ (	self			:    int    ):
        if torch_device == "mps":
            return
        lowerCAmelCase				:			Any    			=      self.scheduler_classes[0]
        lowerCAmelCase				:			Optional[int]    			=      self.get_scheduler_config()
        lowerCAmelCase				:			List[str]    			=      scheduler_class(**UpperCAmelCase_    )

        scheduler.set_timesteps(self.num_inference_steps    )

        lowerCAmelCase				:			Any    			=      torch.manual_seed(0    )

        lowerCAmelCase				:			List[Any]    			=      self.dummy_model()
        lowerCAmelCase				:			List[Any]    			=      self.dummy_sample_deter * scheduler.init_noise_sigma
        lowerCAmelCase				:			Optional[int]    			=      sample.to(UpperCAmelCase_    )

        for i, t in enumerate(scheduler.timesteps    ):
            lowerCAmelCase				:			str    			=      scheduler.scale_model_input(UpperCAmelCase_    ,				UpperCAmelCase_    )

            lowerCAmelCase				:			Any    			=      model(UpperCAmelCase_    ,				UpperCAmelCase_    )

            lowerCAmelCase				:			Optional[Any]    			=      scheduler.step(UpperCAmelCase_    ,				UpperCAmelCase_    ,				UpperCAmelCase_    ,				generator=UpperCAmelCase_    )
            lowerCAmelCase				:			Union[str, Any]    			=      output.prev_sample

        lowerCAmelCase				:			List[Any]    			=      torch.sum(torch.abs(UpperCAmelCase_    )    )
        lowerCAmelCase				:			Any    			=      torch.mean(torch.abs(UpperCAmelCase_    )    )

        assert abs(result_sum.item() - 1_38_49.38_77    ) < 1E-2
        assert abs(result_mean.item() - 18.03_31    ) < 5E-3






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






    def 	lowercase__ (	self			:    List[str]    ):
        if torch_device == "mps":
            return
        lowerCAmelCase				:			Optional[Any]    			=      self.scheduler_classes[0]
        lowerCAmelCase				:			List[Any]    			=      self.get_scheduler_config(prediction_type='v_prediction'    )
        lowerCAmelCase				:			Any    			=      scheduler_class(**UpperCAmelCase_    )

        scheduler.set_timesteps(self.num_inference_steps    )

        lowerCAmelCase				:			Optional[int]    			=      self.dummy_model()
        lowerCAmelCase				:			Any    			=      self.dummy_sample_deter * scheduler.init_noise_sigma
        lowerCAmelCase				:			Optional[int]    			=      sample.to(UpperCAmelCase_    )

        lowerCAmelCase				:			Optional[int]    			=      torch.manual_seed(0    )

        for i, t in enumerate(scheduler.timesteps    ):
            lowerCAmelCase				:			Dict    			=      scheduler.scale_model_input(UpperCAmelCase_    ,				UpperCAmelCase_    )

            lowerCAmelCase				:			Optional[int]    			=      model(UpperCAmelCase_    ,				UpperCAmelCase_    )

            lowerCAmelCase				:			Optional[int]    			=      scheduler.step(UpperCAmelCase_    ,				UpperCAmelCase_    ,				UpperCAmelCase_    ,				generator=UpperCAmelCase_    )
            lowerCAmelCase				:			str    			=      output.prev_sample

        lowerCAmelCase				:			str    			=      torch.sum(torch.abs(UpperCAmelCase_    )    )
        lowerCAmelCase				:			Tuple    			=      torch.mean(torch.abs(UpperCAmelCase_    )    )

        assert abs(result_sum.item() - 3_28.99_70    ) < 1E-2
        assert abs(result_mean.item() - 0.42_84    ) < 1E-3






    def 	lowercase__ (	self			:    Tuple    ):
        if torch_device == "mps":
            return
        lowerCAmelCase				:			str    			=      self.scheduler_classes[0]
        lowerCAmelCase				:			Dict    			=      self.get_scheduler_config()
        lowerCAmelCase				:			List[str]    			=      scheduler_class(**UpperCAmelCase_    )

        scheduler.set_timesteps(self.num_inference_steps    ,				device=UpperCAmelCase_    )
        lowerCAmelCase				:			int    			=      torch.manual_seed(0    )

        lowerCAmelCase				:			Tuple    			=      self.dummy_model()
        lowerCAmelCase				:			Optional[Any]    			=      self.dummy_sample_deter.to(UpperCAmelCase_    ) * scheduler.init_noise_sigma

        for t in scheduler.timesteps:
            lowerCAmelCase				:			str    			=      scheduler.scale_model_input(UpperCAmelCase_    ,				UpperCAmelCase_    )

            lowerCAmelCase				:			List[Any]    			=      model(UpperCAmelCase_    ,				UpperCAmelCase_    )

            lowerCAmelCase				:			Dict    			=      scheduler.step(UpperCAmelCase_    ,				UpperCAmelCase_    ,				UpperCAmelCase_    ,				generator=UpperCAmelCase_    )
            lowerCAmelCase				:			Dict    			=      output.prev_sample

        lowerCAmelCase				:			Union[str, Any]    			=      torch.sum(torch.abs(UpperCAmelCase_    )    )
        lowerCAmelCase				:			str    			=      torch.mean(torch.abs(UpperCAmelCase_    )    )

        assert abs(result_sum.item() - 1_38_49.38_18    ) < 1E-1
        assert abs(result_mean.item() - 18.03_31    ) < 1E-3





