
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


_A       =					logging.get_logger(__name__)  # pylint: disable=invalid-name





class      _lowerCAmelCase (     __a	):
				_lowercase      		=['''safety_checker''', '''feature_extractor''']




				def __init__( self    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase = True    ,    )    ->				Union[str, Any]:
							super().__init__()
							if hasattr(scheduler.config    ,    "steps_offset"					) and scheduler.config.steps_offset != 1:
										lowerCAmelCase_      =     (
										    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"    ,    _UpperCamelCase    ,    standard_warn=_UpperCamelCase					)
										lowerCAmelCase_      =     dict(scheduler.config					)
										lowerCAmelCase_      =     1
										lowerCAmelCase_      =     FrozenDict(_UpperCamelCase					)

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




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




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




				def 					__a						( self					)    ->				Dict:
							self.enable_attention_slicing(_UpperCamelCase					)




				@torch.no_grad()
				def 					__a						( self    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase = 0.8    ,    _UpperCamelCase = 50    ,    _UpperCamelCase = 7.5    ,    _UpperCamelCase = None    ,    _UpperCamelCase = 1    ,    _UpperCamelCase = 0.0    ,    _UpperCamelCase = None    ,    _UpperCamelCase = "pil"    ,    _UpperCamelCase = True    ,    _UpperCamelCase = None    ,    _UpperCamelCase = 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=_UpperCamelCase    ,    image=_UpperCamelCase    ,    mask_image=_UpperCamelCase    ,    strength=_UpperCamelCase    ,    num_inference_steps=_UpperCamelCase    ,    guidance_scale=_UpperCamelCase    ,    negative_prompt=_UpperCamelCase    ,    num_images_per_prompt=_UpperCamelCase    ,    eta=_UpperCamelCase    ,    generator=_UpperCamelCase    ,    output_type=_UpperCamelCase    ,    return_dict=_UpperCamelCase    ,    callback=_UpperCamelCase    ,    )




				@torch.no_grad()
				def 					__a						( self    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase = 0.8    ,    _UpperCamelCase = 50    ,    _UpperCamelCase = 7.5    ,    _UpperCamelCase = None    ,    _UpperCamelCase = 1    ,    _UpperCamelCase = 0.0    ,    _UpperCamelCase = None    ,    _UpperCamelCase = "pil"    ,    _UpperCamelCase = True    ,    _UpperCamelCase = None    ,    _UpperCamelCase = 1    ,    **_UpperCamelCase    ,    )    ->				Optional[Any]:
							# 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=_UpperCamelCase    ,    image=_UpperCamelCase    ,    strength=_UpperCamelCase    ,    num_inference_steps=_UpperCamelCase    ,    guidance_scale=_UpperCamelCase    ,    negative_prompt=_UpperCamelCase    ,    num_images_per_prompt=_UpperCamelCase    ,    eta=_UpperCamelCase    ,    generator=_UpperCamelCase    ,    output_type=_UpperCamelCase    ,    return_dict=_UpperCamelCase    ,    callback=_UpperCamelCase    ,    callback_steps=_UpperCamelCase    ,    )




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





import math






def        lowerCamelCase__    (    __lowerCAmelCase  :  int    ):




			"""simple docstring"""


			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5   ,							int(math.sqrt(__lowerCAmelCase    ) + 1    )   ,							6    ):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True






def        lowerCamelCase__    (    __lowerCAmelCase  :  int = 600851475143    ):




			"""simple docstring"""


			try:
						lowerCAmelCase_      =     int(__lowerCAmelCase    )
			except (TypeError, ValueError):
						raise TypeError("Parameter n must be int or castable to int."    )
			if n <= 0:
						raise ValueError("Parameter n must be greater than or equal to one."    )
			lowerCAmelCase_      =     0
			if is_prime(__lowerCAmelCase    ):
						return n
			while n % 2 == 0:
						n //= 2
			if is_prime(__lowerCAmelCase    ):
						return n
			for i in range(3   ,							int(math.sqrt(__lowerCAmelCase    )    ) + 1   ,							2    ):
						if n % i == 0:
									if is_prime(n // i    ):
												lowerCAmelCase_      =     n // i
												break
									elif is_prime(__lowerCAmelCase    ):
												lowerCAmelCase_      =     i
			return max_number


if __name__ == "__main__":
			print(f"""{solution() = }""")



