






import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812

def      lowerCAmelCase__	(    ):
		print("Making key files..."    )
		make_key_files("rsa"  ,      10_24    )
		print("Key files generation successful."    )

def      lowerCAmelCase__	(    _a       :			int    ):
		print("Generating prime p..."    )
		snake_case_				:							int						 =       rabinMiller.generate_large_prime(_a    )
		print("Generating prime q..."    )
		snake_case_				:							Union[str, Any]						 =       rabinMiller.generate_large_prime(_a    )
		snake_case_				:							Tuple						 =       p * q

		print("Generating e that is relatively prime to (p - 1) * (q - 1)..."    )
		while True:
				snake_case_				:							int						 =       random.randrange(2 ** (key_size - 1)  ,      2 ** (key_size)    )
				if cryptoMath.gcd(_a  ,      (p - 1) * (q - 1)    ) == 1:
						break

		print("Calculating d that is mod inverse of e..."    )
		snake_case_				:							str						 =       cryptoMath.find_mod_inverse(_a  ,      (p - 1) * (q - 1)    )

		snake_case_				:							Optional[Any]						 =       (n, e)
		snake_case_				:							Union[str, Any]						 =       (n, d)
		return (public_key, private_key)

def      lowerCAmelCase__	(    _a       :			str  ,      _a       :			int    ):
		if os.path.exists(F'''{name}_pubkey.txt'''    ) or os.path.exists(F'''{name}_privkey.txt'''    ):
				print("\nWARNING:"    )
				print(
				    F'''"{name}_pubkey.txt" or "{name}_privkey.txt" already exists. \n'''
				    "Use a different name or delete these files and re-run this program."    )
				sys.exit()

		snake_case_				:							Optional[int]						 =       generate_key(_a    )
		print(F'''\nWriting public key to file {name}_pubkey.txt...'''    )
		with open(F'''{name}_pubkey.txt'''  ,      "w"    ) as out_file:
				out_file.write(F'''{key_size},{public_key[0]},{public_key[1]}'''    )

		print(F'''Writing private key to file {name}_privkey.txt...'''    )
		with open(F'''{name}_privkey.txt'''  ,      "w"    ) as out_file:
				out_file.write(F'''{key_size},{private_key[0]},{private_key[1]}'''    )


if __name__ == "__main__":
							main()














import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase  :							List[Any]			  =    logging.get_logger(__name__)

lowercase  :							Any			  =    {
    '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json''',
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}




