

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase__ :     Tuple				    =    logging.get_logger(__name__)

UpperCAmelCase__ :     Optional[int]				    =    {
    """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/config.json""",
    """bert-large-uncased""": """https://huggingface.co/bert-large-uncased/resolve/main/config.json""",
    """bert-base-cased""": """https://huggingface.co/bert-base-cased/resolve/main/config.json""",
    """bert-large-cased""": """https://huggingface.co/bert-large-cased/resolve/main/config.json""",
    """bert-base-multilingual-uncased""": """https://huggingface.co/bert-base-multilingual-uncased/resolve/main/config.json""",
    """bert-base-multilingual-cased""": """https://huggingface.co/bert-base-multilingual-cased/resolve/main/config.json""",
    """bert-base-chinese""": """https://huggingface.co/bert-base-chinese/resolve/main/config.json""",
    """bert-base-german-cased""": """https://huggingface.co/bert-base-german-cased/resolve/main/config.json""",
    """bert-large-uncased-whole-word-masking""": (
        """https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/config.json"""
    ),
    """bert-large-cased-whole-word-masking""": (
        """https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/config.json"""
    ),
    """bert-large-uncased-whole-word-masking-finetuned-squad""": (
        """https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/config.json"""
    ),
    """bert-large-cased-whole-word-masking-finetuned-squad""": (
        """https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/config.json"""
    ),
    """bert-base-cased-finetuned-mrpc""": """https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/config.json""",
    """bert-base-german-dbmdz-cased""": """https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/config.json""",
    """bert-base-german-dbmdz-uncased""": """https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/config.json""",
    """cl-tohoku/bert-base-japanese""": """https://huggingface.co/cl-tohoku/bert-base-japanese/resolve/main/config.json""",
    """cl-tohoku/bert-base-japanese-whole-word-masking""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-whole-word-masking/resolve/main/config.json"""
    ),
    """cl-tohoku/bert-base-japanese-char""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-char/resolve/main/config.json"""
    ),
    """cl-tohoku/bert-base-japanese-char-whole-word-masking""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-char-whole-word-masking/resolve/main/config.json"""
    ),
    """TurkuNLP/bert-base-finnish-cased-v1""": (
        """https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/config.json"""
    ),
    """TurkuNLP/bert-base-finnish-uncased-v1""": (
        """https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/config.json"""
    ),
    """wietsedv/bert-base-dutch-cased""": """https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/config.json""",
    # See all BERT models at https://huggingface.co/models?filter=bert
}







class        a__       (   UpperCAmelCase       ):







		"""simple docstring"""




		UpperCAmelCase__      : int			       ="""bert"""


		def __init__(			self    : Optional[Any]				,				UpperCAmelCase__    : Tuple=3_0_5_2_2				,				UpperCAmelCase__    : Optional[Any]=7_6_8				,				UpperCAmelCase__    : List[str]=1_2				,				UpperCAmelCase__    : List[Any]=1_2				,				UpperCAmelCase__    : Union[str, Any]=3_0_7_2				,				UpperCAmelCase__    : Optional[Any]="gelu"				,				UpperCAmelCase__    : Dict=0.1				,				UpperCAmelCase__    : Tuple=0.1				,				UpperCAmelCase__    : Dict=5_1_2				,				UpperCAmelCase__    : List[str]=2				,				UpperCAmelCase__    : List[Any]=0.02				,				UpperCAmelCase__    : Union[str, Any]=1e-12				,				UpperCAmelCase__    : Union[str, Any]=0				,				UpperCAmelCase__    : str="absolute"				,				UpperCAmelCase__    : Union[str, Any]=True				,				UpperCAmelCase__    : Dict=None				,				**UpperCAmelCase__    : Union[str, Any]				,				)					->Tuple:
								"""simple docstring"""







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

								SCREAMING_SNAKE_CASE :      Dict       =   vocab_size
								SCREAMING_SNAKE_CASE :      Tuple       =   hidden_size
								SCREAMING_SNAKE_CASE :      Tuple       =   num_hidden_layers
								SCREAMING_SNAKE_CASE :      List[Any]       =   num_attention_heads
								SCREAMING_SNAKE_CASE :      Dict       =   hidden_act
								SCREAMING_SNAKE_CASE :      Any       =   intermediate_size
								SCREAMING_SNAKE_CASE :      Optional[int]       =   hidden_dropout_prob
								SCREAMING_SNAKE_CASE :      Optional[Any]       =   attention_probs_dropout_prob
								SCREAMING_SNAKE_CASE :      Any       =   max_position_embeddings
								SCREAMING_SNAKE_CASE :      Any       =   type_vocab_size
								SCREAMING_SNAKE_CASE :      Any       =   initializer_range
								SCREAMING_SNAKE_CASE :      Optional[Any]       =   layer_norm_eps
								SCREAMING_SNAKE_CASE :      int       =   position_embedding_type
								SCREAMING_SNAKE_CASE :      str       =   use_cache
								SCREAMING_SNAKE_CASE :      int       =   classifier_dropout







class        a__       (   UpperCAmelCase       ):







		"""simple docstring"""




		@property
		def  _lowercase      (			self    : Any		)					->Mapping[str, Mapping[int, str]]:
								"""simple docstring"""







								if self.task == "multiple-choice":
														SCREAMING_SNAKE_CASE :      str       =   {0: """batch""", 1: """choice""", 2: """sequence"""}
								else:
														SCREAMING_SNAKE_CASE :      Union[str, Any]       =   {0: """batch""", 1: """sequence"""}
								return OrderedDict(
								    [
								        ("""input_ids""", dynamic_axis),
								        ("""attention_mask""", dynamic_axis),
								        ("""token_type_ids""", dynamic_axis),
								    ]		)







import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCAmelCase__ :     Optional[Any]				    =    3






def 					__lowercase      (     _A			)     ->						int:
      print("""Generating primitive root of p"""			)
      while True:
            SCREAMING_SNAKE_CASE :      int       =   random.randrange(3						,    _A			)
            if pow(_A						,    2						,    _A			) == 1:
                  continue
            if pow(_A						,    _A						,    _A			) == 1:
                  continue
            return g






def 					__lowercase      (     _A			)     ->						tuple[tuple[int, int, int, int], tuple[int, int]]:
      print("""Generating prime p..."""			)
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   rabin_miller.generate_large_prime(_A			)  # select large prime number.
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   primitive_root(_A			)  # one primitive root on modulo p.
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   random.randrange(3						,    _A			)  # private_key -> have to be greater than 2 for safety.
      SCREAMING_SNAKE_CASE :      List[str]       =   cryptomath.find_mod_inverse(pow(_A						,    _A						,    _A			)						,    _A			)

      SCREAMING_SNAKE_CASE :      str       =   (key_size, e_a, e_a, p)
      SCREAMING_SNAKE_CASE :      Union[str, Any]       =   (key_size, d)

      return public_key, private_key






def 					__lowercase      (     _A						,    _A			)     ->						None:
      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()

      SCREAMING_SNAKE_CASE     ,	SCREAMING_SNAKE_CASE :      List[str]       =   generate_key(_A			)
      print(F"\nWriting public key to file {name}_pubkey.txt..."			)
      with open(F"{name}_pubkey.txt"						,    """w"""			) as fo:
            fo.write(F"{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}"			)

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






def 					__lowercase      (     )     ->						None:
      print("""Making key files..."""			)
      make_key_files("""elgamal"""						,    2048			)
      print("""Key files generation successful"""			)


if __name__ == "__main__":
  main()




