


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






import csv

import tweepy

# Twitter API credentials
__a  :     Union[str, Any]       =  """"""
__a  :     Union[str, Any]       =  """"""
__a  :     Union[str, Any]       =  """"""
__a  :     List[Any]       =  """"""





def 				UpperCAmelCase						(    lowercase							):







				"""simple docstring"""



				__lowercase 			=							tweepy.OAuthHandler(lowercase							,			lowercase							)
				auth.set_access_token(lowercase							,			lowercase							)
				__lowercase 			=							tweepy.API(lowercase							)

				# initialize a list to hold all the tweepy Tweets
				__lowercase 			=							[]

				# make initial request for most recent tweets (200 is the maximum allowed count)
				__lowercase 			=							api.user_timeline(screen_name=lowercase							,			count=200							)

				# save most recent tweets
				alltweets.extend(lowercase							)

				# save the id of the oldest tweet less one
				__lowercase 			=							alltweets[-1].id - 1

				# keep grabbing tweets until there are no tweets left to grab
				while len(lowercase							) > 0:
								print(F"getting tweets before {oldest}"							)

								# all subsequent requests use the max_id param to prevent duplicates
								__lowercase 			=							api.user_timeline(
								    screen_name=lowercase							,			count=200							,			max_id=lowercase							)

								# save most recent tweets
								alltweets.extend(lowercase							)

								# update the id of the oldest tweet less one
								__lowercase 			=							alltweets[-1].id - 1

								print(F"...{len(lowercase							)} tweets downloaded so far"							)

				# transform the tweepy tweets into a 2D array that will populate the csv
				__lowercase 			=							[[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets]

				# write the csv
				with open(F"new_{screen_name}_tweets.csv"							,			'''w'''							) as f:
								__lowercase 			=							csv.writer(lowercase							)
								writer.writerow(['''id''', '''created_at''', '''text''']							)
								writer.writerows(lowercase							)


if __name__ == "__main__":
		# pass in the username of the account you want to download
		get_all_tweets("""FirePing32""")