


def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			Optional[int]:







 """simple docstring"""


 _lowercase							      =''''''
 for i in table:
  res += inp[i - 1]
 return res
def 				UpperCAmelCase_					(							__snake_case						)     ->			int:







 """simple docstring"""


 return data[1:] + data[0]
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			Dict:







 """simple docstring"""


 _lowercase							      =''''''
 for i in range(len(__snake_case						)						):
  if a[i] == b[i]:
   res += "0"
  else:
   res += "1"
 return res
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			List[Any]:







 """simple docstring"""


 _lowercase							      =int('''0b''' + data[0] + data[-1]     ,						2						)
 _lowercase							      =int('''0b''' + data[1:3]     ,						2						)
 return bin(s[row][col]						)[2:]
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case     ,						__snake_case     ,						__snake_case     ,						__snake_case						)     ->			Dict:







 """simple docstring"""


 _lowercase							      =message[:4]
 _lowercase							      =message[4:]
 _lowercase							      =apply_table(__snake_case     ,						__snake_case						)
 _lowercase							      =xor(__snake_case     ,						__snake_case						)
 _lowercase							      =apply_sbox(__snake_case     ,						temp[:4]						)  # noqa: E741
 _lowercase							      =apply_sbox(__snake_case     ,						temp[4:]						)
 _lowercase							      ='''0''' * (2 - len(__snake_case						)) + l  # noqa: E741
 _lowercase							      ='''0''' * (2 - len(__snake_case						)) + r
 _lowercase							      =apply_table(l + r     ,						__snake_case						)
 _lowercase							      =xor(__snake_case     ,						__snake_case						)
 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)




import argparse
from argparse import Namespace

import torch
from torch import nn

from transformers import XGLMConfig, XGLMForCausalLM






def        UpperCamelCase_(							_snake_case   :  Union[str, Any]	):




			"""simple docstring"""






			__a        =[
			    'decoder.version',
			    'decoder.output_projection.weight',
			    '_float_tensor',
			    'decoder.embed_positions._float_tensor',
			]
			for k in ignore_keys:
						state_dict.pop(_snake_case       ,     _snake_case	)






def        UpperCamelCase_(							_snake_case   :  Any	):




			"""simple docstring"""






			__a      ,    __a        =emb.weight.shape
			__a        =nn.Linear(_snake_case       ,     _snake_case       ,     bias=_snake_case	)
			__a        =emb.weight.data
			return lin_layer






def        UpperCamelCase_(							_snake_case   :  str	):




			"""simple docstring"""






			__a        =torch.load(_snake_case       ,     map_location='cpu'	)
			__a        =Namespace(**checkpoint['cfg']['model']	)
			__a        =checkpoint['model']
			remove_ignore_keys_(_snake_case	)
			__a        =state_dict['decoder.embed_tokens.weight'].shape[0]

			__a        ={key.replace('decoder'       ,     'model'	): val for key, val in state_dict.items()}

			__a        =XGLMConfig(
			    vocab_size=_snake_case       ,     max_position_embeddings=args.max_target_positions       ,     num_layers=args.decoder_layers       ,     attention_heads=args.decoder_attention_heads       ,     ffn_dim=args.decoder_ffn_embed_dim       ,     d_model=args.decoder_embed_dim       ,     layerdrop=args.decoder_layerdrop       ,     dropout=args.dropout       ,     attention_dropout=args.attention_dropout       ,     activation_dropout=args.activation_dropout       ,     activation_function='gelu'       ,     scale_embedding=not args.no_scale_embedding       ,     tie_word_embeddings=args.share_decoder_input_output_embed       ,     )

			__a        =XGLMForCausalLM(_snake_case	)
			__a        =model.load_state_dict(_snake_case       ,     strict=_snake_case	)
			print(_snake_case	)
			__a        =make_linear_from_emb(model.model.embed_tokens	)

			return model


if __name__ == "__main__":
						_lowerCAmelCase					:			str  				=			argparse.ArgumentParser()
						# Required parameters
						parser.add_argument("fairseq_path", type=str, help="path to a model.pt on local filesystem.")
						parser.add_argument("pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model.")
						_lowerCAmelCase					:			str  				=			parser.parse_args()
						_lowerCAmelCase					:			Union[str, Any]  				=			convert_fairseq_xglm_checkpoint_from_disk(args.fairseq_path)
						model.save_pretrained(args.pytorch_dump_folder_path)






