




'''simple docstring'''





import os
import random
import sys

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





def       __a      (  )		->					None:

     """simple docstring"""




     print("Making key files..."       )
     make_key_files("rsa"   ,		1_024       )
     print("Key files generation successful."       )





def       __a      (  _UpperCamelCase:       int       )		->					tuple[tuple[int, int], tuple[int, int]]:

     """simple docstring"""




     print("Generating prime p..."       )
     _snake_case				= rabinMiller.generate_large_prime(_UpperCamelCase       )
     print("Generating prime q..."       )
     _snake_case				= rabinMiller.generate_large_prime(_UpperCamelCase       )
     _snake_case				= p * q

     print("Generating e that is relatively prime to (p - 1) * (q - 1)..."       )
     while True:
          _snake_case				= 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..."       )
     _snake_case				= cryptoMath.find_mod_inverse(_UpperCamelCase   ,		(p - 1) * (q - 1)       )

     _snake_case				= (n, e)
     _snake_case				= (n, d)
     return (public_key, private_key)





def       __a      (  _UpperCamelCase:       str   ,		_UpperCamelCase:       int       )		->					None:

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

     _snake_case				,   _snake_case				= 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


UpperCamelCase_		:     int          =		logging.get_logger(__name__)

UpperCamelCase_		:     Any          =		{
    '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''',
    '''tiiuae/falcon-7b''': '''https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json''',
}

class   _a							(		__lowerCAmelCase				):
     SCREAMING_SNAKE_CASE_				:       List[str]       							=		"""falcon"""
     SCREAMING_SNAKE_CASE_				:       Optional[int]       							=		["""past_key_values"""]






     def __init__(					self   ,_SCREAMING_SNAKE_CASE=65_024   ,_SCREAMING_SNAKE_CASE=4_544   ,_SCREAMING_SNAKE_CASE=32   ,_SCREAMING_SNAKE_CASE=71   ,_SCREAMING_SNAKE_CASE=1e-5   ,_SCREAMING_SNAKE_CASE=0.0_2   ,_SCREAMING_SNAKE_CASE=True   ,_SCREAMING_SNAKE_CASE=0.0   ,_SCREAMING_SNAKE_CASE=0.0   ,_SCREAMING_SNAKE_CASE=None   ,_SCREAMING_SNAKE_CASE=False   ,_SCREAMING_SNAKE_CASE=False   ,_SCREAMING_SNAKE_CASE=True   ,_SCREAMING_SNAKE_CASE=True   ,_SCREAMING_SNAKE_CASE=False   ,_SCREAMING_SNAKE_CASE=11   ,_SCREAMING_SNAKE_CASE=11   ,**_SCREAMING_SNAKE_CASE   ,)				->     Dict:
          _snake_case				= vocab_size
          # Backward compatibility with n_embed kwarg
          _snake_case				= kwargs.pop("n_embed"   ,_SCREAMING_SNAKE_CASE       )
          _snake_case				= hidden_size if n_embed is None else n_embed
          _snake_case				= num_hidden_layers
          _snake_case				= num_attention_heads
          _snake_case				= layer_norm_epsilon
          _snake_case				= initializer_range
          _snake_case				= use_cache
          _snake_case				= hidden_dropout
          _snake_case				= attention_dropout

          _snake_case				= bos_token_id
          _snake_case				= eos_token_id
          _snake_case				= num_attention_heads if num_kv_heads is None else num_kv_heads
          _snake_case				= alibi
          _snake_case				= new_decoder_architecture
          _snake_case				= multi_query  # Ignored when new_decoder_architecture is True
          _snake_case				= parallel_attn
          _snake_case				= bias

          super().__init__(bos_token_id=_SCREAMING_SNAKE_CASE   ,eos_token_id=_SCREAMING_SNAKE_CASE   ,**_SCREAMING_SNAKE_CASE       )






     @property
     def 							_lowercase      (					self       )				->     Union[str, Any]:
          return self.hidden_size // self.num_attention_heads






     @property
     def 							_lowercase      (					self       )				->     Optional[int]:
          return not self.alibi


