





import unittest

from transformers import DebertaVaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          DebertaVaForMaskedLM,
          DebertaVaForMultipleChoice,
          DebertaVaForQuestionAnswering,
          DebertaVaForSequenceClassification,
          DebertaVaForTokenClassification,
          DebertaVaModel,
      )
      from transformers.models.deberta_va.modeling_deberta_va import DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST

class  _UpperCAmelCase				(		_SCREAMING_SNAKE_CASE  ):
      def __init__(		self   ,							a__   ,							a__=13   ,							a__=7   ,							a__=True   ,							a__=True   ,							a__=True   ,							a__=True   ,							a__=99   ,							a__=32   ,							a__=5   ,							a__=4   ,							a__=37   ,							a__="gelu"   ,							a__=0.1   ,							a__=0.1   ,							a__=512   ,							a__=16   ,							a__=2   ,							a__=0.02   ,							a__=False   ,							a__=True   ,							a__="None"   ,							a__=3   ,							a__=4   ,							a__=None   ,							):
         A_  :					List[str]         =						parent
         A_  :					str         =						batch_size
         A_  :					Any         =						seq_length
         A_  :					Dict         =						is_training
         A_  :					Union[str, Any]         =						use_input_mask
         A_  :					Dict         =						use_token_type_ids
         A_  :					List[str]         =						use_labels
         A_  :					str         =						vocab_size
         A_  :					Dict         =						hidden_size
         A_  :					Dict         =						num_hidden_layers
         A_  :					Union[str, Any]         =						num_attention_heads
         A_  :					List[Any]         =						intermediate_size
         A_  :					List[Any]         =						hidden_act
         A_  :					Any         =						hidden_dropout_prob
         A_  :					Dict         =						attention_probs_dropout_prob
         A_  :					List[Any]         =						max_position_embeddings
         A_  :					str         =						type_vocab_size
         A_  :					Dict         =						type_sequence_label_size
         A_  :					List[Any]         =						initializer_range
         A_  :					Optional[int]         =						num_labels
         A_  :					List[str]         =						num_choices
         A_  :					Optional[int]         =						relative_attention
         A_  :					Optional[int]         =						position_biased_input
         A_  :					Optional[int]         =						pos_att_type
         A_  :					List[str]         =						scope
      def 		_lowerCamelCase   (		self							):
         A_  :					Optional[Any]         =						ids_tensor([self.batch_size, self.seq_length]   ,							self.vocab_size							)

         A_  :					List[Any]         =						None
         if self.use_input_mask:
            A_  :					Dict         =						ids_tensor([self.batch_size, self.seq_length]   ,							vocab_size=2							)

         A_  :					Union[str, Any]         =						None
         if self.use_token_type_ids:
            A_  :					Tuple         =						ids_tensor([self.batch_size, self.seq_length]   ,							self.type_vocab_size							)

         A_  :					Optional[int]         =						None
         A_  :					Union[str, Any]         =						None
         A_  :					Dict         =						None
         if self.use_labels:
            A_  :					int         =						ids_tensor([self.batch_size]   ,							self.type_sequence_label_size							)
            A_  :					str         =						ids_tensor([self.batch_size, self.seq_length]   ,							self.num_labels							)
            A_  :					List[str]         =						ids_tensor([self.batch_size]   ,							self.num_choices							)

         A_  :					Any         =						self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
      def 		_lowerCamelCase   (		self							):
         return DebertaVaConfig(
             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   ,							initializer_range=self.initializer_range   ,							relative_attention=self.relative_attention   ,							position_biased_input=self.position_biased_input   ,							pos_att_type=self.pos_att_type   ,							)
      def 		_lowerCamelCase   (		self   ,							a__							):
         self.parent.assertListEqual(list(result.loss.size()							)   ,							[]							)
      def 		_lowerCamelCase   (		self   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__							):
         A_  :					str         =						DebertaVaModel(config=a__							)
         model.to(a__							)
         model.eval()
         A_  :					Any         =						model(a__   ,							attention_mask=a__   ,							token_type_ids=a__							)[0]
         A_  :					Tuple         =						model(a__   ,							token_type_ids=a__							)[0]
         A_  :					Optional[int]         =						model(a__							)[0]

         self.parent.assertListEqual(list(sequence_output.size()							)   ,							[self.batch_size, self.seq_length, self.hidden_size]							)
      def 		_lowerCamelCase   (		self   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__							):
         A_  :					str         =						DebertaVaForMaskedLM(config=a__							)
         model.to(a__							)
         model.eval()
         A_  :					Optional[int]         =						model(a__   ,							attention_mask=a__   ,							token_type_ids=a__   ,							labels=a__							)

         self.parent.assertEqual(result.logits.shape   ,							(self.batch_size, self.seq_length, self.vocab_size)							)
      def 		_lowerCamelCase   (		self   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__							):
         A_  :					Any         =						self.num_labels
         A_  :					Optional[Any]         =						DebertaVaForSequenceClassification(a__							)
         model.to(a__							)
         model.eval()
         A_  :					Dict         =						model(a__   ,							attention_mask=a__   ,							token_type_ids=a__   ,							labels=a__							)
         self.parent.assertListEqual(list(result.logits.size()							)   ,							[self.batch_size, self.num_labels]							)
         self.check_loss_output(a__							)
      def 		_lowerCamelCase   (		self   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__							):
         A_  :					Optional[Any]         =						self.num_labels
         A_  :					List[str]         =						DebertaVaForTokenClassification(config=a__							)
         model.to(a__							)
         model.eval()
         A_  :					Optional[Any]         =						model(a__   ,							attention_mask=a__   ,							token_type_ids=a__   ,							labels=a__							)
         self.parent.assertEqual(result.logits.shape   ,							(self.batch_size, self.seq_length, self.num_labels)							)
      def 		_lowerCamelCase   (		self   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__							):
         A_  :					Optional[int]         =						DebertaVaForQuestionAnswering(config=a__							)
         model.to(a__							)
         model.eval()
         A_  :					List[str]         =						model(
             a__   ,							attention_mask=a__   ,							token_type_ids=a__   ,							start_positions=a__   ,							end_positions=a__   ,							)
         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   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__   ,							a__							):
         A_  :					Any         =						DebertaVaForMultipleChoice(config=a__							)
         model.to(a__							)
         model.eval()
         A_  :					Dict         =						input_ids.unsqueeze(1							).expand(-1   ,							self.num_choices   ,							-1							).contiguous()
         A_  :					Any         =						token_type_ids.unsqueeze(1							).expand(-1   ,							self.num_choices   ,							-1							).contiguous()
         A_  :					List[Any]         =						input_mask.unsqueeze(1							).expand(-1   ,							self.num_choices   ,							-1							).contiguous()
         A_  :					str         =						model(
             a__   ,							attention_mask=a__   ,							token_type_ids=a__   ,							labels=a__   ,							)
         self.parent.assertEqual(result.logits.shape   ,							(self.batch_size, self.num_choices)							)






      def 		_lowerCamelCase   (		self							):
         A_  :					Dict         =						self.prepare_config_and_inputs()
         (
             A_				
         )  :					Union[str, Any]         =						config_and_inputs
         A_  :					str         =						{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
         return config, inputs_dict






@require_torch
class  _UpperCAmelCase				(		_SCREAMING_SNAKE_CASE      ,							_SCREAMING_SNAKE_CASE      ,							unittest.TestCase  ):
      a    							=				(
          (
              DebertaVaModel,
              DebertaVaForMaskedLM,
              DebertaVaForSequenceClassification,
              DebertaVaForTokenClassification,
              DebertaVaForQuestionAnswering,
              DebertaVaForMultipleChoice,
          )
          if is_torch_available()
          else ()
      )
      a    							=				(
          {
              '''feature-extraction''': DebertaVaModel,
              '''fill-mask''': DebertaVaForMaskedLM,
              '''question-answering''': DebertaVaForQuestionAnswering,
              '''text-classification''': DebertaVaForSequenceClassification,
              '''token-classification''': DebertaVaForTokenClassification,
              '''zero-shot''': DebertaVaForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )

      a    							=				True
      a    							=				False
      a    							=				False
      a    							=				False
      a    							=				False
      def 		_lowerCamelCase   (		self							):
         A_  :					Tuple         =						DebertaVaModelTester(self							)
         A_  :					List[Any]         =						ConfigTester(self   ,							config_class=a__   ,							hidden_size=37							)
      def 		_lowerCamelCase   (		self							):
         self.config_tester.run_common_tests()
      def 		_lowerCamelCase   (		self							):
         A_  :					str         =						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_model(*a__							)
      def 		_lowerCamelCase   (		self							):
         A_  :					Optional[Any]         =						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_sequence_classification(*a__							)
      def 		_lowerCamelCase   (		self							):
         A_  :					str         =						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_masked_lm(*a__							)
      def 		_lowerCamelCase   (		self							):
         A_  :					Dict         =						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_question_answering(*a__							)
      def 		_lowerCamelCase   (		self							):
         A_  :					int         =						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_token_classification(*a__							)
      def 		_lowerCamelCase   (		self							):
         A_  :					Tuple         =						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_multiple_choice(*a__							)






      @slow
      def 		_lowerCamelCase   (		self							):
         for model_name in DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            A_  :					Optional[int]         =						DebertaVaModel.from_pretrained(a__							)
            self.assertIsNotNone(a__							)






@require_torch
@require_sentencepiece
@require_tokenizers
class  _UpperCAmelCase				(		unittest.TestCase  ):
      @unittest.skip(reason="""Model not available yet"""							)
      def 		_lowerCamelCase   (		self							):
         pass






      @slow
      def 		_lowerCamelCase   (		self							):
         A_  :					List[str]         =						DebertaVaModel.from_pretrained("""microsoft/deberta-v2-xlarge"""							)

         A_  :					str         =						torch.tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]							)
         A_  :					Tuple         =						torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]							)
         with torch.no_grad():
            A_  :					List[Any]         =						model(a__   ,							attention_mask=a__							)[0]
         # compare the actual values for a slice.
         A_  :					Optional[Any]         =						torch.tensor(
             [[[0.2356, 0.1948, 0.0369], [-0.1063, 0.3586, -0.5152], [-0.6399, -0.0259, -0.2525]]]							)
         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]   ,							a__   ,							atol=1E-4							)   ,							F"""{output[:, 1:4, 1:4]}"""							)










'''simple docstring'''






import requests
from bsa import BeautifulSoup







def 							UpperCamelCase_     (       A__   :  str = "AAPL"   ):
  '''simple docstring'''





  lowerCAmelCase_     : Dict     =  f'https://in.finance.yahoo.com/quote/{symbol}?s={symbol}'
  lowerCAmelCase_     : Optional[Any]     =  BeautifulSoup(requests.get(A__   ).text				,       """html.parser"""   )
  lowerCAmelCase_     : Union[str, Any]     =  """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}''')



