

'''simple docstring'''




def 		UpperCamelCase			(					a						,		a					) ->      Any:






     '''simple docstring'''
     __magic_name__		  =							''''''
     for i in table:
          res += inp[i - 1]
     return res




def 		UpperCamelCase			(					a					) ->      List[str]:






     '''simple docstring'''
     return data[1:] + data[0]




def 		UpperCamelCase			(					a						,		a					) ->      Union[str, Any]:






     '''simple docstring'''
     __magic_name__		  =							''''''
     for i in range(len(_a					)					):
          if a[i] == b[i]:
               res += "0"
          else:
               res += "1"
     return res




def 		UpperCamelCase			(					a						,		a					) ->      Optional[int]:






     '''simple docstring'''
     __magic_name__		  =							int('''0b''' + data[0] + data[-1]						,		2					)
     __magic_name__		  =							int('''0b''' + data[1:3]						,		2					)
     return bin(s[row][col]					)[2:]




def 		UpperCamelCase			(					a						,		a						,		a						,		a						,		a					) ->      int:






     '''simple docstring'''
     __magic_name__		  =							message[:4]
     __magic_name__		  =							message[4:]
     __magic_name__		  =							apply_table(_a						,		_a					)
     __magic_name__		  =							xor(_a						,		_a					)
     __magic_name__		  =							apply_sbox(_a						,		temp[:4]					)  # noqa: E741
     __magic_name__		  =							apply_sbox(_a						,		temp[4:]					)
     __magic_name__		  =							'''0''' * (2 - len(_a					)) + l  # noqa: E741
     __magic_name__		  =							'''0''' * (2 - len(_a					)) + r
     __magic_name__		  =							apply_table(l + r						,		_a					)
     __magic_name__		  =							xor(_a						,		_a					)
     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 functools
import gc
import inspect

import torch

from .imports import is_npu_available, is_xpu_available



def   _A					(	*_a	:						int				):



      """simple docstring"""






      if not isinstance(_a     ,   _a				):
            A				  =		list(_a				)
      for i in range(len(_a				)				):
            A				  =		None
      gc.collect()
      if is_xpu_available():
            torch.xpu.empty_cache()
      elif is_npu_available():
            torch.npu.empty_cache()
      else:
            torch.cuda.empty_cache()
      return objects



def   _A					(	_a	:						Exception				):



      """simple docstring"""






      A				  =		[
          """CUDA out of memory.""",  # CUDA OOM
          """cuDNN error: CUDNN_STATUS_NOT_SUPPORTED.""",  # CUDNN SNAFU
          """DefaultCPUAllocator: can't allocate memory""",  # CPU OOM
      ]
      if isinstance(_a     ,   _a				) and len(exception.args				) == 1:
            return any(err in exception.args[0] for err in _statements				)
      return False





def   _A					(	_a	:						callable = None     ,   _a	:						int = 1_2_8				):



      """simple docstring"""






      if function is None:
            return functools.partial(_a     ,   starting_batch_size=_a				)

      A				  =		starting_batch_size

      def decorator(*_a	:						Union[str, Any]     ,   **_a	:						List[Any]				):
            nonlocal batch_size
            gc.collect()
            if is_xpu_available():
                  torch.xpu.empty_cache()
            elif is_npu_available():
                  torch.npu.empty_cache()
            else:
                  torch.cuda.empty_cache()
            A				  =		list(inspect.signature(_a				).parameters.keys()				)
            # Guard against user error
            if len(_a				) < (len(_a				) + 1):
                  A				  =		""", """.join([f'{arg}={value}' for arg, value in zip(params[1:]     ,   args[1:]				)]				)
                  raise TypeError(
                      f'Batch size was passed into `{function.__name__}` as the first argument when called.'
                      f'Remove this as the decorator already does so: `{function.__name__}({arg_str})`'				)
            while True:
                  if batch_size == 0:
                        raise RuntimeError("""No executable batch size found, reached zero."""				)
                  try:
                        return function(_a     ,   *_a     ,   **_a				)
                  except Exception as e:
                        if should_reduce_batch_size(_a				):
                              gc.collect()
                              if is_xpu_available():
                                    torch.xpu.empty_cache()
                              elif is_npu_available():
                                    torch.npu.empty_cache()
                              else:
                                    torch.cuda.empty_cache()
                              batch_size //= 2
                        else:
                              raise

      return decorator




