


import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812
def 				__lowerCamelCase						( ):




      """simple docstring"""





      print('''Making key files...'''						)
      make_key_files('''rsa''' ,  1024						)
      print('''Key files generation successful.'''						)
def 				__lowerCamelCase						( UpperCAmelCase_						:		int						):




      """simple docstring"""





      print('''Generating prime p...'''						)
      a						:Dict 							=       rabinMiller.generate_large_prime(UpperCAmelCase_						)
      print('''Generating prime q...'''						)
      a						:Optional[Any] 							=       rabinMiller.generate_large_prime(UpperCAmelCase_						)
      a						:int 							=       p * q

      print('''Generating e that is relatively prime to (p - 1) * (q - 1)...'''						)
      while True:
            a						:Optional[Any] 							=       random.randrange(2 ** (key_size - 1) ,  2 ** (key_size)						)
            if cryptoMath.gcd(UpperCAmelCase_ ,  (p - 1) * (q - 1)						) == 1:
                  break

      print('''Calculating d that is mod inverse of e...'''						)
      a						:Union[str, Any] 							=       cryptoMath.find_mod_inverse(UpperCAmelCase_ ,  (p - 1) * (q - 1)						)

      a						:Tuple 							=       (n, e)
      a						:Optional[int] 							=       (n, d)
      return (public_key, private_key)
def 				__lowerCamelCase						( UpperCAmelCase_						:		str ,  UpperCAmelCase_						:		int						):




      """simple docstring"""





      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()

      a							,				a						:List[str] 							=       generate_key(UpperCAmelCase_						)
      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()









'''simple docstring'''

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


lowerCamelCase							:   Dict  						=	logging.get_logger(__name__)

lowerCamelCase							:   Union[str, Any]  						=	{
    # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert
}
class   __lowerCAmelCase						(lowercase_     ):





      '''simple docstring'''






      lowerCAmelCase__					:     List[str]  					=							"""megatron-bert"""



      def __init__(self    :    Tuple   ,						UpperCamelCase    :    Optional[int]=29056   ,						UpperCamelCase    :    Optional[Any]=1024   ,						UpperCamelCase    :    Any=24   ,						UpperCamelCase    :    int=16   ,						UpperCamelCase    :    Optional[int]=4096   ,						UpperCamelCase    :    int="gelu"   ,						UpperCamelCase    :    int=0.1   ,						UpperCamelCase    :    Tuple=0.1   ,						UpperCamelCase    :    Any=512   ,						UpperCamelCase    :    int=2   ,						UpperCamelCase    :    Dict=0.02   ,						UpperCamelCase    :    Dict=1E-12   ,						UpperCamelCase    :    List[Any]=0   ,						UpperCamelCase    :    Optional[int]="absolute"   ,						UpperCamelCase    :    List[Any]=True   ,						**UpperCamelCase    :    str   ,						):

             '''simple docstring'''







             super().__init__(pad_token_id=UpperCamelCase   ,						**UpperCamelCase )

             lowercase__      			= vocab_size
             lowercase__      			= hidden_size
             lowercase__      			= num_hidden_layers
             lowercase__      			= num_attention_heads
             lowercase__      			= hidden_act
             lowercase__      			= intermediate_size
             lowercase__      			= hidden_dropout_prob
             lowercase__      			= attention_probs_dropout_prob
             lowercase__      			= max_position_embeddings
             lowercase__      			= type_vocab_size
             lowercase__      			= initializer_range
             lowercase__      			= layer_norm_eps
             lowercase__      			= position_embedding_type
             lowercase__      			= use_cache




