



'''simple docstring'''





def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase							,   UpperCamelCase      ):



    """simple docstring"""





    lowerCAmelCase__			:  List[Any]											= """"""
    for i in table:
        res += inp[i - 1]
    return res
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase      ):



    """simple docstring"""





    return data[1:] + data[0]
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase							,   UpperCamelCase      ):



    """simple docstring"""





    lowerCAmelCase__			:  Optional[Any]											= """"""
    for i in range(len(UpperCamelCase      )      ):
        if a[i] == b[i]:
            res += "0"
        else:
            res += "1"
    return res
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase							,   UpperCamelCase      ):



    """simple docstring"""





    lowerCAmelCase__			:  Dict											= int("""0b""" + data[0] + data[-1]							,   2      )
    lowerCAmelCase__			:  Tuple											= int("""0b""" + data[1:3]							,   2      )
    return bin(s[row][col]      )[2:]
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase							,   UpperCamelCase							,   UpperCamelCase							,   UpperCamelCase							,   UpperCamelCase      ):



    """simple docstring"""





    lowerCAmelCase__			:  int											= message[:4]
    lowerCAmelCase__			:  int											= message[4:]
    lowerCAmelCase__			:  Tuple											= apply_table(UpperCamelCase							,   UpperCamelCase      )
    lowerCAmelCase__			:  List[str]											= xor(UpperCamelCase							,   UpperCamelCase      )
    lowerCAmelCase__			:  str											= apply_sbox(UpperCamelCase							,   temp[:4]      )  # noqa: E741
    lowerCAmelCase__			:  Optional[Any]											= apply_sbox(UpperCamelCase							,   temp[4:]      )
    lowerCAmelCase__			:  Union[str, Any]											= """0""" * (2 - len(UpperCamelCase      )) + l  # noqa: E741
    lowerCAmelCase__			:  List[str]											= """0""" * (2 - len(UpperCamelCase      )) + r
    lowerCAmelCase__			:  Optional[Any]											= apply_table(l + r							,   UpperCamelCase      )
    lowerCAmelCase__			:  Union[str, Any]											= 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 copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


_lowerCAmelCase										=     logging.get_logger(__name__)

_lowerCAmelCase										=     {
    '''Salesforce/instruct-blip-flan-t5''': '''https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json''',
}






