
"""simple docstring"""

import argparse

import intel_extension_for_pytorch as ipex
import torch

from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline


_A						=			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')
_A						=			parser.parse_args()


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

_A						=			'path-to-your-trained-model'
_A						=			StableDiffusionPipeline.from_pretrained(model_id)
if args.dpm:
					_A						=			DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
_A						=			pipe.to(device)

# to channels last
_A						=			pipe.unet.to(memory_format=torch.channels_last)
_A						=			pipe.vae.to(memory_format=torch.channels_last)
_A						=			pipe.text_encoder.to(memory_format=torch.channels_last)
if pipe.requires_safety_checker:
					_A						=			pipe.safety_checker.to(memory_format=torch.channels_last)

# optimize with ipex
_A						=			torch.randn(2, 4, 6_4, 6_4)
_A						=			torch.rand(1) * 9_9_9
_A						=			torch.randn(2, 7_7, 7_6_8)
_A						=			(sample, timestep, encoder_hidden_status)
try:
					_A						=			ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True, sample_input=input_example)
except Exception:
					_A						=			ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True)
_A						=			ipex.optimize(pipe.vae.eval(), dtype=torch.bfloataa, inplace=True)
_A						=			ipex.optimize(pipe.text_encoder.eval(), dtype=torch.bfloataa, inplace=True)
if pipe.requires_safety_checker:
					_A						=			ipex.optimize(pipe.safety_checker.eval(), dtype=torch.bfloataa, inplace=True)

# compute
_A						=			6_6_6
_A						=			torch.Generator(device).manual_seed(seed)
_A						=			{'generator': generator}
if args.steps is not None:
					_A						=			args.steps

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

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








"""simple docstring"""

def 		UpperCAmelCase (		a_ = 1000      ):





		'''simple docstring'''


		lowerCamelCase					:      Dict          =   2**power
		lowerCamelCase					:      List[str]          =   str(a_      )
		lowerCamelCase					:      Dict          =   list(a_      )
		lowerCamelCase					:      Optional[Any]          =   0

		for i in list_num:
				sum_of_num += int(a_      )

		return sum_of_num


if __name__ == "__main__":
					_A						=			int(input('Enter the power of 2: ').strip())
					print('2 ^ ', power, ' = ', 2**power)
					_A						=			solution(power)
					print('Sum of the digits is: ', result)






