
'''simple docstring'''






import unittest

import numpy as np
import torch

from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device

from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()




class     __snake_case		(   a__    ,   unittest.TestCase):
					_lowerCAmelCase			     =	DDIMPipeline
					_lowerCAmelCase			     =	UNCONDITIONAL_IMAGE_GENERATION_PARAMS
					_lowerCAmelCase			     =	PipelineTesterMixin.required_optional_params - {
					    '''num_images_per_prompt''',
					    '''latents''',
					    '''callback''',
					    '''callback_steps''',
					}
					_lowerCAmelCase			     =	UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS
					_lowerCAmelCase			     =	False
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									torch.manual_seed(0      )
									lowerCamelCase					:			int									= UNetaDModel(
									    block_out_channels=(32, 64),    layers_per_block=2,    sample_size=32,    in_channels=3,    out_channels=3,    down_block_types=('DownBlock2D', 'AttnDownBlock2D'),    up_block_types=('AttnUpBlock2D', 'UpBlock2D'),    )
									lowerCamelCase					:			Any									= DDIMScheduler()
									lowerCamelCase					:			Optional[Any]									= {'unet': unet, 'scheduler': scheduler}
									return components
					def     UpperCAmelCase_							(     self,    A,    A=0      ):

									"""simple docstring"""


									if str(A      ).startswith('mps'      ):
													lowerCamelCase					:			Tuple									= torch.manual_seed(A      )
									else:
													lowerCamelCase					:			str									= torch.Generator(device=A      ).manual_seed(A      )
									lowerCamelCase					:			Dict									= {
									    'batch_size': 1,
									    'generator': generator,
									    'num_inference_steps': 2,
									    'output_type': 'numpy',
									}
									return inputs
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									lowerCamelCase					:			List[Any]									= 'cpu'

									lowerCamelCase					:			int									= self.get_dummy_components()
									lowerCamelCase					:			Optional[int]									= self.pipeline_class(**A      )
									pipe.to(A      )
									pipe.set_progress_bar_config(disable=A      )

									lowerCamelCase					:			List[str]									= self.get_dummy_inputs(A      )
									lowerCamelCase					:			Optional[Any]									= pipe(**A      ).images
									lowerCamelCase					:			str									= image[0, -3:, -3:, -1]

									self.assertEqual(image.shape,    (1, 32, 32, 3)      )
									lowerCamelCase					:			Any									= np.array(
									    [1.0_00e00, 5.7_17e-01, 4.7_17e-01, 1.0_00e00, 0.0_00e00, 1.0_00e00, 3.0_00e-04, 0.0_00e00, 9.0_00e-04]      )
									lowerCamelCase					:			Dict									= np.abs(image_slice.flatten() - expected_slice      ).max()
									self.assertLessEqual(A,    1e-3      )
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									super().test_dict_tuple_outputs_equivalent(expected_max_difference=3e-3      )
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									super().test_save_load_local(expected_max_difference=3e-3      )
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									super().test_save_load_optional_components(expected_max_difference=3e-3      )




					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									super().test_inference_batch_single_identical(expected_max_diff=3e-3      )





@slow
@require_torch_gpu
class     __snake_case		(   unittest.TestCase):
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									lowerCamelCase					:			int									= 'google/ddpm-cifar10-32'

									lowerCamelCase					:			List[str]									= UNetaDModel.from_pretrained(A      )
									lowerCamelCase					:			Any									= DDIMScheduler()

									lowerCamelCase					:			int									= DDIMPipeline(unet=A,    scheduler=A      )
									ddim.to(A      )
									ddim.set_progress_bar_config(disable=A      )

									lowerCamelCase					:			Tuple									= torch.manual_seed(0      )
									lowerCamelCase					:			Union[str, Any]									= ddim(generator=A,    eta=0.0,    output_type='numpy'      ).images

									lowerCamelCase					:			Tuple									= image[0, -3:, -3:, -1]

									assert image.shape == (1, 32, 32, 3)
									lowerCamelCase					:			Optional[int]									= np.array([0.1723, 0.1617, 0.1600, 0.1626, 0.1497, 0.1513, 0.1505, 0.1442, 0.1453]      )

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




					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									lowerCamelCase					:			Optional[Any]									= 'google/ddpm-ema-bedroom-256'

									lowerCamelCase					:			int									= UNetaDModel.from_pretrained(A      )
									lowerCamelCase					:			str									= DDIMScheduler.from_pretrained(A      )

									lowerCamelCase					:			Optional[int]									= DDIMPipeline(unet=A,    scheduler=A      )
									ddpm.to(A      )
									ddpm.set_progress_bar_config(disable=A      )

									lowerCamelCase					:			Optional[int]									= torch.manual_seed(0      )
									lowerCamelCase					:			Any									= ddpm(generator=A,    output_type='numpy'      ).images

									lowerCamelCase					:			Union[str, Any]									= image[0, -3:, -3:, -1]

									assert image.shape == (1, 256, 256, 3)
									lowerCamelCase					:			Any									= np.array([0.0060, 0.0201, 0.0344, 0.0024, 0.0018, 0.0002, 0.0022, 0.0000, 0.0069]      )

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


'''simple docstring'''






import requests
from bsa import BeautifulSoup





def    UpperCAmelCase							(  UpperCAmelCase__							:							str = "AAPL"):
				lowerCamelCase					:			List[Any]									= F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}'''
				lowerCamelCase					:			Dict									= BeautifulSoup(requests.get(UpperCAmelCase__).text       ,							'html.parser')
				lowerCamelCase					:			Dict									= 'My(6px) Pos(r) smartphone_Mt(6px)'
				return soup.find('div'       ,							class_=class_).find('span').text


if __name__ == "__main__":
					for symbol in "AAPL AMZN IBM GOOG MSFT ORCL".split():
										print(f"""Current {symbol:<4} stock price is {stock_price(symbol):>8}""")