class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_					):
  '''simple docstring'''




  __lowercase							:				Optional[Any]           =				'''instructblip_vision_model'''




  def __init__(   self  ,__UpperCAmelCase=1408  ,__UpperCAmelCase=6144  ,__UpperCAmelCase=39  ,__UpperCAmelCase=16  ,__UpperCAmelCase=224  ,__UpperCAmelCase=14  ,__UpperCAmelCase="gelu"  ,__UpperCAmelCase=1E-6  ,__UpperCAmelCase=0.0  ,__UpperCAmelCase=1E-10  ,__UpperCAmelCase=True  ,**__UpperCAmelCase  ,)   ->		List[Any]:
      super().__init__(**__UpperCAmelCase				)

      lowerCAmelCase__			:  Any											= hidden_size
      lowerCAmelCase__			:  List[str]											= intermediate_size
      lowerCAmelCase__			:  str											= num_hidden_layers
      lowerCAmelCase__			:  Tuple											= num_attention_heads
      lowerCAmelCase__			:  Union[str, Any]											= patch_size
      lowerCAmelCase__			:  int											= image_size
      lowerCAmelCase__			:  Tuple											= initializer_range
      lowerCAmelCase__			:  Optional[int]											= attention_dropout
      lowerCAmelCase__			:  List[str]											= layer_norm_eps
      lowerCAmelCase__			:  List[Any]											= hidden_act
      lowerCAmelCase__			:  int											= qkv_bias






  @classmethod
  def 							UpperCAmelCase_     (   cls  ,__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		"PretrainedConfig":
      cls._set_token_in_kwargs(__UpperCAmelCase				)

      lowerCAmelCase__				,       lowerCAmelCase__			:  Tuple											= cls.get_config_dict(__UpperCAmelCase  ,**__UpperCAmelCase				)

      # get the vision config dict if we are loading from InstructBlipConfig
      if config_dict.get("""model_type"""				) == "instructblip":
          lowerCAmelCase__			:  Optional[int]											= config_dict["""vision_config"""]

      if "model_type" in config_dict and hasattr(cls  ,"""model_type"""				) and config_dict["model_type"] != cls.model_type:
          logger.warning(
              F"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
              F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""				)

      return cls.from_dict(__UpperCAmelCase  ,**__UpperCAmelCase				)







class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_					):
  '''simple docstring'''




  __lowercase							:				int           =				'''instructblip_qformer'''




  def __init__(   self  ,__UpperCAmelCase=3_0522  ,__UpperCAmelCase=768  ,__UpperCAmelCase=12  ,__UpperCAmelCase=12  ,__UpperCAmelCase=3072  ,__UpperCAmelCase="gelu"  ,__UpperCAmelCase=0.1  ,__UpperCAmelCase=0.1  ,__UpperCAmelCase=512  ,__UpperCAmelCase=0.0_2  ,__UpperCAmelCase=1E-12  ,__UpperCAmelCase=0  ,__UpperCAmelCase="absolute"  ,__UpperCAmelCase=2  ,__UpperCAmelCase=1408  ,**__UpperCAmelCase  ,)   ->		Tuple:
      super().__init__(pad_token_id=__UpperCAmelCase  ,**__UpperCAmelCase				)

      lowerCAmelCase__			:  List[Any]											= vocab_size
      lowerCAmelCase__			:  Optional[Any]											= hidden_size
      lowerCAmelCase__			:  Any											= num_hidden_layers
      lowerCAmelCase__			:  int											= num_attention_heads
      lowerCAmelCase__			:  Tuple											= hidden_act
      lowerCAmelCase__			:  int											= intermediate_size
      lowerCAmelCase__			:  Tuple											= hidden_dropout_prob
      lowerCAmelCase__			:  Optional[Any]											= attention_probs_dropout_prob
      lowerCAmelCase__			:  Optional[Any]											= max_position_embeddings
      lowerCAmelCase__			:  Any											= initializer_range
      lowerCAmelCase__			:  Tuple											= layer_norm_eps
      lowerCAmelCase__			:  Dict											= position_embedding_type
      lowerCAmelCase__			:  int											= cross_attention_frequency
      lowerCAmelCase__			:  List[Any]											= encoder_hidden_size






  @classmethod
  def 							UpperCAmelCase_     (   cls  ,__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		"PretrainedConfig":
      cls._set_token_in_kwargs(__UpperCAmelCase				)

      lowerCAmelCase__				,       lowerCAmelCase__			:  Any											= cls.get_config_dict(__UpperCAmelCase  ,**__UpperCAmelCase				)

      # get the qformer config dict if we are loading from InstructBlipConfig
      if config_dict.get("""model_type"""				) == "instructblip":
          lowerCAmelCase__			:  Tuple											= config_dict["""qformer_config"""]

      if "model_type" in config_dict and hasattr(cls  ,"""model_type"""				) and config_dict["model_type"] != cls.model_type:
          logger.warning(
              F"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
              F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""				)

      return cls.from_dict(__UpperCAmelCase  ,**__UpperCAmelCase				)







class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_					):
  '''simple docstring'''




  __lowercase							:				Any           =				'''instructblip'''
  __lowercase							:				str           =				True




  def __init__(   self  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,__UpperCAmelCase=32  ,**__UpperCAmelCase				)   ->		Any:
      super().__init__(**__UpperCAmelCase				)

      if vision_config is None:
          lowerCAmelCase__			:  Any											= {}
          logger.info("""vision_config is None. initializing the InstructBlipVisionConfig with default values."""				)

      if qformer_config is None:
          lowerCAmelCase__			:  List[str]											= {}
          logger.info("""qformer_config is None. Initializing the InstructBlipQFormerConfig with default values."""				)

      if text_config is None:
          lowerCAmelCase__			:  List[Any]											= {}
          logger.info("""text_config is None. Initializing the text config with default values (`OPTConfig`)."""				)

      lowerCAmelCase__			:  Any											= InstructBlipVisionConfig(**__UpperCAmelCase				)
      lowerCAmelCase__			:  Tuple											= InstructBlipQFormerConfig(**__UpperCAmelCase				)
      lowerCAmelCase__			:  Tuple											= text_config["""model_type"""] if """model_type""" in text_config else """opt"""
      lowerCAmelCase__			:  Any											= CONFIG_MAPPING[text_model_type](**__UpperCAmelCase				)

      lowerCAmelCase__			:  Union[str, Any]											= self.text_config.tie_word_embeddings
      lowerCAmelCase__			:  Any											= self.text_config.is_encoder_decoder

      lowerCAmelCase__			:  int											= num_query_tokens
      lowerCAmelCase__			:  List[str]											= self.vision_config.hidden_size
      lowerCAmelCase__			:  Optional[int]											= self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
      lowerCAmelCase__			:  Optional[Any]											= 1.0
      lowerCAmelCase__			:  Dict											= 0.0_2




  @classmethod
  def 							UpperCAmelCase_     (   cls  ,__UpperCAmelCase  ,__UpperCAmelCase  ,__UpperCAmelCase  ,**__UpperCAmelCase  ,)   ->		Union[str, Any]:
      return cls(
          vision_config=vision_config.to_dict()  ,qformer_config=qformer_config.to_dict()  ,text_config=text_config.to_dict()  ,**__UpperCAmelCase  ,)






  def 							UpperCAmelCase_     (   self				)   ->		str:
      lowerCAmelCase__			:  List[Any]											= copy.deepcopy(self.__dict__				)
      lowerCAmelCase__			:  str											= self.vision_config.to_dict()
      lowerCAmelCase__			:  Union[str, Any]											= self.qformer_config.to_dict()
      lowerCAmelCase__			:  Union[str, Any]											= self.text_config.to_dict()
      lowerCAmelCase__			:  str											= self.__class__.model_type
      return output


