

'''simple docstring'''







def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      Union[str, Any]:
       A_						       =   """"""
       for i in table:
              res += inp[i - 1]
       return res
def    UpperCAmelCase__     (   UpperCAmelCase__					)      ->      int:
       return data[1:] + data[0]
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      Any:
       A_						       =   """"""
       for i in range(len(UpperCAmelCase__					)					):
              if a[i] == b[i]:
                     res += "0"
              else:
                     res += "1"
       return res
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      int:
       A_						       =   int("""0b""" + data[0] + data[-1],							2					)
       A_						       =   int("""0b""" + data[1:3],							2					)
       return bin(s[row][col]					)[2:]
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__					)      ->      Union[str, Any]:
       A_						       =   message[:4]
       A_						       =   message[4:]
       A_						       =   apply_table(UpperCAmelCase__,							UpperCAmelCase__					)
       A_						       =   xor(UpperCAmelCase__,							UpperCAmelCase__					)
       A_						       =   apply_sbox(UpperCAmelCase__,							temp[:4]					)  # noqa: E741
       A_						       =   apply_sbox(UpperCAmelCase__,							temp[4:]					)
       A_						       =   """0""" * (2 - len(UpperCAmelCase__					)) + l  # noqa: E741
       A_						       =   """0""" * (2 - len(UpperCAmelCase__					)) + r
       A_						       =   apply_table(l + r,							UpperCAmelCase__					)
       A_						       =   xor(UpperCAmelCase__,							UpperCAmelCase__					)
       return temp + right


if __name__ == "__main__":
      __lowerCamelCase									=     input('''Enter 10 bit key: ''')
      __lowerCamelCase									=     input('''Enter 8 bit message: ''')

      __lowerCamelCase									=     [6, 3, 7, 4, 8, 5, 10, 9]
      __lowerCamelCase									=     [3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
      __lowerCamelCase									=     [2, 4, 3, 1]
      __lowerCamelCase									=     [2, 6, 3, 1, 4, 8, 5, 7]
      __lowerCamelCase									=     [4, 1, 3, 5, 7, 2, 8, 6]
      __lowerCamelCase									=     [4, 1, 2, 3, 2, 3, 4, 1]
      __lowerCamelCase									=     [[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
      __lowerCamelCase									=     [[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

      # key generation
      __lowerCamelCase									=     apply_table(key, paa_table)
      __lowerCamelCase									=     temp[:5]
      __lowerCamelCase									=     temp[5:]
      __lowerCamelCase									=     left_shift(left)
      __lowerCamelCase									=     left_shift(right)
      __lowerCamelCase									=     apply_table(left + right, pa_table)
      __lowerCamelCase									=     left_shift(left)
      __lowerCamelCase									=     left_shift(right)
      __lowerCamelCase									=     left_shift(left)
      __lowerCamelCase									=     left_shift(right)
      __lowerCamelCase									=     apply_table(left + right, pa_table)

      # encryption
      __lowerCamelCase									=     apply_table(message, IP)
      __lowerCamelCase									=     function(expansion, sa, sa, keya, temp)
      __lowerCamelCase									=     temp[4:] + temp[:4]
      __lowerCamelCase									=     function(expansion, sa, sa, keya, temp)
      __lowerCamelCase									=     apply_table(temp, IP_inv)
      print('''Cipher text is:''', CT)

      # decryption
      __lowerCamelCase									=     apply_table(CT, IP)
      __lowerCamelCase									=     function(expansion, sa, sa, keya, temp)
      __lowerCamelCase									=     temp[4:] + temp[:4]
      __lowerCamelCase									=     function(expansion, sa, sa, keya, temp)
      __lowerCamelCase									=     apply_table(temp, IP_inv)
      print('''Plain text after decypting is:''', PT)



'''simple docstring'''







import unittest

import numpy as np
import torch

from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()


class        A__   (   unittest.TestCase      ):



    @property
    def        snake_case_      (       self							)    ->   int:





           '''simple docstring'''
           torch.manual_seed(0							)
           A_						       =   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        snake_case_      (       self							)    ->   str:





           '''simple docstring'''
           A_						       =   self.dummy_uncond_unet
           A_						       =   PNDMScheduler()

           A_						       =   PNDMPipeline(unet=UpperCamelCase__		,					scheduler=UpperCamelCase__							)
           pndm.to(UpperCamelCase__							)
           pndm.set_progress_bar_config(disable=UpperCamelCase__							)

           A_						       =   torch.manual_seed(0							)
           A_						       =   pndm(generator=UpperCamelCase__		,					num_inference_steps=20		,					output_type="""numpy"""							).images

           A_						       =   torch.manual_seed(0							)
           A_						       =   pndm(generator=UpperCamelCase__		,					num_inference_steps=20		,					output_type="""numpy"""		,					return_dict=UpperCamelCase__							)[0]

           A_						       =   image[0, -3:, -3:, -1]
           A_						       =   image_from_tuple[0, -3:, -3:, -1]

           assert image.shape == (1, 32, 32, 3)
           A_						       =   np.array([1.0, 1.0, 0.0, 1.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        snake_case_      (       self							)    ->   Tuple:





           '''simple docstring'''
           A_						       =   """google/ddpm-cifar10-32"""

           A_						       =   UNetaDModel.from_pretrained(UpperCamelCase__							)
           A_						       =   PNDMScheduler()

           A_						       =   PNDMPipeline(unet=UpperCamelCase__		,					scheduler=UpperCamelCase__							)
           pndm.to(UpperCamelCase__							)
           pndm.set_progress_bar_config(disable=UpperCamelCase__							)
           A_						       =   torch.manual_seed(0							)
           A_						       =   pndm(generator=UpperCamelCase__		,					output_type="""numpy"""							).images

           A_						       =   image[0, -3:, -3:, -1]

           assert image.shape == (1, 32, 32, 3)
           A_						       =   np.array([0.1564, 0.14645, 0.1406, 0.14715, 0.12425, 0.14045, 0.13115, 0.12175, 0.125]							)

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