






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')













from __future__ import annotations

from collections.abc import Generator

import requests
from bsa import BeautifulSoup

lowerCAmelCase_           = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l='







def      snake_case		(							UpperCAmelCase	:       str = "mumbai"   ):
				A	 =      BeautifulSoup(requests.get(url + location   ).content,						'html.parser'   )
				# This attribute finds out all the specifics listed in a job
				for job in soup.find_all('div',						attrs={'data-tn-component': 'organicJob'}   ):
								A	 =      job.find('a',						attrs={'data-tn-element': 'jobTitle'}   ).text.strip()
								A	 =      job.find('span',						{'class': 'company'}   ).text.strip()
								yield job_title, company_name


if __name__ == "__main__":
					for i, job in enumerate(fetch_jobs('Bangalore'), 1):
										print(f'''Job {i:>2} is {job[0]} at {job[1]}''')





