


'''simple docstring'''


def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):
		_UpperCAmelCase		:       Optional[int]								=      ""
		for i in table:
				res += inp[i - 1]
		return res






def  __lowerCAmelCase (__lowerCAmelCase   ):
		return data[1:] + data[0]






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):
		_UpperCAmelCase		:       Union[str, Any]								=      ""
		for i in range(len(_A   )   ):
				if a[i] == b[i]:
						res += "0"
				else:
						res += "1"
		return res






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):
		_UpperCAmelCase		:       List[str]								=      int("0b" + data[0] + data[-1]      , 2   )
		_UpperCAmelCase		:       Optional[int]								=      int("0b" + data[1:3]      , 2   )
		return bin(s[row][col]   )[2:]






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase      , __lowerCAmelCase      , __lowerCAmelCase      , __lowerCAmelCase   ):
		_UpperCAmelCase		:       Dict								=      message[:4]
		_UpperCAmelCase		:       str								=      message[4:]
		_UpperCAmelCase		:       Union[str, Any]								=      apply_table(_A      , _A   )
		_UpperCAmelCase		:       Optional[int]								=      xor(_A      , _A   )
		_UpperCAmelCase		:       Union[str, Any]								=      apply_sbox(_A      , temp[:4]   )  # noqa: E741
		_UpperCAmelCase		:       List[str]								=      apply_sbox(_A      , temp[4:]   )
		_UpperCAmelCase		:       Union[str, Any]								=      "0" * (2 - len(_A   )) + l  # noqa: E741
		_UpperCAmelCase		:       str								=      "0" * (2 - len(_A   )) + r
		_UpperCAmelCase		:       List[str]								=      apply_table(l + r      , _A   )
		_UpperCAmelCase		:       Tuple								=      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 argparse

import torch

from transformers import BertForMaskedLM


if __name__ == "__main__":
						lowerCamelCase__    	=     argparse.ArgumentParser(
						    description=(
						        'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned'
						        ' Distillation'
						    )
						)
						parser.add_argument('--model_type', default='bert', choices=['bert'])
						parser.add_argument('--model_name', default='bert-base-uncased', type=str)
						parser.add_argument('--dump_checkpoint', default='serialization_dir/tf_bert-base-uncased_0247911.pth', type=str)
						parser.add_argument('--vocab_transform', action='store_true')
						lowerCamelCase__    	=     parser.parse_args()

						if args.model_type == "bert":
												lowerCamelCase__    	=     BertForMaskedLM.from_pretrained(args.model_name)
												lowerCamelCase__    	=     'bert'
						else:
												raise ValueError('args.model_type should be "bert".')

						lowerCamelCase__    	=     model.state_dict()
						lowerCamelCase__    	=     {}

						for w in ["word_embeddings", "position_embeddings"]:
												lowerCamelCase__    	=     state_dict[F'''{prefix}.embeddings.{w}.weight''']
						for w in ["weight", "bias"]:
												lowerCamelCase__    	=     state_dict[F'''{prefix}.embeddings.LayerNorm.{w}''']

						lowerCamelCase__    	=     0
						for teacher_idx in [0, 2, 4, 7, 9, 11]:
												for w in ["weight", "bias"]:
																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.attention.self.query.{w}'''
																		]
																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.attention.self.key.{w}'''
																		]
																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.attention.self.value.{w}'''
																		]

																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.attention.output.dense.{w}'''
																		]
																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.attention.output.LayerNorm.{w}'''
																		]

																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.intermediate.dense.{w}'''
																		]
																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.output.dense.{w}'''
																		]
																		lowerCamelCase__    	=     state_dict[
																		    F'''{prefix}.encoder.layer.{teacher_idx}.output.LayerNorm.{w}'''
																		]
												std_idx += 1

						lowerCamelCase__    	=     state_dict['cls.predictions.decoder.weight']
						lowerCamelCase__    	=     state_dict['cls.predictions.bias']
						if args.vocab_transform:
												for w in ["weight", "bias"]:
																		lowerCamelCase__    	=     state_dict[F'''cls.predictions.transform.dense.{w}''']
																		lowerCamelCase__    	=     state_dict[F'''cls.predictions.transform.LayerNorm.{w}''']

						print(F'''N layers selected for distillation: {std_idx}''')
						print(F'''Number of params transferred for distillation: {len(compressed_sd.keys())}''')

						print(F'''Save transferred checkpoint to {args.dump_checkpoint}.''')
						torch.save(compressed_sd, args.dump_checkpoint)



