




'''simple docstring'''





def 						lowerCAmelCase		(		_lowerCAmelCase							:   List[str]						,							_lowerCAmelCase							:   Any	):




 """simple docstring"""







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



def 						lowerCAmelCase		(		_lowerCAmelCase							:   Dict	):




 """simple docstring"""







 return data[1:] + data[0]



def 						lowerCAmelCase		(		_lowerCAmelCase							:   str						,							_lowerCAmelCase							:   Any	):




 """simple docstring"""







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



def 						lowerCAmelCase		(		_lowerCAmelCase							:   List[str]						,							_lowerCAmelCase							:   Union[str, Any]	):




 """simple docstring"""







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



def 						lowerCAmelCase		(		_lowerCAmelCase							:   Optional[int]						,							_lowerCAmelCase							:   int						,							_lowerCAmelCase							:   Any						,							_lowerCAmelCase							:   Union[str, Any]						,							_lowerCAmelCase							:   Dict	):




 """simple docstring"""







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


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

  _lowerCAmelCase						:   Any		=   [6, 3, 7, 4, 8, 5, 1_0, 9]
  _lowerCAmelCase						:   List[str]		=   [3, 5, 2, 7, 4, 1_0, 1, 9, 8, 6]
  _lowerCAmelCase						:   List[Any]		=   [2, 4, 3, 1]
  _lowerCAmelCase						:   Optional[int]		=   [2, 6, 3, 1, 4, 8, 5, 7]
  _lowerCAmelCase						:   int		=   [4, 1, 3, 5, 7, 2, 8, 6]
  _lowerCAmelCase						:   Dict		=   [4, 1, 2, 3, 2, 3, 4, 1]
  _lowerCAmelCase						:   Tuple		=   [[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
  _lowerCAmelCase						:   Tuple		=   [[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

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

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

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











import json
from typing import TYPE_CHECKING, List, Optional, Tuple

from tokenizers import pre_tokenizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if TYPE_CHECKING:
  from transformers.pipelines.conversational import Conversation


_lowerCAmelCase						:   str		=   logging.get_logger(__name__)

_lowerCAmelCase						:   List[Any]		=   {"tokenizer_file": "tokenizer.json"}

_lowerCAmelCase						:   Tuple		=   {
    "tokenizer_file": {
        "bigscience/tokenizer": "https://huggingface.co/bigscience/tokenizer/blob/main/tokenizer.json",
        "bigscience/bloom-560m": "https://huggingface.co/bigscience/bloom-560m/blob/main/tokenizer.json",
        "bigscience/bloom-1b1": "https://huggingface.co/bigscience/bloom-1b1/blob/main/tokenizer.json",
        "bigscience/bloom-1b7": "https://huggingface.co/bigscience/bloom-1b7/blob/main/tokenizer.json",
        "bigscience/bloom-3b": "https://huggingface.co/bigscience/bloom-3b/blob/main/tokenizer.json",
        "bigscience/bloom-7b1": "https://huggingface.co/bigscience/bloom-7b1/blob/main/tokenizer.json",
        "bigscience/bloom": "https://huggingface.co/bigscience/bloom/blob/main/tokenizer.json",
    },
}
class 			_UpperCamelCase      (				lowerCAmelCase		):
      UpperCAmelCase_        =		VOCAB_FILES_NAMES
      UpperCAmelCase_        =		PRETRAINED_VOCAB_FILES_MAP
      UpperCAmelCase_        =		["""input_ids""", """attention_mask"""]
      UpperCAmelCase_        =		None
      def __init__(			self   :List[Any] ,      lowerCamelCase   :Union[str, Any]=None ,      lowerCamelCase   :Optional[Any]=None ,      lowerCamelCase   :List[Any]=None ,      lowerCamelCase   :Union[str, Any]="<unk>" ,      lowerCamelCase   :Union[str, Any]="<s>" ,      lowerCamelCase   :Union[str, Any]="</s>" ,      lowerCamelCase   :str="<pad>" ,      lowerCamelCase   :Any=False ,      lowerCamelCase   :Optional[Any]=False ,      **lowerCamelCase   :Optional[Any] ,      )     ->			Any:
       super().__init__(
           lowerCamelCase ,      lowerCamelCase ,      tokenizer_file=lowerCamelCase ,      unk_token=lowerCamelCase ,      bos_token=lowerCamelCase ,      eos_token=lowerCamelCase ,      pad_token=lowerCamelCase ,      add_prefix_space=lowerCamelCase ,      clean_up_tokenization_spaces=lowerCamelCase ,      **lowerCamelCase ,      )
       UpperCAmelCase__							 =						json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()      )
       if pre_tok_state.get("add_prefix_space" ,      lowerCamelCase      ) != add_prefix_space:
        UpperCAmelCase__							 =						getattr(lowerCamelCase ,      pre_tok_state.pop("type"      )      )
        UpperCAmelCase__							 =						add_prefix_space
        UpperCAmelCase__							 =						pre_tok_class(**lowerCamelCase      )

       UpperCAmelCase__							 =						add_prefix_space
      def 	UpperCAmelCase_						(			self   :int ,      *lowerCamelCase   :Any ,      **lowerCamelCase   :int      )     ->			BatchEncoding:
       UpperCAmelCase__							 =						kwargs.get("is_split_into_words" ,      lowerCamelCase      )
       if not (self.add_prefix_space or not is_split_into_words):
        raise Exception(
            f'''You need to instantiate {self.__class__.__name__} with add_prefix_space=True to use it with'''
            " pretokenized inputs."      )

       return super()._batch_encode_plus(*lowerCamelCase ,      **lowerCamelCase      )
      def 	UpperCAmelCase_						(			self   :Any ,      *lowerCamelCase   :List[Any] ,      **lowerCamelCase   :Union[str, Any]      )     ->			BatchEncoding:
       UpperCAmelCase__							 =						kwargs.get("is_split_into_words" ,      lowerCamelCase      )

       if not (self.add_prefix_space or not is_split_into_words):
        raise Exception(
            f'''You need to instantiate {self.__class__.__name__} with add_prefix_space=True to use it with'''
            " pretokenized inputs."      )

       return super()._encode_plus(*lowerCamelCase ,      **lowerCamelCase      )
      def 	UpperCAmelCase_						(			self   :Tuple ,      lowerCamelCase   :str ,      lowerCamelCase   :Optional[str] = None      )     ->			Tuple[str]:
       UpperCAmelCase__							 =						self._tokenizer.model.save(lowerCamelCase ,      name=lowerCamelCase      )
       return tuple(lowerCamelCase      )







      def 	UpperCAmelCase_						(			self   :List[str] ,      lowerCamelCase   :"Conversation"      )     ->			List[int]:
       UpperCAmelCase__							 =						[]
       for is_user, text in conversation.iter_texts():
        input_ids.extend(self.encode(lowerCamelCase ,      add_special_tokens=lowerCamelCase      ) + [self.eos_token_id]      )

       if len(lowerCamelCase      ) > self.model_max_length:
        UpperCAmelCase__							 =						input_ids[-self.model_max_length :]
       return input_ids





