'''simple docstring'''




import argparse

import intel_extension_for_pytorch as ipex
import torch

from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline


__UpperCAmelCase												=	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")
__UpperCAmelCase												=	parser.parse_args()


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

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

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

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

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

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

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

'''simple docstring'''




from __future__ import annotations

from typing import Any






def __lowerCAmelCase			(							UpperCamelCase__    )     ->   None:
    create_state_space_tree(UpperCamelCase__    ,  []    ,  0    )






def __lowerCAmelCase			(							UpperCamelCase__    ,  UpperCamelCase__    ,  UpperCamelCase__    )     ->   None:

    if index == len(UpperCamelCase__    ):
        print(UpperCamelCase__    )
        return

    create_state_space_tree(UpperCamelCase__    ,  UpperCamelCase__    ,  index + 1    )
    current_subsequence.append(sequence[index]    )
    create_state_space_tree(UpperCamelCase__    ,  UpperCamelCase__    ,  index + 1    )
    current_subsequence.pop()


if __name__ == "__main__":
  __UpperCAmelCase												=[3, 1, 2, 4]
  generate_all_subsequences(seq)

  seq.clear()
  seq.extend(["A", "B", "C"])
  generate_all_subsequences(seq)
