






'''simple docstring'''







import requests
from bsa import BeautifulSoup
def     A__      (					__lowerCAmelCase		:      str = "AAPL"    ):
						lowerCamelCase__								=	F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}'''
						lowerCamelCase__								=	BeautifulSoup(requests.get(__lowerCAmelCase    ).text ,     """html.parser"""    )
						lowerCamelCase__								=	"""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}')









import unittest

import numpy as np
import torch
from torch import nn
from transformers import (
    CLIPImageProcessor,
    CLIPTextConfig,
    CLIPTextModelWithProjection,
    CLIPTokenizer,
    CLIPVisionConfig,
    CLIPVisionModelWithProjection,
)

from diffusers import KandinskyVaaPriorPipeline, PriorTransformer, UnCLIPScheduler
from diffusers.utils import torch_device
from diffusers.utils.testing_utils import enable_full_determinism, skip_mps

from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()




class       snake_case__ (				lowercase_						,     unittest.TestCase):

       '''simple docstring'''
       lowerCamelCase				:					Tuple								=			KandinskyVaaPriorPipeline
       lowerCamelCase				:					Optional[Any]								=			["prompt"]
       lowerCamelCase				:					Any								=			["prompt", "negative_prompt"]
       lowerCamelCase				:					Tuple								=			[
           "num_images_per_prompt",
           "generator",
           "num_inference_steps",
           "latents",
           "negative_prompt",
           "guidance_scale",
           "output_type",
           "return_dict",
       ]
       lowerCamelCase				:					Any								=			False



       @property
       def        __lowercase    (				self     )			->   Union[str, Any]:






            '''simple docstring'''





            return 32



       @property
       def        __lowercase    (				self     )			->   Any:






            '''simple docstring'''





            return 32



       @property
       def        __lowercase    (				self     )			->   List[Any]:






            '''simple docstring'''





            return self.time_input_dim



       @property
       def        __lowercase    (				self     )			->   Optional[Any]:






            '''simple docstring'''





            return self.time_input_dim * 4



       @property
       def        __lowercase    (				self     )			->   Optional[Any]:






            '''simple docstring'''





            return 1_00



       @property
       def        __lowercase    (				self     )			->   Optional[Any]:






            '''simple docstring'''





            __snake_case      :Tuple 							=    CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""     )
            return tokenizer



       @property
       def        __lowercase    (				self     )			->   str:






            '''simple docstring'''





            torch.manual_seed(0     )
            __snake_case      :Dict 							=    CLIPTextConfig(
                bos_token_id=0      ,    eos_token_id=2      ,    hidden_size=self.text_embedder_hidden_size      ,    projection_dim=self.text_embedder_hidden_size      ,    intermediate_size=37      ,    layer_norm_eps=1e-05      ,    num_attention_heads=4      ,    num_hidden_layers=5      ,    pad_token_id=1      ,    vocab_size=10_00      ,    )
            return CLIPTextModelWithProjection(a__     )



       @property
       def        __lowercase    (				self     )			->   str:






            '''simple docstring'''





            torch.manual_seed(0     )

            __snake_case      :List[Any] 							=    {
                """num_attention_heads""": 2,
                """attention_head_dim""": 12,
                """embedding_dim""": self.text_embedder_hidden_size,
                """num_layers""": 1,
            }

            __snake_case      :Union[str, Any] 							=    PriorTransformer(**a__     )
            # clip_std and clip_mean is initialized to be 0 so PriorTransformer.post_process_latents will always return 0 - set clip_std to be 1 so it won't return 0
            __snake_case      :int 							=    nn.Parameter(torch.ones(model.clip_std.shape     )     )
            return model



       @property
       def        __lowercase    (				self     )			->   List[str]:






            '''simple docstring'''





            torch.manual_seed(0     )
            __snake_case      :List[Any] 							=    CLIPVisionConfig(
                hidden_size=self.text_embedder_hidden_size      ,    image_size=2_24      ,    projection_dim=self.text_embedder_hidden_size      ,    intermediate_size=37      ,    num_attention_heads=4      ,    num_channels=3      ,    num_hidden_layers=5      ,    patch_size=14      ,    )

            __snake_case      :Tuple 							=    CLIPVisionModelWithProjection(a__     )
            return model



       @property
       def        __lowercase    (				self     )			->   Optional[Any]:






            '''simple docstring'''





            __snake_case      :Optional[int] 							=    CLIPImageProcessor(
                crop_size=2_24      ,    do_center_crop=a__      ,    do_normalize=a__      ,    do_resize=a__      ,    image_mean=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]      ,    image_std=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]      ,    resample=3      ,    size=2_24      ,    )

            return image_processor



       def        __lowercase    (				self     )			->   Optional[Any]:






            '''simple docstring'''





            __snake_case      :Optional[Any] 							=    self.dummy_prior
            __snake_case      :Tuple 							=    self.dummy_image_encoder
            __snake_case      :List[Any] 							=    self.dummy_text_encoder
            __snake_case      :List[str] 							=    self.dummy_tokenizer
            __snake_case      :int 							=    self.dummy_image_processor

            __snake_case      :Union[str, Any] 							=    UnCLIPScheduler(
                variance_type="""fixed_small_log"""      ,    prediction_type="""sample"""      ,    num_train_timesteps=10_00      ,    clip_sample=a__      ,    clip_sample_range=10.0      ,    )

            __snake_case      :Union[str, Any] 							=    {
                """prior""": prior,
                """image_encoder""": image_encoder,
                """text_encoder""": text_encoder,
                """tokenizer""": tokenizer,
                """scheduler""": scheduler,
                """image_processor""": image_processor,
            }

            return components



       def        __lowercase    (				self      ,    a__      ,    a__=0     )			->   Optional[Any]:






            '''simple docstring'''





            if str(a__     ).startswith("""mps"""     ):
                 __snake_case      :Any 							=    torch.manual_seed(a__     )
            else:
                 __snake_case      :Any 							=    torch.Generator(device=a__     ).manual_seed(a__     )
            __snake_case      :Union[str, Any] 							=    {
                """prompt""": """horse""",
                """generator""": generator,
                """guidance_scale""": 4.0,
                """num_inference_steps""": 2,
                """output_type""": """np""",
            }
            return inputs



       def        __lowercase    (				self     )			->   List[str]:






            '''simple docstring'''





            __snake_case      :str 							=    """cpu"""

            __snake_case      :Optional[Any] 							=    self.get_dummy_components()

            __snake_case      :List[Any] 							=    self.pipeline_class(**a__     )
            __snake_case      :Union[str, Any] 							=    pipe.to(a__     )

            pipe.set_progress_bar_config(disable=a__     )

            __snake_case      :List[Any] 							=    pipe(**self.get_dummy_inputs(a__     )     )
            __snake_case      :Any 							=    output.image_embeds

            __snake_case      :Any 							=    pipe(
                **self.get_dummy_inputs(a__     )      ,    return_dict=a__      ,    )[0]

            __snake_case      :Any 							=    image[0, -10:]
            __snake_case      :Any 							=    image_from_tuple[0, -10:]

            assert image.shape == (1, 32)

            __snake_case      :List[str] 							=    np.array(
                [-0.05_32, 1.71_20, 0.36_56, -1.08_52, -0.89_46, -1.17_56, 0.43_48, 0.24_82, 0.51_46, -0.11_56]     )

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



       @skip_mps
       def        __lowercase    (				self     )			->   str:






            '''simple docstring'''





            __snake_case      :List[Any] 							=    torch_device == """cpu"""
            __snake_case      :List[str] 							=    True
            __snake_case      :Optional[Any] 							=    False

            self._test_inference_batch_single_identical(
                test_max_difference=a__      ,    relax_max_difference=a__      ,    test_mean_pixel_difference=a__      ,    )



       @skip_mps
       def        __lowercase    (				self     )			->   List[Any]:






            '''simple docstring'''





            __snake_case      :Any 							=    torch_device == """cpu"""
            __snake_case      :str 							=    False

            self._test_attention_slicing_forward_pass(
                test_max_difference=a__      ,    test_mean_pixel_difference=a__      ,    )


