


'''simple docstring'''
import unittest

from transformers import MraConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_torch_available():
		import torch

		from transformers import (
		    MraForMaskedLM,
		    MraForMultipleChoice,
		    MraForQuestionAnswering,
		    MraForSequenceClassification,
		    MraForTokenClassification,
		    MraModel,
		)
		from transformers.models.mra.modeling_mra import MRA_PRETRAINED_MODEL_ARCHIVE_LIST
class   lowercase      :

		"""simple docstring"""

		def __init__(						self       ,  UpperCamelCase_       ,  UpperCamelCase_=2       ,  UpperCamelCase_=8       ,  UpperCamelCase_=True       ,  UpperCamelCase_=True       ,  UpperCamelCase_=True       ,  UpperCamelCase_=True       ,  UpperCamelCase_=99       ,  UpperCamelCase_=16       ,  UpperCamelCase_=5       ,  UpperCamelCase_=2       ,  UpperCamelCase_=36       ,  UpperCamelCase_="gelu"       ,  UpperCamelCase_=0.0       ,  UpperCamelCase_=0.0       ,  UpperCamelCase_=512       ,  UpperCamelCase_=16       ,  UpperCamelCase_=2       ,  UpperCamelCase_=0.02       ,  UpperCamelCase_=3       ,  UpperCamelCase_=4       ,  UpperCamelCase_=None       ,  ):

							'''simple docstring'''


							UpperCamelCase__  :Dict				   =					parent
							UpperCamelCase__  :Union[str, Any]				   =					batch_size
							UpperCamelCase__  :Union[str, Any]				   =					seq_length
							UpperCamelCase__  :Union[str, Any]				   =					is_training
							UpperCamelCase__  :Tuple				   =					use_input_mask
							UpperCamelCase__  :Dict				   =					use_token_type_ids
							UpperCamelCase__  :Optional[Any]				   =					use_labels
							UpperCamelCase__  :Tuple				   =					vocab_size
							UpperCamelCase__  :int				   =					hidden_size
							UpperCamelCase__  :Dict				   =					num_hidden_layers
							UpperCamelCase__  :Optional[int]				   =					num_attention_heads
							UpperCamelCase__  :List[Any]				   =					intermediate_size
							UpperCamelCase__  :int				   =					hidden_act
							UpperCamelCase__  :List[str]				   =					hidden_dropout_prob
							UpperCamelCase__  :int				   =					attention_probs_dropout_prob
							UpperCamelCase__  :Tuple				   =					max_position_embeddings
							UpperCamelCase__  :Tuple				   =					type_vocab_size
							UpperCamelCase__  :Any				   =					type_sequence_label_size
							UpperCamelCase__  :Tuple				   =					initializer_range
							UpperCamelCase__  :Any				   =					num_labels
							UpperCamelCase__  :int				   =					num_choices
							UpperCamelCase__  :List[Any]				   =					scope




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Dict				   =					ids_tensor([self.batch_size, self.seq_length]       ,  self.vocab_size				)

							UpperCamelCase__  :Optional[Any]				   =					None
							if self.use_input_mask:
												UpperCamelCase__  :Any				   =					random_attention_mask([self.batch_size, self.seq_length]				)

							UpperCamelCase__  :List[Any]				   =					None
							if self.use_token_type_ids:
												UpperCamelCase__  :List[str]				   =					ids_tensor([self.batch_size, self.seq_length]       ,  self.type_vocab_size				)

							UpperCamelCase__  :Dict				   =					None
							UpperCamelCase__  :Tuple				   =					None
							UpperCamelCase__  :Optional[Any]				   =					None
							if self.use_labels:
												UpperCamelCase__  :Optional[int]				   =					ids_tensor([self.batch_size]       ,  self.type_sequence_label_size				)
												UpperCamelCase__  :Any				   =					ids_tensor([self.batch_size, self.seq_length]       ,  self.num_labels				)
												UpperCamelCase__  :Tuple				   =					ids_tensor([self.batch_size]       ,  self.num_choices				)

							UpperCamelCase__  :Tuple				   =					self.get_config()

							return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							return MraConfig(
							    vocab_size=self.vocab_size       ,  hidden_size=self.hidden_size       ,  num_hidden_layers=self.num_hidden_layers       ,  num_attention_heads=self.num_attention_heads       ,  intermediate_size=self.intermediate_size       ,  hidden_act=self.hidden_act       ,  hidden_dropout_prob=self.hidden_dropout_prob       ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,  max_position_embeddings=self.max_position_embeddings       ,  type_vocab_size=self.type_vocab_size       ,  is_decoder=UpperCamelCase_       ,  initializer_range=self.initializer_range       ,  )




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Tuple				   =					self.get_config()
							UpperCamelCase__  :Union[str, Any]				   =					300
							return config




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							(
							    (
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							
							)  :Tuple				   =					self.prepare_config_and_inputs()

							UpperCamelCase__  :Union[str, Any]				   =					True
							UpperCamelCase__  :List[Any]				   =					floats_tensor([self.batch_size, self.seq_length, self.hidden_size]				)
							UpperCamelCase__  :str				   =					ids_tensor([self.batch_size, self.seq_length]       ,  vocab_size=2				)

							return (
							    config,
							    input_ids,
							    token_type_ids,
							    input_mask,
							    sequence_labels,
							    token_labels,
							    choice_labels,
							    encoder_hidden_states,
							    encoder_attention_mask,
							)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :Tuple				   =					MraModel(config=UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :Tuple				   =					model(UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_				)
							UpperCamelCase__  :Tuple				   =					model(UpperCamelCase_       ,  token_type_ids=UpperCamelCase_				)
							UpperCamelCase__  :int				   =					model(UpperCamelCase_				)
							self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, self.seq_length, self.hidden_size)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  ):

							'''simple docstring'''


							UpperCamelCase__  :Optional[int]				   =					True
							UpperCamelCase__  :List[str]				   =					MraModel(UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :int				   =					model(
							    UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  encoder_hidden_states=UpperCamelCase_       ,  encoder_attention_mask=UpperCamelCase_       ,  )
							UpperCamelCase__  :Optional[Any]				   =					model(
							    UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  encoder_hidden_states=UpperCamelCase_       ,  )
							UpperCamelCase__  :List[Any]				   =					model(UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_				)
							self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, self.seq_length, self.hidden_size)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :Dict				   =					MraForMaskedLM(config=UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :Any				   =					model(UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  labels=UpperCamelCase_				)
							self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.vocab_size)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :int				   =					MraForQuestionAnswering(config=UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :Dict				   =					model(
							    UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  start_positions=UpperCamelCase_       ,  end_positions=UpperCamelCase_       ,  )
							self.parent.assertEqual(result.start_logits.shape       ,  (self.batch_size, self.seq_length)				)
							self.parent.assertEqual(result.end_logits.shape       ,  (self.batch_size, self.seq_length)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :Optional[int]				   =					self.num_labels
							UpperCamelCase__  :Any				   =					MraForSequenceClassification(UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :Optional[Any]				   =					model(UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  labels=UpperCamelCase_				)
							self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.num_labels)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :Tuple				   =					self.num_labels
							UpperCamelCase__  :List[str]				   =					MraForTokenClassification(config=UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :Optional[int]				   =					model(UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  labels=UpperCamelCase_				)
							self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.num_labels)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :Union[str, Any]				   =					self.num_choices
							UpperCamelCase__  :List[str]				   =					MraForMultipleChoice(config=UpperCamelCase_				)
							model.to(UpperCamelCase_				)
							model.eval()
							UpperCamelCase__  :str				   =					input_ids.unsqueeze(1				).expand(-1       ,  self.num_choices       ,  -1				).contiguous()
							UpperCamelCase__  :Optional[int]				   =					token_type_ids.unsqueeze(1				).expand(-1       ,  self.num_choices       ,  -1				).contiguous()
							UpperCamelCase__  :List[str]				   =					input_mask.unsqueeze(1				).expand(-1       ,  self.num_choices       ,  -1				).contiguous()
							UpperCamelCase__  :Optional[Any]				   =					model(
							    UpperCamelCase_       ,  attention_mask=UpperCamelCase_       ,  token_type_ids=UpperCamelCase_       ,  labels=UpperCamelCase_       ,  )
							self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.num_choices)				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[Any]				   =					self.prepare_config_and_inputs()
							(
							    (
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							(
							    UpperCamelCase__
							)   ,							
							)  :str				   =					config_and_inputs
							UpperCamelCase__  :Any				   =					{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
							return config, inputs_dict



@require_torch
class   lowercase      (				A__      ,						unittest.TestCase   ):

		"""simple docstring"""

		_a       					=							(
		    (
		        MraModel,
		        MraForMaskedLM,
		        MraForMultipleChoice,
		        MraForQuestionAnswering,
		        MraForSequenceClassification,
		        MraForTokenClassification,
		    )
		    if is_torch_available()
		    else ()
		)
		_a       					=							False
		_a       					=							False
		_a       					=							False
		_a       					=							False

		_a       					=							()




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :int				   =					MraModelTester(self				)
							UpperCamelCase__  :Any				   =					ConfigTester(self       ,  config_class=UpperCamelCase_       ,  hidden_size=37				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							self.config_tester.run_common_tests()




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[Any]				   =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Optional[int]				   =					self.model_tester.prepare_config_and_inputs()
							for type in ["absolute", "relative_key", "relative_key_query"]:
												UpperCamelCase__  :List[Any]				   =					type
												self.model_tester.create_and_check_model(*UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Optional[Any]				   =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_masked_lm(*UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Dict				   =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_multiple_choice(*UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Union[str, Any]				   =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_question_answering(*UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Dict				   =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase_				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Optional[int]				   =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*UpperCamelCase_				)




		@slow
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							for model_name in MRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												UpperCamelCase__  :List[str]				   =					MraModel.from_pretrained(UpperCamelCase_				)
												self.assertIsNotNone(UpperCamelCase_				)




		@unittest.skip(reason='''MRA does not output attentions'''				)
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							return



@require_torch
class   lowercase      (				unittest.TestCase   ):

		"""simple docstring"""

		@slow
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[str]				   =					MraModel.from_pretrained('''uw-madison/mra-base-512-4'''				)
							UpperCamelCase__  :str				   =					torch.arange(256				).unsqueeze(0				)

							with torch.no_grad():
												UpperCamelCase__  :Optional[int]				   =					model(UpperCamelCase_				)[0]

							UpperCamelCase__  :Any				   =					torch.Size((1, 256, 768)				)
							self.assertEqual(output.shape       ,  UpperCamelCase_				)

							UpperCamelCase__  :Tuple				   =					torch.tensor(
							    [[[-0.0140, 0.0830, -0.0381], [0.1546, 0.1402, 0.0220], [0.1162, 0.0851, 0.0165]]]				)

							self.assertTrue(torch.allclose(output[:, :3, :3]       ,  UpperCamelCase_       ,  atol=1e-4				)				)




		@slow
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :int				   =					MraForMaskedLM.from_pretrained('''uw-madison/mra-base-512-4'''				)
							UpperCamelCase__  :Optional[Any]				   =					torch.arange(256				).unsqueeze(0				)

							with torch.no_grad():
												UpperCamelCase__  :Any				   =					model(UpperCamelCase_				)[0]

							UpperCamelCase__  :List[Any]				   =					50265

							UpperCamelCase__  :List[str]				   =					torch.Size((1, 256, vocab_size)				)
							self.assertEqual(output.shape       ,  UpperCamelCase_				)

							UpperCamelCase__  :Dict				   =					torch.tensor(
							    [[[9.2595, -3.6038, 11.8819], [9.3869, -3.2693, 11.0956], [11.8524, -3.4938, 13.1210]]]				)

							self.assertTrue(torch.allclose(output[:, :3, :3]       ,  UpperCamelCase_       ,  atol=1e-4				)				)




		@slow
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[str]				   =					MraForMaskedLM.from_pretrained('''uw-madison/mra-base-4096-8-d3'''				)
							UpperCamelCase__  :Tuple				   =					torch.arange(4096				).unsqueeze(0				)

							with torch.no_grad():
												UpperCamelCase__  :int				   =					model(UpperCamelCase_				)[0]

							UpperCamelCase__  :Optional[int]				   =					50265

							UpperCamelCase__  :str				   =					torch.Size((1, 4096, vocab_size)				)
							self.assertEqual(output.shape       ,  UpperCamelCase_				)

							UpperCamelCase__  :Optional[int]				   =					torch.tensor(
							    [[[5.4789, -2.3564, 7.5064], [7.9067, -1.3369, 9.9668], [9.0712, -1.8106, 7.0380]]]				)

							self.assertTrue(torch.allclose(output[:, :3, :3]       ,  UpperCamelCase_       ,  atol=1e-4				)				)



'''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}""")