

import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class        a__       (   UpperCAmelCase       ):







		"""simple docstring"""




		UpperCAmelCase__      : Union[str, Any]			       =["""image_processor""", """tokenizer"""]
		UpperCAmelCase__      : int			       ="""ViTImageProcessor"""
		UpperCAmelCase__      : Optional[int]			       =("""CLIPTokenizer""", """CLIPTokenizerFast""")


		def __init__(			self    : str				,				UpperCAmelCase__    : Tuple=None				,				UpperCAmelCase__    : List[Any]=None				,				**UpperCAmelCase__    : Union[str, Any]		)					->Optional[Any]:
								"""simple docstring"""







								SCREAMING_SNAKE_CASE :      Union[str, Any]       =   None
								if "feature_extractor" in kwargs:
														warnings.warn(
														    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
														    """ instead."""				,				UpperCAmelCase__				,				)
														SCREAMING_SNAKE_CASE :      int       =   kwargs.pop("""feature_extractor"""		)

								SCREAMING_SNAKE_CASE :      List[str]       =   image_processor if image_processor is not None else feature_extractor
								if image_processor is None:
														raise ValueError("""You need to specify an `image_processor`."""		)
								if tokenizer is None:
														raise ValueError("""You need to specify a `tokenizer`."""		)

								super().__init__(UpperCAmelCase__				,				UpperCAmelCase__		)


		def __call__(			self    : str				,				UpperCAmelCase__    : Optional[Any]=None				,				UpperCAmelCase__    : Union[str, Any]=None				,				UpperCAmelCase__    : Optional[int]=None				,				UpperCAmelCase__    : Optional[int]=None				,				**UpperCAmelCase__    : Any		)					->List[str]:
								"""simple docstring"""







								if text is None and visual_prompt is None and images is None:
														raise ValueError("""You have to specify either text, visual prompt or images."""		)

								if text is not None and visual_prompt is not None:
														raise ValueError("""You have to specify exactly one type of prompt. Either text or visual prompt."""		)

								if text is not None:
														SCREAMING_SNAKE_CASE :      Any       =   self.tokenizer(UpperCAmelCase__				,				return_tensors=UpperCAmelCase__				,				**UpperCAmelCase__		)

								if visual_prompt is not None:
														SCREAMING_SNAKE_CASE :      Any       =   self.image_processor(UpperCAmelCase__				,				return_tensors=UpperCAmelCase__				,				**UpperCAmelCase__		)

								if images is not None:
														SCREAMING_SNAKE_CASE :      str       =   self.image_processor(UpperCAmelCase__				,				return_tensors=UpperCAmelCase__				,				**UpperCAmelCase__		)

								if visual_prompt is not None and images is not None:
														SCREAMING_SNAKE_CASE :      Optional[int]       =   {
														    """pixel_values""": image_features.pixel_values,
														    """conditional_pixel_values""": prompt_features.pixel_values,
														}
														return encoding
								elif text is not None and images is not None:
														SCREAMING_SNAKE_CASE :      str       =   image_features.pixel_values
														return encoding
								elif text is not None:
														return encoding
								elif visual_prompt is not None:
														SCREAMING_SNAKE_CASE :      str       =   {
														    """conditional_pixel_values""": prompt_features.pixel_values,
														}
														return encoding
								else:
														return BatchEncoding(data=dict(**UpperCAmelCase__		)				,				tensor_type=UpperCAmelCase__		)


		def  _lowercase      (			self    : Optional[Any]				,				*UpperCAmelCase__    : Optional[int]				,				**UpperCAmelCase__    : Any		)					->str:
								"""simple docstring"""







								return self.tokenizer.batch_decode(*UpperCAmelCase__				,				**UpperCAmelCase__		)


		def  _lowercase      (			self    : List[str]				,				*UpperCAmelCase__    : Optional[Any]				,				**UpperCAmelCase__    : Dict		)					->Tuple:
								"""simple docstring"""







								return self.tokenizer.decode(*UpperCAmelCase__				,				**UpperCAmelCase__		)


		@property
		def  _lowercase      (			self    : Optional[int]		)					->Tuple:
								"""simple docstring"""







								warnings.warn(
								    """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""				,				UpperCAmelCase__				,				)
								return self.image_processor_class




		@property
		def  _lowercase      (			self    : Optional[Any]		)					->Any:
								"""simple docstring"""







								warnings.warn(
								    """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""				,				UpperCAmelCase__				,				)
								return self.image_processor







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




