
"""simple docstring"""




import argparse

import intel_extension_for_pytorch as ipex
import torch

from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline


lowerCAmelCase__							=				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__							=				parser.parse_args()


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

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

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

# optimize with ipex
lowerCAmelCase__							=				torch.randn(2, 4, 64, 64)
lowerCAmelCase__							=				torch.rand(1) * 999
lowerCAmelCase__							=				torch.randn(2, 77, 768)
lowerCAmelCase__							=				(sample, timestep, encoder_hidden_status)
try:
						lowerCAmelCase__							=				ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True, sample_input=input_example)
except Exception:
						lowerCAmelCase__							=				ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True)
lowerCAmelCase__							=				ipex.optimize(pipe.vae.eval(), dtype=torch.bfloataa, inplace=True)
lowerCAmelCase__							=				ipex.optimize(pipe.text_encoder.eval(), dtype=torch.bfloataa, inplace=True)
if pipe.requires_safety_checker:
						lowerCAmelCase__							=				ipex.optimize(pipe.safety_checker.eval(), dtype=torch.bfloataa, inplace=True)

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

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

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

"""simple docstring"""




from __future__ import annotations



def        _lowerCamelCase ( __a,							__a    ):
		SCREAMING_SNAKE_CASE_						 = 0
		SCREAMING_SNAKE_CASE_						 = len(__a    ) - 1

		while i < j:
				if nums[i] + nums[j] == target:
						return [i, j]
				elif nums[i] + nums[j] < target:
						SCREAMING_SNAKE_CASE_						 = i + 1
				else:
						SCREAMING_SNAKE_CASE_						 = j - 1

		return []


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(f'''{two_pointer([2, 7, 11, 15], 9) = }''')