
"""simple docstring"""




import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


UpperCAmelCase__      :    Dict    							= False



class 	lowerCAmelCase_						(unittest.TestCase  ):


				"""simple docstring"""



				pass






@nightly
@require_torch_gpu
class 	lowerCAmelCase_						(unittest.TestCase  ):


				"""simple docstring"""



				def 	__magic_name__    (self    )					->		int:



											"""simple docstring"""




											super().tearDown()
											gc.collect()
											torch.cuda.empty_cache()



				def 	__magic_name__    (self    )					->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       int           =   VersatileDiffusionPipeline.from_pretrained("""shi-labs/versatile-diffusion"""   ,       torch_dtype=torch.floataa    )
											pipe.to(A__    )
											pipe.set_progress_bar_config(disable=A__    )

											SCREAMING_SNAKE_CASE__						:       Union[str, Any]           =   load_image(
											    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"""    )

											SCREAMING_SNAKE_CASE__						:       Tuple           =   torch.manual_seed(0    )
											SCREAMING_SNAKE_CASE__						:       Optional[int]           =   pipe.dual_guided(
											    prompt="""first prompt"""   ,       image=A__   ,       text_to_image_strength=0.75   ,       generator=A__   ,       guidance_scale=7.5   ,       num_inference_steps=2   ,       output_type="""numpy"""   ,       ).images

											with tempfile.TemporaryDirectory() as tmpdirname:
																		pipe.save_pretrained(A__    )
																		SCREAMING_SNAKE_CASE__						:       str           =   VersatileDiffusionPipeline.from_pretrained(A__   ,       torch_dtype=torch.floataa    )
											pipe.to(A__    )
											pipe.set_progress_bar_config(disable=A__    )

											SCREAMING_SNAKE_CASE__						:       Any           =   generator.manual_seed(0    )
											SCREAMING_SNAKE_CASE__						:       Tuple           =   pipe.dual_guided(
											    prompt="""first prompt"""   ,       image=A__   ,       text_to_image_strength=0.75   ,       generator=A__   ,       guidance_scale=7.5   ,       num_inference_steps=2   ,       output_type="""numpy"""   ,       ).images

											assert np.abs(image - new_image    ).sum() < 1E-5, "Models don't have the same forward pass"



				def 	__magic_name__    (self    )					->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       Dict           =   VersatileDiffusionPipeline.from_pretrained("""shi-labs/versatile-diffusion"""   ,       torch_dtype=torch.floataa    )
											pipe.to(A__    )
											pipe.set_progress_bar_config(disable=A__    )

											SCREAMING_SNAKE_CASE__						:       Dict           =   """cyberpunk 2077"""
											SCREAMING_SNAKE_CASE__						:       Any           =   load_image(
											    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"""    )
											SCREAMING_SNAKE_CASE__						:       Union[str, Any]           =   torch.manual_seed(0    )
											SCREAMING_SNAKE_CASE__						:       List[str]           =   pipe.dual_guided(
											    prompt=A__   ,       image=A__   ,       text_to_image_strength=0.75   ,       generator=A__   ,       guidance_scale=7.5   ,       num_inference_steps=50   ,       output_type="""numpy"""   ,       ).images

											SCREAMING_SNAKE_CASE__						:       Tuple           =   image[0, 2_53:2_56, 2_53:2_56, -1]

											assert image.shape == (1, 5_12, 5_12, 3)
											SCREAMING_SNAKE_CASE__						:       List[Any]           =   np.array([0.1448, 0.1619, 0.1741, 0.1086, 0.1147, 0.1128, 0.1199, 0.1165, 0.1001]    )

											assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-1

											SCREAMING_SNAKE_CASE__						:       int           =   """A painting of a squirrel eating a burger """
											SCREAMING_SNAKE_CASE__						:       Dict           =   torch.manual_seed(0    )
											SCREAMING_SNAKE_CASE__						:       int           =   pipe.text_to_image(
											    prompt=A__   ,       generator=A__   ,       guidance_scale=7.5   ,       num_inference_steps=50   ,       output_type="""numpy"""    ).images

											SCREAMING_SNAKE_CASE__						:       Any           =   image[0, 2_53:2_56, 2_53:2_56, -1]

											assert image.shape == (1, 5_12, 5_12, 3)
											SCREAMING_SNAKE_CASE__						:       Dict           =   np.array([0.3367, 0.3169, 0.2656, 0.3870, 0.4790, 0.3796, 0.4009, 0.4878, 0.4778]    )

											assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-1

											SCREAMING_SNAKE_CASE__						:       int           =   pipe.image_variation(A__   ,       generator=A__   ,       output_type="""numpy"""    ).images

											SCREAMING_SNAKE_CASE__						:       str           =   image[0, 2_53:2_56, 2_53:2_56, -1]

											assert image.shape == (1, 5_12, 5_12, 3)
											SCREAMING_SNAKE_CASE__						:       List[Any]           =   np.array([0.3076, 0.3123, 0.3284, 0.3782, 0.3770, 0.3894, 0.4297, 0.4331, 0.4456]    )

											assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-1






import requests
from bsa import BeautifulSoup



def        UpperCamelCase    (							lowerCAmelCase__ = "https://www.worldometers.info/coronavirus"		):
					'''simple docstring'''
					lowercase							=						BeautifulSoup(requests.get(lowerCAmelCase__		).text ,			'''html.parser'''		)
					lowercase							=						soup.findAll('''h1'''		)
					lowercase							=						soup.findAll('''div''' ,			{'''class''': '''maincounter-number'''}		)
					keys += soup.findAll('''span''' ,			{'''class''': '''panel-title'''}		)
					values += soup.findAll('''div''' ,			{'''class''': '''number-table-main'''}		)
					return {key.text.strip(): value.text.strip() for key, value in zip(lowerCAmelCase__ ,			lowerCAmelCase__		)}


if __name__ == "__main__":
							print("\033[1m" + "COVID-19 Status of the World" + "\033[0m\n")
							for key, value in world_covidaa_stats().items():
														print(F'{key}\n{value}\n')