class 		UpperCAmelCase_						(	SCREAMING_SNAKE_CASE__					):


						'''simple docstring'''




						A     :   Optional[int]						=					'sew-d'






						def __init__(	self		,				_SCREAMING_SNAKE_CASE=32		,				_SCREAMING_SNAKE_CASE=768		,				_SCREAMING_SNAKE_CASE=12		,				_SCREAMING_SNAKE_CASE=12		,				_SCREAMING_SNAKE_CASE=3072		,				_SCREAMING_SNAKE_CASE=2		,				_SCREAMING_SNAKE_CASE=512		,				_SCREAMING_SNAKE_CASE=256		,				_SCREAMING_SNAKE_CASE=True		,				_SCREAMING_SNAKE_CASE=True		,				_SCREAMING_SNAKE_CASE=("p2c", "c2p")		,				_SCREAMING_SNAKE_CASE="layer_norm"		,				_SCREAMING_SNAKE_CASE="gelu_python"		,				_SCREAMING_SNAKE_CASE=0.1		,				_SCREAMING_SNAKE_CASE=0.1		,				_SCREAMING_SNAKE_CASE=0.1		,				_SCREAMING_SNAKE_CASE=0.0		,				_SCREAMING_SNAKE_CASE=0.1		,				_SCREAMING_SNAKE_CASE=0.02		,				_SCREAMING_SNAKE_CASE=1e-7		,				_SCREAMING_SNAKE_CASE=1e-5		,				_SCREAMING_SNAKE_CASE="group"		,				_SCREAMING_SNAKE_CASE="gelu"		,				_SCREAMING_SNAKE_CASE=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)		,				_SCREAMING_SNAKE_CASE=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)		,				_SCREAMING_SNAKE_CASE=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)		,				_SCREAMING_SNAKE_CASE=False		,				_SCREAMING_SNAKE_CASE=128		,				_SCREAMING_SNAKE_CASE=16		,				_SCREAMING_SNAKE_CASE=True		,				_SCREAMING_SNAKE_CASE=0.05		,				_SCREAMING_SNAKE_CASE=10		,				_SCREAMING_SNAKE_CASE=2		,				_SCREAMING_SNAKE_CASE=0.0		,				_SCREAMING_SNAKE_CASE=10		,				_SCREAMING_SNAKE_CASE=0		,				_SCREAMING_SNAKE_CASE="mean"		,				_SCREAMING_SNAKE_CASE=False		,				_SCREAMING_SNAKE_CASE=False		,				_SCREAMING_SNAKE_CASE=256		,				_SCREAMING_SNAKE_CASE=0		,				_SCREAMING_SNAKE_CASE=1		,				_SCREAMING_SNAKE_CASE=2		,				**_SCREAMING_SNAKE_CASE		,				) ->				List[Any]:
								super().__init__(**_SCREAMING_SNAKE_CASE		,				pad_token_id=_SCREAMING_SNAKE_CASE		,				bos_token_id=_SCREAMING_SNAKE_CASE		,				eos_token_id=_SCREAMING_SNAKE_CASE				)
								snake_case_				:							Optional[Any]						 =       hidden_size
								snake_case_				:							Any						 =       feat_extract_norm
								snake_case_				:							Union[str, Any]						 =       feat_extract_activation
								snake_case_				:							Any						 =       list(_SCREAMING_SNAKE_CASE				)
								snake_case_				:							Any						 =       list(_SCREAMING_SNAKE_CASE				)
								snake_case_				:							Tuple						 =       list(_SCREAMING_SNAKE_CASE				)
								snake_case_				:							List[Any]						 =       conv_bias
								snake_case_				:							Union[str, Any]						 =       num_conv_pos_embeddings
								snake_case_				:							Tuple						 =       num_conv_pos_embedding_groups
								snake_case_				:							Optional[int]						 =       len(self.conv_dim				)
								snake_case_				:							str						 =       num_hidden_layers
								snake_case_				:							List[Any]						 =       intermediate_size
								snake_case_				:							List[Any]						 =       squeeze_factor
								snake_case_				:							Tuple						 =       max_position_embeddings
								snake_case_				:							Optional[int]						 =       position_buckets
								snake_case_				:							Union[str, Any]						 =       share_att_key
								snake_case_				:							Optional[int]						 =       relative_attention
								snake_case_				:							List[str]						 =       norm_rel_ebd
								snake_case_				:							Tuple						 =       list(_SCREAMING_SNAKE_CASE				)
								snake_case_				:							str						 =       hidden_act
								snake_case_				:							Any						 =       num_attention_heads
								snake_case_				:							Dict						 =       hidden_dropout
								snake_case_				:							int						 =       attention_dropout
								snake_case_				:							Any						 =       activation_dropout
								snake_case_				:							Optional[Any]						 =       feat_proj_dropout
								snake_case_				:							Tuple						 =       final_dropout
								snake_case_				:							Tuple						 =       layer_norm_eps
								snake_case_				:							Tuple						 =       feature_layer_norm_eps
								snake_case_				:							Any						 =       initializer_range
								snake_case_				:							Optional[int]						 =       vocab_size

								if (
								    (len(self.conv_stride				) != self.num_feat_extract_layers)
								    or (len(self.conv_kernel				) != self.num_feat_extract_layers)
								    or (len(self.conv_dim				) != self.num_feat_extract_layers)
								):
										raise ValueError(
										    "Configuration for convolutional layers is incorrect."
										    "It is required that `len(config.conv_dim)` == `len(config.conv_stride)` == `len(config.conv_kernel)`,"
										    f'''but is `len(config.conv_dim) = {len(self.conv_dim				)}`, `len(config.conv_stride)'''
										    f'''= {len(self.conv_stride				)}`, `len(config.conv_kernel) = {len(self.conv_kernel				)}`.'''				)

								# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
								snake_case_				:							List[str]						 =       apply_spec_augment
								snake_case_				:							List[Any]						 =       mask_time_prob
								snake_case_				:							str						 =       mask_time_length
								snake_case_				:							Optional[Any]						 =       mask_time_min_masks
								snake_case_				:							Optional[Any]						 =       mask_feature_prob
								snake_case_				:							str						 =       mask_feature_length
								snake_case_				:							Optional[int]						 =       mask_feature_min_masks

								# ctc loss
								snake_case_				:							Any						 =       ctc_loss_reduction
								snake_case_				:							Tuple						 =       ctc_zero_infinity

								# sequence classification
								snake_case_				:							int						 =       use_weighted_layer_sum
								snake_case_				:							List[Any]						 =       classifier_proj_size






						@property
						def       _lowerCAmelCase       (	self				) ->				Dict:
								return functools.reduce(operator.mul		,				self.conv_stride		,				1				)
