

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






 """simple docstring"""



 print('''Making key files...'''      )
 make_key_files('''rsa'''     ,				1024      )
 print('''Key files generation successful.'''      )


def 		_A     (    A__      ):






 """simple docstring"""



 print('''Generating prime p...'''      )
 __lowercase							  = rabinMiller.generate_large_prime(A__      )
 print('''Generating prime q...'''      )
 __lowercase							  = rabinMiller.generate_large_prime(A__      )
 __lowercase							  = p * q

 print('''Generating e that is relatively prime to (p - 1) * (q - 1)...'''      )
 while True:
  __lowercase							  = random.randrange(2 ** (key_size - 1)     ,				2 ** (key_size)      )
  if cryptoMath.gcd(A__     ,				(p - 1) * (q - 1)      ) == 1:
   break

 print('''Calculating d that is mod inverse of e...'''      )
 __lowercase							  = cryptoMath.find_mod_inverse(A__     ,				(p - 1) * (q - 1)      )

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


def 		_A     (    A__     ,				A__      ):






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

 __lowercase  ,	__lowercase							  = generate_key(A__      )
 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
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowerCAmelCase__											=	logging.get_logger(__name__)

lowerCAmelCase__											=	{
    '''facebook/convnextv2-tiny-1k-224''': '''https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json''',
}






class 			lowercase_	(lowerCamelCase__				,       lowerCamelCase__      ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE    :  List[str]							=			'convnextv2'






  def __init__(      self   :     Tuple					,lowercase__   :     Dict=3					,lowercase__   :     int=4					,lowercase__   :     Optional[int]=4					,lowercase__   :     Optional[Any]=None					,lowercase__   :     List[str]=None					,lowercase__   :     Tuple="gelu"					,lowercase__   :     Dict=0.0_2					,lowercase__   :     List[Any]=1e-1_2					,lowercase__   :     Optional[int]=0.0					,lowercase__   :     int=2_2_4					,lowercase__   :     int=None					,lowercase__   :     Tuple=None					,**lowercase__   :     List[str]					,):
   super().__init__(**lowercase__			)

   __lowercase							  = num_channels
   __lowercase							  = patch_size
   __lowercase							  = num_stages
   __lowercase							  = [9_6, 1_9_2, 3_8_4, 7_6_8] if hidden_sizes is None else hidden_sizes
   __lowercase							  = [3, 3, 9, 3] if depths is None else depths
   __lowercase							  = hidden_act
   __lowercase							  = initializer_range
   __lowercase							  = layer_norm_eps
   __lowercase							  = drop_path_rate
   __lowercase							  = image_size
   __lowercase							  = ['''stem'''] + [F"stage{idx}" for idx in range(1					,len(self.depths			) + 1			)]
   __lowercase  ,	__lowercase							  = get_aligned_output_features_output_indices(
       out_features=lowercase__					,out_indices=lowercase__					,stage_names=self.stage_names			)

