


'''simple docstring'''
import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers.testing_utils import require_vision
from transformers.utils import is_vision_available


if is_vision_available():
		from PIL import Image

		from transformers import (
		    AutoProcessor,
		    BertTokenizerFast,
		    BlipImageProcessor,
		    GPTaTokenizer,
		    InstructBlipProcessor,
		    PreTrainedTokenizerFast,
		)
@require_vision
class   lowercase      (				unittest.TestCase   ):

		"""simple docstring"""

		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :str				   =					tempfile.mkdtemp()

							UpperCamelCase__  :Optional[Any]				   =					BlipImageProcessor()
							UpperCamelCase__  :Optional[Any]				   =					GPTaTokenizer.from_pretrained('''hf-internal-testing/tiny-random-GPT2Model'''				)
							UpperCamelCase__  :Tuple				   =					BertTokenizerFast.from_pretrained('''hf-internal-testing/tiny-random-bert'''				)

							UpperCamelCase__  :List[str]				   =					InstructBlipProcessor(UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				)

							processor.save_pretrained(self.tmpdirname				)




		def        lowerCAmelCase__							(						self       ,  **UpperCamelCase_				):

							'''simple docstring'''


							return AutoProcessor.from_pretrained(self.tmpdirname       ,  **UpperCamelCase_				).tokenizer




		def        lowerCAmelCase__							(						self       ,  **UpperCamelCase_				):

							'''simple docstring'''


							return AutoProcessor.from_pretrained(self.tmpdirname       ,  **UpperCamelCase_				).image_processor




		def        lowerCAmelCase__							(						self       ,  **UpperCamelCase_				):

							'''simple docstring'''


							return AutoProcessor.from_pretrained(self.tmpdirname       ,  **UpperCamelCase_				).qformer_tokenizer




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							shutil.rmtree(self.tmpdirname				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[str]				   =					[np.random.randint(255       ,  size=(3, 30, 400)       ,  dtype=np.uinta				)]

							UpperCamelCase__  :Any				   =					[Image.fromarray(np.moveaxis(UpperCamelCase_       ,  0       ,  -1				)				) for x in image_inputs]

							return image_inputs




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[str]				   =					InstructBlipProcessor(
							    tokenizer=self.get_tokenizer()       ,  image_processor=self.get_image_processor()       ,  qformer_tokenizer=self.get_qformer_tokenizer()       ,  )
							processor.save_pretrained(self.tmpdirname				)

							UpperCamelCase__  :int				   =					self.get_tokenizer(bos_token='''(BOS)'''       ,  eos_token='''(EOS)'''				)
							UpperCamelCase__  :Union[str, Any]				   =					self.get_image_processor(do_normalize=UpperCamelCase_       ,  padding_value=1.0				)

							UpperCamelCase__  :Dict				   =					InstructBlipProcessor.from_pretrained(
							    self.tmpdirname       ,  bos_token='''(BOS)'''       ,  eos_token='''(EOS)'''       ,  do_normalize=UpperCamelCase_       ,  padding_value=1.0				)

							self.assertEqual(processor.tokenizer.get_vocab()       ,  tokenizer_add_kwargs.get_vocab()				)
							self.assertIsInstance(processor.tokenizer       ,  UpperCamelCase_				)

							self.assertEqual(processor.image_processor.to_json_string()       ,  image_processor_add_kwargs.to_json_string()				)
							self.assertIsInstance(processor.image_processor       ,  UpperCamelCase_				)
							self.assertIsInstance(processor.qformer_tokenizer       ,  UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :int				   =					self.get_image_processor()
							UpperCamelCase__  :List[str]				   =					self.get_tokenizer()
							UpperCamelCase__  :Tuple				   =					self.get_qformer_tokenizer()

							UpperCamelCase__  :Optional[Any]				   =					InstructBlipProcessor(
							    tokenizer=UpperCamelCase_       ,  image_processor=UpperCamelCase_       ,  qformer_tokenizer=UpperCamelCase_				)

							UpperCamelCase__  :List[Any]				   =					self.prepare_image_inputs()

							UpperCamelCase__  :Tuple				   =					image_processor(UpperCamelCase_       ,  return_tensors='''np'''				)
							UpperCamelCase__  :int				   =					processor(images=UpperCamelCase_       ,  return_tensors='''np'''				)

							for key in input_feat_extract.keys():
												self.assertAlmostEqual(input_feat_extract[key].sum()       ,  input_processor[key].sum()       ,  delta=1e-2				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Union[str, Any]				   =					self.get_image_processor()
							UpperCamelCase__  :Tuple				   =					self.get_tokenizer()
							UpperCamelCase__  :Optional[Any]				   =					self.get_qformer_tokenizer()

							UpperCamelCase__  :Dict				   =					InstructBlipProcessor(
							    tokenizer=UpperCamelCase_       ,  image_processor=UpperCamelCase_       ,  qformer_tokenizer=UpperCamelCase_				)

							UpperCamelCase__  :List[Any]				   =					'''lower newer'''

							UpperCamelCase__  :Optional[int]				   =					processor(text=UpperCamelCase_				)

							UpperCamelCase__  :List[str]				   =					tokenizer(UpperCamelCase_       ,  return_token_type_ids=UpperCamelCase_				)
							UpperCamelCase__  :Dict				   =					qformer_tokenizer(UpperCamelCase_       ,  return_token_type_ids=UpperCamelCase_				)

							for key in encoded_tokens.keys():
												self.assertListEqual(encoded_tokens[key]       ,  encoded_processor[key]				)

							for key in encoded_tokens_qformer.keys():
												self.assertListEqual(encoded_tokens_qformer[key]       ,  encoded_processor['''qformer_''' + key]				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[str]				   =					self.get_image_processor()
							UpperCamelCase__  :List[Any]				   =					self.get_tokenizer()
							UpperCamelCase__  :Any				   =					self.get_qformer_tokenizer()

							UpperCamelCase__  :List[str]				   =					InstructBlipProcessor(
							    tokenizer=UpperCamelCase_       ,  image_processor=UpperCamelCase_       ,  qformer_tokenizer=UpperCamelCase_				)

							UpperCamelCase__  :Any				   =					'''lower newer'''
							UpperCamelCase__  :str				   =					self.prepare_image_inputs()

							UpperCamelCase__  :int				   =					processor(text=UpperCamelCase_       ,  images=UpperCamelCase_				)

							self.assertListEqual(
							    list(inputs.keys()				)       ,  ['''input_ids''', '''attention_mask''', '''qformer_input_ids''', '''qformer_attention_mask''', '''pixel_values''']       ,  )

							# test if it raises when no input is passed
							with pytest.raises(UpperCamelCase_				):
												processor()




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[str]				   =					self.get_image_processor()
							UpperCamelCase__  :List[Any]				   =					self.get_tokenizer()
							UpperCamelCase__  :Tuple				   =					self.get_qformer_tokenizer()

							UpperCamelCase__  :Dict				   =					InstructBlipProcessor(
							    tokenizer=UpperCamelCase_       ,  image_processor=UpperCamelCase_       ,  qformer_tokenizer=UpperCamelCase_				)

							UpperCamelCase__  :Union[str, Any]				   =					[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

							UpperCamelCase__  :Optional[Any]				   =					processor.batch_decode(UpperCamelCase_				)
							UpperCamelCase__  :Any				   =					tokenizer.batch_decode(UpperCamelCase_				)

							self.assertListEqual(UpperCamelCase_       ,  UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Union[str, Any]				   =					self.get_image_processor()
							UpperCamelCase__  :Optional[int]				   =					self.get_tokenizer()
							UpperCamelCase__  :Dict				   =					self.get_qformer_tokenizer()

							UpperCamelCase__  :Dict				   =					InstructBlipProcessor(
							    tokenizer=UpperCamelCase_       ,  image_processor=UpperCamelCase_       ,  qformer_tokenizer=UpperCamelCase_				)

							UpperCamelCase__  :Optional[int]				   =					'''lower newer'''
							UpperCamelCase__  :List[Any]				   =					self.prepare_image_inputs()

							UpperCamelCase__  :Tuple				   =					processor(text=UpperCamelCase_       ,  images=UpperCamelCase_				)

							self.assertListEqual(
							    list(inputs.keys()				)       ,  ['''input_ids''', '''attention_mask''', '''qformer_input_ids''', '''qformer_attention_mask''', '''pixel_values''']       ,  )



'''simple docstring'''
import requests
from bsa import BeautifulSoup


def      a (     __a = "AAPL"  )    ->      str:



					'''simple docstring'''






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