





'''simple docstring'''







import math





def        lowerCamelCase_      (  ) ->	None:
						UpperCAmelCase_			:      Union[str, Any]     						=  input('''Enter message: '''   )
						UpperCAmelCase_			:      List[str]     						=  int(input(F"""Enter key [2-{len(SCREAMING_SNAKE_CASE__   ) - 1}]: """   )   )
						UpperCAmelCase_			:      Any     						=  input('''Encryption/Decryption [e/d]: '''   )

						if mode.lower().startswith('''e'''   ):
												UpperCAmelCase_			:      Optional[int]     						=  encrypt_message(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   )
						elif mode.lower().startswith('''d'''   ):
												UpperCAmelCase_			:      int     						=  decrypt_message(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   )

						# Append pipe symbol (vertical bar) to identify spaces at the end.
						print(F"""Output:\n{text + "|"}"""   )





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			int,			SCREAMING_SNAKE_CASE__      :			str   ) ->	str:
						UpperCAmelCase_			:      Optional[int]     						=  [''''''] * key
						for col in range(SCREAMING_SNAKE_CASE__   ):
												UpperCAmelCase_			:      Optional[Any]     						=  col
												while pointer < len(SCREAMING_SNAKE_CASE__   ):
																		cipher_text[col] += message[pointer]
																		pointer += key
						return "".join(SCREAMING_SNAKE_CASE__   )





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			int,			SCREAMING_SNAKE_CASE__      :			str   ) ->	str:
						UpperCAmelCase_			:      Union[str, Any]     						=  math.ceil(len(SCREAMING_SNAKE_CASE__   ) / key   )
						UpperCAmelCase_			:      int     						=  key
						UpperCAmelCase_			:      Optional[int]     						=  (num_cols * num_rows) - len(SCREAMING_SNAKE_CASE__   )
						UpperCAmelCase_			:      Any     						=  [''''''] * num_cols
						UpperCAmelCase_			:      str     						=  0
						UpperCAmelCase_			:      Optional[int]     						=  0

						for symbol in message:
												plain_text[col] += symbol
												col += 1

												if (
												    (col == num_cols)
												    or (col == num_cols - 1)
												    and (row >= num_rows - num_shaded_boxes)
												):
																		UpperCAmelCase_			:      Any     						=  0
																		row += 1

						return "".join(SCREAMING_SNAKE_CASE__   )


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					main()












'''simple docstring'''







import unittest

import numpy as np
import torch

from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()


class 					__a      (unittest.TestCase     ):

							@property
							def     UpperCAmelCase__	(							self							:     Dict   )					->       str:







													"""simple docstring"""
													torch.manual_seed(0   )
													UpperCAmelCase_			:      Optional[Any]     						=  UNetaDModel(
													    block_out_channels=(32, 64)       ,     layers_per_block=2       ,     sample_size=32       ,     in_channels=3       ,     out_channels=3       ,     down_block_types=('''DownBlock2D''', '''AttnDownBlock2D''')       ,     up_block_types=('''AttnUpBlock2D''', '''UpBlock2D''')       ,     )
													return model



							def     UpperCAmelCase__	(							self							:     Dict   )					->       Tuple:







													"""simple docstring"""
													UpperCAmelCase_			:      List[Any]     						=  self.dummy_uncond_unet
													UpperCAmelCase_			:      Dict     						=  KarrasVeScheduler()

													UpperCAmelCase_			:      Union[str, Any]     						=  KarrasVePipeline(unet=__magic_name__       ,     scheduler=__magic_name__   )
													pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      Dict     						=  torch.manual_seed(0   )
													UpperCAmelCase_			:      Optional[int]     						=  pipe(num_inference_steps=2       ,     generator=__magic_name__       ,     output_type='''numpy'''   ).images

													UpperCAmelCase_			:      Tuple     						=  torch.manual_seed(0   )
													UpperCAmelCase_			:      str     						=  pipe(num_inference_steps=2       ,     generator=__magic_name__       ,     output_type='''numpy'''       ,     return_dict=__magic_name__   )[0]

													UpperCAmelCase_			:      Union[str, Any]     						=  image[0, -3:, -3:, -1]
													UpperCAmelCase_			:      Optional[Any]     						=  image_from_tuple[0, -3:, -3:, -1]

													assert image.shape == (1, 32, 32, 3)
													UpperCAmelCase_			:      Dict     						=  np.array([0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-2
													assert np.abs(image_from_tuple_slice.flatten() - expected_slice   ).max() < 1E-2





@slow
@require_torch
class 					__a      (unittest.TestCase     ):

							def     UpperCAmelCase__	(							self							:     int   )					->       Union[str, Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[str]     						=  '''google/ncsnpp-celebahq-256'''
													UpperCAmelCase_			:      List[str]     						=  UNetaDModel.from_pretrained(__magic_name__   )
													UpperCAmelCase_			:      List[Any]     						=  KarrasVeScheduler()

													UpperCAmelCase_			:      Any     						=  KarrasVePipeline(unet=__magic_name__       ,     scheduler=__magic_name__   )
													pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      Dict     						=  torch.manual_seed(0   )
													UpperCAmelCase_			:      Optional[Any]     						=  pipe(num_inference_steps=20       ,     generator=__magic_name__       ,     output_type='''numpy'''   ).images

													UpperCAmelCase_			:      Any     						=  image[0, -3:, -3:, -1]
													assert image.shape == (1, 2_56, 2_56, 3)
													UpperCAmelCase_			:      Optional[Any]     						=  np.array([0.5_7_8, 0.5_8_1_1, 0.5_9_2_4, 0.5_8_0_9, 0.5_8_7, 0.5_8_8_6, 0.5_8_6_1, 0.5_8_0_2, 0.5_8_6]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-2





