



import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
							import torch

if is_vision_available():
							from PIL import Image

							from transformers import ChineseCLIPImageProcessor


class   __lowerCAmelCase  (		unittest.TestCase   ):
					"""simple docstring"""






					def __init__(  self       :							Tuple					,       _snake_case       :							List[str]					,       _snake_case       :							Union[str, Any]=7					,       _snake_case       :							Any=3					,       _snake_case       :							List[Any]=18					,       _snake_case       :							Union[str, Any]=30					,       _snake_case       :							Optional[int]=4_00					,       _snake_case       :							Union[str, Any]=True					,       _snake_case       :							str=None					,       _snake_case       :							List[str]=True					,       _snake_case       :							str=None					,       _snake_case       :							Union[str, Any]=True					,       _snake_case       :							List[str]=[0.4814_5466, 0.457_8275, 0.4082_1073]					,       _snake_case       :							List[Any]=[0.2686_2954, 0.2613_0258, 0.2757_7711]					,       _snake_case       :							Tuple=True					,       ):






								"""simple docstring"""


								A__	  =     size if size is not None else {'height': 2_24, 'width': 2_24}
								A__	  =     crop_size if crop_size is not None else {'height': 18, 'width': 18}
								A__	  =     parent
								A__	  =     batch_size
								A__	  =     num_channels
								A__	  =     image_size
								A__	  =     min_resolution
								A__	  =     max_resolution
								A__	  =     do_resize
								A__	  =     size
								A__	  =     do_center_crop
								A__	  =     crop_size
								A__	  =     do_normalize
								A__	  =     image_mean
								A__	  =     image_std
								A__	  =     do_convert_rgb



					def      _a				(  self       :							int       ):






								"""simple docstring"""


								return {
								    "do_resize": self.do_resize,
								    "size": self.size,
								    "do_center_crop": self.do_center_crop,
								    "crop_size": self.crop_size,
								    "do_normalize": self.do_normalize,
								    "image_mean": self.image_mean,
								    "image_std": self.image_std,
								    "do_convert_rgb": self.do_convert_rgb,
								}



					def      _a				(  self       :							Any					,       _snake_case       :							Optional[int]=False					,       _snake_case       :							str=False					,       _snake_case       :							Optional[Any]=False       ):






								"""simple docstring"""


								assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

								if equal_resolution:
											A__	  =     []
											for i in range(self.batch_size       ):
														image_inputs.append(
														    np.random.randint(
														        2_55					,       size=(self.num_channels, self.max_resolution, self.max_resolution)					,       dtype=np.uinta       )       )
								else:
											A__	  =     []
											for i in range(self.batch_size       ):
														A__  ,			A__	  =     np.random.choice(np.arange(self.min_resolution					,       self.max_resolution       )					,       2       )
														image_inputs.append(np.random.randint(2_55					,       size=(self.num_channels, width, height)					,       dtype=np.uinta       )       )

								if not numpify and not torchify:
											# PIL expects the channel dimension as last dimension
											A__	  =     [Image.fromarray(np.moveaxis(_snake_case					,       0					,       -1       )       ) for x in image_inputs]

								if torchify:
											A__	  =     [torch.from_numpy(_snake_case       ) for x in image_inputs]

								return image_inputs







