

"""simple docstring"""


def   _A					(	_a	:						str     ,   _a	:						List[Any]				):



      """simple docstring"""






      A				  =		""""""
      for i in table:
            res += inp[i - 1]
      return res



def   _A					(	_a	:						str				):



      """simple docstring"""






      return data[1:] + data[0]



def   _A					(	_a	:						List[str]     ,   _a	:						List[str]				):



      """simple docstring"""






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



def   _A					(	_a	:						str     ,   _a	:						Dict				):



      """simple docstring"""






      A				  =		int("""0b""" + data[0] + data[-1]     ,   2				)
      A				  =		int("""0b""" + data[1:3]     ,   2				)
      return bin(s[row][col]				)[2:]



def   _A					(	_a	:						Dict     ,   _a	:						Tuple     ,   _a	:						Optional[int]     ,   _a	:						Dict     ,   _a	:						Optional[Any]				):



      """simple docstring"""






      A				  =		message[:4]
      A				  =		message[4:]
      A				  =		apply_table(_a     ,   _a				)
      A				  =		xor(_a     ,   _a				)
      A				  =		apply_sbox(_a     ,   temp[:4]				)  # noqa: E741
      A				  =		apply_sbox(_a     ,   temp[4:]				)
      A				  =		"""0""" * (2 - len(_a				)) + l  # noqa: E741
      A				  =		"""0""" * (2 - len(_a				)) + r
      A				  =		apply_table(l + r     ,   _a				)
      A				  =		xor(_a     ,   _a				)
      return temp + right


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

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

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

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

  # decryption
  UpperCAmelCase													=apply_table(CT, IP)
  UpperCAmelCase													=function(expansion, sa, sa, keya, temp)
  UpperCAmelCase													=temp[4:] + temp[:4]
  UpperCAmelCase													=function(expansion, sa, sa, keya, temp)
  UpperCAmelCase													=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




