






from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


snake_case_   :	Optional[Any]							      =logging.get_logger(__name__)  # pylint: disable=invalid-name





class        a__      (	lowerCAmelCase__		):
		UpperCAmelCase_							:       Dict 					= ['safety_checker', 'feature_extractor']






		def __init__(      self							, lowercase__							, lowercase__							, lowercase__							, lowercase__							, lowercase__							, lowercase__							, lowercase__							, lowercase__ = True							, )				->				Dict:
				super().__init__()
				if hasattr(scheduler.config							, "steps_offset"						) and scheduler.config.steps_offset != 1:
						__A    =							(
						    F"""The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`"""
						    F""" should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure """
						    "to update the config accordingly as leaving `steps_offset` might led to incorrect results"
						    " in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,"
						    " it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`"
						    " file"
						)
						deprecate("steps_offset!=1"							, "1.0.0"							, lowercase__							, standard_warn=lowercase__						)
						__A    =							dict(scheduler.config						)
						__A    =							1
						__A    =							FrozenDict(lowercase__						)

				self.register_modules(
				    vae=lowercase__							, text_encoder=lowercase__							, tokenizer=lowercase__							, unet=lowercase__							, scheduler=lowercase__							, safety_checker=lowercase__							, feature_extractor=lowercase__							, )
				self.register_to_config(requires_safety_checker=lowercase__						)






		@property
		def 					_lowerCamelCase					(      self						)				->				Dict[str, Any]:
				return {k: getattr(self							, lowercase__						) for k in self.config.keys() if not k.startswith("_"						)}






		def 					_lowerCamelCase					(      self							, lowercase__ = "auto"						)				->				str:
				if slice_size == "auto":
						# half the attention head size is usually a good trade-off between
						# speed and memory
						__A    =							self.unet.config.attention_head_dim // 2
				self.unet.set_attention_slice(lowercase__						)






		def 					_lowerCamelCase					(      self						)				->				Optional[int]:
				self.enable_attention_slicing(lowercase__						)






		@torch.no_grad()
		def 					_lowerCamelCase					(      self							, lowercase__							, lowercase__							, lowercase__							, lowercase__ = 0.8							, lowercase__ = 50							, lowercase__ = 7.5							, lowercase__ = None							, lowercase__ = 1							, lowercase__ = 0.0							, lowercase__ = None							, lowercase__ = "pil"							, lowercase__ = True							, lowercase__ = None							, lowercase__ = 1							, )				->				List[str]:
				# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
				return StableDiffusionInpaintPipelineLegacy(**self.components						)(
				    prompt=lowercase__							, image=lowercase__							, mask_image=lowercase__							, strength=lowercase__							, num_inference_steps=lowercase__							, guidance_scale=lowercase__							, negative_prompt=lowercase__							, num_images_per_prompt=lowercase__							, eta=lowercase__							, generator=lowercase__							, output_type=lowercase__							, return_dict=lowercase__							, callback=lowercase__							, )






		@torch.no_grad()
		def 					_lowerCamelCase					(      self							, lowercase__							, lowercase__							, lowercase__ = 0.8							, lowercase__ = 50							, lowercase__ = 7.5							, lowercase__ = None							, lowercase__ = 1							, lowercase__ = 0.0							, lowercase__ = None							, lowercase__ = "pil"							, lowercase__ = True							, lowercase__ = None							, lowercase__ = 1							, **lowercase__							, )				->				Tuple:
				# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
				return StableDiffusionImgaImgPipeline(**self.components						)(
				    prompt=lowercase__							, image=lowercase__							, strength=lowercase__							, num_inference_steps=lowercase__							, guidance_scale=lowercase__							, negative_prompt=lowercase__							, num_images_per_prompt=lowercase__							, eta=lowercase__							, generator=lowercase__							, output_type=lowercase__							, return_dict=lowercase__							, callback=lowercase__							, callback_steps=lowercase__							, )






		@torch.no_grad()
		def 					_lowerCamelCase					(      self							, lowercase__							, lowercase__ = 512							, lowercase__ = 512							, lowercase__ = 50							, lowercase__ = 7.5							, lowercase__ = None							, lowercase__ = 1							, lowercase__ = 0.0							, lowercase__ = None							, lowercase__ = None							, lowercase__ = "pil"							, lowercase__ = True							, lowercase__ = None							, lowercase__ = 1							, )				->				Tuple:
				# For more information on how this function https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline
				return StableDiffusionPipeline(**self.components						)(
				    prompt=lowercase__							, height=lowercase__							, width=lowercase__							, num_inference_steps=lowercase__							, guidance_scale=lowercase__							, negative_prompt=lowercase__							, num_images_per_prompt=lowercase__							, eta=lowercase__							, generator=lowercase__							, latents=lowercase__							, output_type=lowercase__							, return_dict=lowercase__							, callback=lowercase__							, callback_steps=lowercase__							, )




from __future__ import annotations





def  _snake_case		(snake_case_					:     int  )							->		int | None:
  for r in range(1    ,       snake_case_  ):
    __UpperCAmelCase	:  List[str]		=     []
    for x in range(n - 1  ):
      __UpperCAmelCase	:  Union[str, Any]		=     pow(snake_case_    ,       snake_case_    ,       snake_case_  )
      if val in li:
        break
      li.append(snake_case_  )
    else:
      return r
  return None


if __name__ == "__main__":
      _SCREAMING_SNAKE_CASE							 =			int(input('''Enter a prime number q: '''))
      _SCREAMING_SNAKE_CASE							 =			find_primitive(q)
      if a is None:
            print(F'''Cannot find the primitive for the value: {a!r}''')
      else:
            _SCREAMING_SNAKE_CASE							 =			int(input('''Enter private key of A: '''))
            _SCREAMING_SNAKE_CASE							 =			pow(a, a_private, q)
            _SCREAMING_SNAKE_CASE							 =			int(input('''Enter private key of B: '''))
            _SCREAMING_SNAKE_CASE							 =			pow(a, b_private, q)

            _SCREAMING_SNAKE_CASE							 =			pow(b_public, a_private, q)
            _SCREAMING_SNAKE_CASE							 =			pow(a_public, b_private, q)

            print('''The key value generated by A is: ''', a_secret)
            print('''The key value generated by B is: ''', b_secret)





