
'''simple docstring'''


def  __snake_case     (    _UpperCAmelCase					:       Optional[int],      _UpperCAmelCase					:       Tuple):
   UpperCamelCase       =  ''''''
   for i in table:
      res += inp[i - 1]
   return res



def  __snake_case     (    _UpperCAmelCase					:       List[Any]):
   return data[1:] + data[0]



def  __snake_case     (    _UpperCAmelCase					:       Optional[int],      _UpperCAmelCase					:       List[str]):
   UpperCamelCase       =  ''''''
   for i in range(len(_UpperCAmelCase)):
      if a[i] == b[i]:
         res += "0"
      else:
         res += "1"
   return res



def  __snake_case     (    _UpperCAmelCase					:       Union[str, Any],      _UpperCAmelCase					:       Tuple):
   UpperCamelCase       =  int('''0b''' + data[0] + data[-1],      2)
   UpperCamelCase       =  int('''0b''' + data[1:3],      2)
   return bin(s[row][col])[2:]



def  __snake_case     (    _UpperCAmelCase					:       Union[str, Any],      _UpperCAmelCase					:       Optional[Any],      _UpperCAmelCase					:       List[str],      _UpperCAmelCase					:       int,      _UpperCAmelCase					:       List[str]):
   UpperCamelCase       =  message[:4]
   UpperCamelCase       =  message[4:]
   UpperCamelCase       =  apply_table(_UpperCAmelCase,      _UpperCAmelCase)
   UpperCamelCase       =  xor(_UpperCAmelCase,      _UpperCAmelCase)
   UpperCamelCase       =  apply_sbox(_UpperCAmelCase,      temp[:4])  # noqa: E741
   UpperCamelCase       =  apply_sbox(_UpperCAmelCase,      temp[4:])
   UpperCamelCase       =  '''0''' * (2 - len(_UpperCAmelCase)) + l  # noqa: E741
   UpperCamelCase       =  '''0''' * (2 - len(_UpperCAmelCase)) + r
   UpperCamelCase       =  apply_table(l + r,      _UpperCAmelCase)
   UpperCamelCase       =  xor(_UpperCAmelCase,      _UpperCAmelCase)
   return temp + right


if __name__ == "__main__":
   snake_case_ :  Optional[int]     =					input('Enter 10 bit key: ')
   snake_case_ :  Union[str, Any]     =					input('Enter 8 bit message: ')

   snake_case_ :  Any     =					[6, 3, 7, 4, 8, 5, 10, 9]
   snake_case_ :  Tuple     =					[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
   snake_case_ :  Optional[Any]     =					[2, 4, 3, 1]
   snake_case_ :  Tuple     =					[2, 6, 3, 1, 4, 8, 5, 7]
   snake_case_ :  Optional[int]     =					[4, 1, 3, 5, 7, 2, 8, 6]
   snake_case_ :  Tuple     =					[4, 1, 2, 3, 2, 3, 4, 1]
   snake_case_ :  Optional[int]     =					[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
   snake_case_ :  Any     =					[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

   # key generation
   snake_case_ :  int     =					apply_table(key, paa_table)
   snake_case_ :  Any     =					temp[:5]
   snake_case_ :  Union[str, Any]     =					temp[5:]
   snake_case_ :  List[Any]     =					left_shift(left)
   snake_case_ :  Optional[int]     =					left_shift(right)
   snake_case_ :  Union[str, Any]     =					apply_table(left + right, pa_table)
   snake_case_ :  Union[str, Any]     =					left_shift(left)
   snake_case_ :  Union[str, Any]     =					left_shift(right)
   snake_case_ :  Any     =					left_shift(left)
   snake_case_ :  int     =					left_shift(right)
   snake_case_ :  Any     =					apply_table(left + right, pa_table)

   # encryption
   snake_case_ :  Dict     =					apply_table(message, IP)
   snake_case_ :  int     =					function(expansion, sa, sa, keya, temp)
   snake_case_ :  str     =					temp[4:] + temp[:4]
   snake_case_ :  Tuple     =					function(expansion, sa, sa, keya, temp)
   snake_case_ :  Optional[int]     =					apply_table(temp, IP_inv)
   print('Cipher text is:', CT)

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







'''simple docstring'''


import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp



def  __snake_case     (    ):
   UpperCamelCase       =  ArgumentParser(
       description=(
           '''PyTorch TPU distributed training launch '''
           '''helper utility that will spawn up '''
           '''multiple distributed processes'''
       ))

   # Optional arguments for the launch helper
   parser.add_argument('''--num_cores''',      type=_UpperCAmelCase,      default=1,      help='''Number of TPU cores to use (1 or 8).''')

   # positional
   parser.add_argument(
       '''training_script''',      type=_UpperCAmelCase,      help=(
           '''The full path to the single TPU training '''
           '''program/script to be launched in parallel, '''
           '''followed by all the arguments for the '''
           '''training script'''
       ),      )

   # rest from the training program
   parser.add_argument('''training_script_args''',      nargs=_UpperCAmelCase)

   return parser.parse_args()



def  __snake_case     (    ):
   UpperCamelCase       =  parse_args()

   # Import training_script as a module.
   UpperCamelCase       =  Path(args.training_script)
   sys.path.append(str(script_fpath.parent.resolve()))
   UpperCamelCase       =  script_fpath.stem
   UpperCamelCase       =  importlib.import_module(_UpperCAmelCase)

   # Patch sys.argv
   UpperCamelCase       =  [args.training_script] + args.training_script_args + ['''--tpu_num_cores''', str(args.num_cores)]
   xmp.spawn(mod._mp_fn,      args=(),      nprocs=args.num_cores)


if __name__ == "__main__":
   main()





