






import argparse

import intel_extension_for_pytorch as ipex
import torch

from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline


lowerCamelCase     :							Optional[int]    =argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False)
parser.add_argument('''--dpm''', action='''store_true''', help='''Enable DPMSolver or not''')
parser.add_argument('''--steps''', default=None, type=int, help='''Num inference steps''')
lowerCamelCase     :							Optional[int]    =parser.parse_args()


lowerCamelCase     :							Any    ='''cpu'''
lowerCamelCase     :							str    ='''a lovely <dicoo> in red dress and hat, in the snowly and brightly night, with many brighly buildings'''

lowerCamelCase     :							int    ='''path-to-your-trained-model'''
lowerCamelCase     :							List[Any]    =StableDiffusionPipeline.from_pretrained(model_id)
if args.dpm:
 lowerCamelCase     :							Union[str, Any]    =DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
lowerCamelCase     :							Optional[Any]    =pipe.to(device)

# to channels last
lowerCamelCase     :							Optional[int]    =pipe.unet.to(memory_format=torch.channels_last)
lowerCamelCase     :							Union[str, Any]    =pipe.vae.to(memory_format=torch.channels_last)
lowerCamelCase     :							Any    =pipe.text_encoder.to(memory_format=torch.channels_last)
if pipe.requires_safety_checker:
 lowerCamelCase     :							List[Any]    =pipe.safety_checker.to(memory_format=torch.channels_last)

# optimize with ipex
lowerCamelCase     :							List[Any]    =torch.randn(2, 4, 64, 64)
lowerCamelCase     :							Union[str, Any]    =torch.rand(1) * 999
lowerCamelCase     :							Tuple    =torch.randn(2, 77, 768)
lowerCamelCase     :							Optional[int]    =(sample, timestep, encoder_hidden_status)
try:
 lowerCamelCase     :							Tuple    =ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True, sample_input=input_example)
except Exception:
 lowerCamelCase     :							Union[str, Any]    =ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True)
lowerCamelCase     :							int    =ipex.optimize(pipe.vae.eval(), dtype=torch.bfloataa, inplace=True)
lowerCamelCase     :							str    =ipex.optimize(pipe.text_encoder.eval(), dtype=torch.bfloataa, inplace=True)
if pipe.requires_safety_checker:
 lowerCamelCase     :							Any    =ipex.optimize(pipe.safety_checker.eval(), dtype=torch.bfloataa, inplace=True)

# compute
lowerCamelCase     :							Dict    =666
lowerCamelCase     :							Union[str, Any]    =torch.Generator(device).manual_seed(seed)
lowerCamelCase     :							str    ={'''generator''': generator}
if args.steps is not None:
 lowerCamelCase     :							Optional[int]    =args.steps

with torch.cpu.amp.autocast(enabled=True, dtype=torch.bfloataa):
 lowerCamelCase     :							str    =pipe(prompt, **generate_kwargs).images[0]

# save image
image.save('''generated.png''')







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase      )			->     int:
     UpperCamelCase__      :       int	    =  1
     for i in range(1 ,   num + 1      ):
          fact *= i
     return fact







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase      )			->     int:
     UpperCamelCase__      :       List[Any]	    =  0
     while number > 0:
          UpperCamelCase__      :       List[Any]	    =  number % 10
          sum_of_digits += last_digit
          UpperCamelCase__      :       int	    =  number // 10  # Removing the last_digit from the given number
     return sum_of_digits







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase = 100      )			->     int:
     UpperCamelCase__      :       Optional[Any]	    =  factorial(__lowerCAmelCase      )
     UpperCamelCase__      :       Optional[int]	    =  split_and_add(__lowerCAmelCase      )
     return result


if __name__ == "__main__":
 print(solution(int(input('''Enter the Number: ''').strip())))