




import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

__SCREAMING_SNAKE_CASE 						=3

def 			a   (_lowerCAmelCase     ):
							print('''Generating primitive root of p'''     )
							while True:
														SCREAMING_SNAKE_CASE_   	=    random.randrange(3  ,    __SCREAMING_SNAKE_CASE     )
														if pow(__SCREAMING_SNAKE_CASE  ,    2  ,    __SCREAMING_SNAKE_CASE     ) == 1:
																					continue
														if pow(__SCREAMING_SNAKE_CASE  ,    __SCREAMING_SNAKE_CASE  ,    __SCREAMING_SNAKE_CASE     ) == 1:
																					continue
														return g

def 			a   (_lowerCAmelCase     ):
							print('''Generating prime p...'''     )
							SCREAMING_SNAKE_CASE_   	=    rabin_miller.generate_large_prime(__SCREAMING_SNAKE_CASE     )  # select large prime number.
							SCREAMING_SNAKE_CASE_   	=    primitive_root(__SCREAMING_SNAKE_CASE     )  # one primitive root on modulo p.
							SCREAMING_SNAKE_CASE_   	=    random.randrange(3  ,    __SCREAMING_SNAKE_CASE     )  # private_key -> have to be greater than 2 for safety.
							SCREAMING_SNAKE_CASE_   	=    cryptomath.find_mod_inverse(pow(__SCREAMING_SNAKE_CASE  ,    __SCREAMING_SNAKE_CASE  ,    __SCREAMING_SNAKE_CASE     )  ,    __SCREAMING_SNAKE_CASE     )

							SCREAMING_SNAKE_CASE_   	=    (key_size, e_a, e_a, p)
							SCREAMING_SNAKE_CASE_   	=    (key_size, d)

							return public_key, private_key

def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):






							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_   	=    generate_key(__SCREAMING_SNAKE_CASE     )
							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 			a   ():
							print('''Making key files...'''     )
							make_key_files('''elgamal'''  ,    2_0_4_8     )
							print('''Key files generation successful'''     )


if __name__ == "__main__":
			main()








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


__SCREAMING_SNAKE_CASE 						=logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE 						={
    """caidas/swin2sr-classicalsr-x2-64""": (
        """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json"""
    ),
}






class  __magic_name__						(  __UpperCAmelCase):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							Optional[Any]	      =					"swin2sr"

				SCREAMING_SNAKE_CASE__					:							str	      =					{
				    "hidden_size": "embed_dim",
				    "num_attention_heads": "num_heads",
				    "num_hidden_layers": "num_layers",
				}


				def __init__(							self:   Optional[int]		,					_lowerCamelCase:   Dict=64		,					_lowerCamelCase:   str=1		,					_lowerCamelCase:   Optional[int]=3		,					_lowerCamelCase:   List[Any]=1_80		,					_lowerCamelCase:   Optional[int]=[6, 6, 6, 6, 6, 6]		,					_lowerCamelCase:   Union[str, Any]=[6, 6, 6, 6, 6, 6]		,					_lowerCamelCase:   Tuple=8		,					_lowerCamelCase:   List[Any]=2.0		,					_lowerCamelCase:   Dict=True		,					_lowerCamelCase:   Dict=0.0		,					_lowerCamelCase:   int=0.0		,					_lowerCamelCase:   Optional[int]=0.1		,					_lowerCamelCase:   Any="gelu"		,					_lowerCamelCase:   int=False		,					_lowerCamelCase:   Tuple=0.02		,					_lowerCamelCase:   List[str]=1E-5		,					_lowerCamelCase:   List[Any]=2		,					_lowerCamelCase:   str=1.0		,					_lowerCamelCase:   List[Any]="1conv"		,					_lowerCamelCase:   str="pixelshuffle"		,					**_lowerCamelCase:   List[str]		,					):
											super().__init__(**_lowerCamelCase		)

											SCREAMING_SNAKE_CASE_   	=    image_size
											SCREAMING_SNAKE_CASE_   	=    patch_size
											SCREAMING_SNAKE_CASE_   	=    num_channels
											SCREAMING_SNAKE_CASE_   	=    embed_dim
											SCREAMING_SNAKE_CASE_   	=    depths
											SCREAMING_SNAKE_CASE_   	=    len(_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    num_heads
											SCREAMING_SNAKE_CASE_   	=    window_size
											SCREAMING_SNAKE_CASE_   	=    mlp_ratio
											SCREAMING_SNAKE_CASE_   	=    qkv_bias
											SCREAMING_SNAKE_CASE_   	=    hidden_dropout_prob
											SCREAMING_SNAKE_CASE_   	=    attention_probs_dropout_prob
											SCREAMING_SNAKE_CASE_   	=    drop_path_rate
											SCREAMING_SNAKE_CASE_   	=    hidden_act
											SCREAMING_SNAKE_CASE_   	=    use_absolute_embeddings
											SCREAMING_SNAKE_CASE_   	=    layer_norm_eps
											SCREAMING_SNAKE_CASE_   	=    initializer_range
											SCREAMING_SNAKE_CASE_   	=    upscale
											SCREAMING_SNAKE_CASE_   	=    img_range
											SCREAMING_SNAKE_CASE_   	=    resi_connection
											SCREAMING_SNAKE_CASE_   	=    upsampler