@require_torch
@require_vision
class   __lowerCAmelCase  (		UpperCAmelCase_				,  unittest.TestCase   ):
					"""simple docstring"""






					A__					:		Dict      							=     ChineseCLIPImageProcessor if is_vision_available() else None



					def      _a				(  self       :							Optional[int]       ):






								"""simple docstring"""


								A__	  =     ChineseCLIPImageProcessingTester(self					,       do_center_crop=_snake_case       )



					@property
					def      _a				(  self       :							str       ):






								"""simple docstring"""


								return self.image_processor_tester.prepare_image_processor_dict()



					def      _a				(  self       :							Optional[int]       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class(**self.image_processor_dict       )
								self.assertTrue(hasattr(_snake_case					,       'do_resize'       )       )
								self.assertTrue(hasattr(_snake_case					,       'size'       )       )
								self.assertTrue(hasattr(_snake_case					,       'do_center_crop'       )       )
								self.assertTrue(hasattr(_snake_case					,       'center_crop'       )       )
								self.assertTrue(hasattr(_snake_case					,       'do_normalize'       )       )
								self.assertTrue(hasattr(_snake_case					,       'image_mean'       )       )
								self.assertTrue(hasattr(_snake_case					,       'image_std'       )       )
								self.assertTrue(hasattr(_snake_case					,       'do_convert_rgb'       )       )



					def      _a				(  self       :							Any       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class.from_dict(self.image_processor_dict       )
								self.assertEqual(image_processor.size					,       {'height': 2_24, 'width': 2_24}       )
								self.assertEqual(image_processor.crop_size					,       {'height': 18, 'width': 18}       )

								A__	  =     self.image_processing_class.from_dict(self.image_processor_dict					,       size=42					,       crop_size=84       )
								self.assertEqual(image_processor.size					,       {'shortest_edge': 42}       )
								self.assertEqual(image_processor.crop_size					,       {'height': 84, 'width': 84}       )



					def      _a				(  self       :							Tuple       ):






								"""simple docstring"""


								pass



					def      _a				(  self       :							int       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class(**self.image_processor_dict       )
								# create random PIL images
								A__	  =     self.image_processor_tester.prepare_inputs(equal_resolution=_snake_case       )
								for image in image_inputs:
											self.assertIsInstance(_snake_case					,       Image.Image       )

								# Test not batched input
								A__	  =     image_processing(image_inputs[0]					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )

								# Test batched
								A__	  =     image_processing(_snake_case					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )



					def      _a				(  self       :							Tuple       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class(**self.image_processor_dict       )
								# create random numpy tensors
								A__	  =     self.image_processor_tester.prepare_inputs(equal_resolution=_snake_case					,       numpify=_snake_case       )
								for image in image_inputs:
											self.assertIsInstance(_snake_case					,       np.ndarray       )

								# Test not batched input
								A__	  =     image_processing(image_inputs[0]					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )

								# Test batched
								A__	  =     image_processing(_snake_case					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )



					def      _a				(  self       :							Optional[int]       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class(**self.image_processor_dict       )
								# create random PyTorch tensors
								A__	  =     self.image_processor_tester.prepare_inputs(equal_resolution=_snake_case					,       torchify=_snake_case       )
								for image in image_inputs:
											self.assertIsInstance(_snake_case					,       torch.Tensor       )

								# Test not batched input
								A__	  =     image_processing(image_inputs[0]					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )

								# Test batched
								A__	  =     image_processing(_snake_case					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )







@require_torch
@require_vision
class   __lowerCAmelCase  (		UpperCAmelCase_				,  unittest.TestCase   ):
					"""simple docstring"""






					A__					:		Dict      							=     ChineseCLIPImageProcessor if is_vision_available() else None



					def      _a				(  self       :							Optional[int]       ):






								"""simple docstring"""


								A__	  =     ChineseCLIPImageProcessingTester(self					,       num_channels=4					,       do_center_crop=_snake_case       )
								A__	  =     3



					@property
					def      _a				(  self       :							Optional[int]       ):






								"""simple docstring"""


								return self.image_processor_tester.prepare_image_processor_dict()



					def      _a				(  self       :							List[str]       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class(**self.image_processor_dict       )
								self.assertTrue(hasattr(_snake_case					,       'do_resize'       )       )
								self.assertTrue(hasattr(_snake_case					,       'size'       )       )
								self.assertTrue(hasattr(_snake_case					,       'do_center_crop'       )       )
								self.assertTrue(hasattr(_snake_case					,       'center_crop'       )       )
								self.assertTrue(hasattr(_snake_case					,       'do_normalize'       )       )
								self.assertTrue(hasattr(_snake_case					,       'image_mean'       )       )
								self.assertTrue(hasattr(_snake_case					,       'image_std'       )       )
								self.assertTrue(hasattr(_snake_case					,       'do_convert_rgb'       )       )



					def      _a				(  self       :							str       ):






								"""simple docstring"""


								pass



					def      _a				(  self       :							str       ):






								"""simple docstring"""


								A__	  =     self.image_processing_class(**self.image_processor_dict       )
								# create random PIL images
								A__	  =     self.image_processor_tester.prepare_inputs(equal_resolution=_snake_case       )
								for image in image_inputs:
											self.assertIsInstance(_snake_case					,       Image.Image       )

								# Test not batched input
								A__	  =     image_processing(image_inputs[0]					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        1,
								        self.expected_encoded_image_num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )

								# Test batched
								A__	  =     image_processing(_snake_case					,       return_tensors='pt'       ).pixel_values
								self.assertEqual(
								    encoded_images.shape					,       (
								        self.image_processor_tester.batch_size,
								        self.expected_encoded_image_num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,       )








import requests
from bsa import BeautifulSoup





def 						_lowerCAmelCase							(     _lowerCAmelCase = "AAPL"			)    ->						str:


						'''simple docstring'''






						__snake_case				=		F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}'''
						__snake_case				=		BeautifulSoup(requests.get(_lowerCAmelCase			).text   ,						"html.parser"			)
						__snake_case				=		"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}''')





