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


UpperCAmelCase__		:     Dict     			=      logging.get_logger(__name__)

UpperCAmelCase__		:     Union[str, Any]     			=      {
    'caidas/swin2sr-classicalsr-x2-64': (
        'https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json'
    ),
}






class UpperCAmelCase   (						SCREAMING_SNAKE_CASE__   ):





   '''simple docstring'''
   __UpperCamelCase		:    Dict 				=    '''swin2sr'''

   __UpperCamelCase		:    str 				=    {
       '''hidden_size''': '''embed_dim''',
       '''num_attention_heads''': '''num_heads''',
       '''num_hidden_layers''': '''num_layers''',
   }


   def __init__(					self     :							List[str]			,			lowerCAmelCase_     :							int=6_4			,			lowerCAmelCase_     :							Optional[Any]=1			,			lowerCAmelCase_     :							Dict=3			,			lowerCAmelCase_     :							Dict=1_8_0			,			lowerCAmelCase_     :							Union[str, Any]=[6, 6, 6, 6, 6, 6]			,			lowerCAmelCase_     :							Tuple=[6, 6, 6, 6, 6, 6]			,			lowerCAmelCase_     :							int=8			,			lowerCAmelCase_     :							Any=2.0			,			lowerCAmelCase_     :							Union[str, Any]=True			,			lowerCAmelCase_     :							Dict=0.0			,			lowerCAmelCase_     :							Optional[int]=0.0			,			lowerCAmelCase_     :							int=0.1			,			lowerCAmelCase_     :							Any="gelu"			,			lowerCAmelCase_     :							List[str]=False			,			lowerCAmelCase_     :							str=0.02			,			lowerCAmelCase_     :							Optional[Any]=1e-5			,			lowerCAmelCase_     :							int=2			,			lowerCAmelCase_     :							int=1.0			,			lowerCAmelCase_     :							Any="1conv"			,			lowerCAmelCase_     :							List[str]="pixelshuffle"			,			**lowerCAmelCase_     :							str			,			):

      """simple docstring"""
      super().__init__(**lowerCAmelCase_     )

      _A:  List[str]					=       image_size
      _A:  Any					=       patch_size
      _A:  Any					=       num_channels
      _A:  Union[str, Any]					=       embed_dim
      _A:  int					=       depths
      _A:  List[Any]					=       len(lowerCAmelCase_     )
      _A:  int					=       num_heads
      _A:  Any					=       window_size
      _A:  Optional[int]					=       mlp_ratio
      _A:  int					=       qkv_bias
      _A:  List[Any]					=       hidden_dropout_prob
      _A:  List[str]					=       attention_probs_dropout_prob
      _A:  List[Any]					=       drop_path_rate
      _A:  Any					=       hidden_act
      _A:  List[str]					=       use_absolute_embeddings
      _A:  Tuple					=       layer_norm_eps
      _A:  str					=       initializer_range
      _A:  int					=       upscale
      _A:  int					=       img_range
      _A:  Optional[Any]					=       resi_connection
      _A:  int					=       upsampler





import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCAmelCase__		:     Any     			=      3






def   lowerCamelCase__							(					a      )      ->   int:
   print('''Generating primitive root of p'''      )
   while True:
      _A:  Union[str, Any]					=       random.randrange(3		,		a      )
      if pow(a		,		2		,		a      ) == 1:
         continue
      if pow(a		,		a		,		a      ) == 1:
         continue
      return g






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

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

   return public_key, private_key






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

   _A			,  _A:  Any					=       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   lowerCamelCase__							(					)      ->   None:
   print('''Making key files...'''      )
   make_key_files('''elgamal'''		,		20_48      )
   print('''Key files generation successful'''      )


if __name__ == "__main__":
   main()



