

'''simple docstring'''






import unittest

from transformers import ErnieMConfig, 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, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          ErnieMForInformationExtraction,
          ErnieMForMultipleChoice,
          ErnieMForQuestionAnswering,
          ErnieMForSequenceClassification,
          ErnieMForTokenClassification,
          ErnieMModel,
      )
      from transformers.models.ernie_m.modeling_ernie_m import ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST
class      SCREAMING_SNAKE_CASE__      :




    def __init__( self    ,					lowercase__    ,					lowercase__=13    ,					lowercase__=7    ,					lowercase__=True    ,					lowercase__=True    ,					lowercase__=True    ,					lowercase__=99    ,					lowercase__=32    ,					lowercase__=5    ,					lowercase__=4    ,					lowercase__=37    ,					lowercase__="gelu"    ,					lowercase__=0.1    ,					lowercase__=0.1    ,					lowercase__=512    ,					lowercase__=16    ,					lowercase__=2    ,					lowercase__=0.02    ,					lowercase__=3    ,					lowercase__=4    ,					lowercase__=None    ,					):






          """simple docstring"""






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




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Any					=	ids_tensor([self.batch_size, self.seq_length]    ,					self.vocab_size      )

          SCREAMING_SNAKE_CASE_				:      Dict					=	None
          if self.use_input_mask:
                SCREAMING_SNAKE_CASE_				:      List[Any]					=	random_attention_mask([self.batch_size, self.seq_length]      )

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

          SCREAMING_SNAKE_CASE_				:      Optional[int]					=	self.get_config()

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




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Optional[int]					=	ids_tensor([self.batch_size, self.seq_length]    ,					self.vocab_size      )

          SCREAMING_SNAKE_CASE_				:      Optional[Any]					=	None
          if self.use_input_mask:
                SCREAMING_SNAKE_CASE_				:      Optional[int]					=	random_attention_mask([self.batch_size, self.seq_length]      )
          SCREAMING_SNAKE_CASE_				:      List[Any]					=	self.get_config()

          return config, input_ids, input_mask




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          return ErnieMConfig(
              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    ,					)




    def   __lowerCamelCase				( self    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Tuple					=	ErnieMModel(config=lowercase__      )
          model.to(lowercase__      )
          model.eval()
          SCREAMING_SNAKE_CASE_				:      Optional[int]					=	model(lowercase__    ,					return_dict=lowercase__      )
          self.parent.assertEqual(result.last_hidden_state.shape    ,					(self.batch_size, self.seq_length, self.hidden_size)      )




    def   __lowerCamelCase				( self    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      List[Any]					=	ErnieMForQuestionAnswering(config=lowercase__      )
          model.to(lowercase__      )
          model.eval()
          SCREAMING_SNAKE_CASE_				:      List[Any]					=	model(
              lowercase__    ,					attention_mask=lowercase__    ,					start_positions=lowercase__    ,					end_positions=lowercase__    ,					)
          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    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      str					=	ErnieMForInformationExtraction(config=lowercase__      )
          model.to(lowercase__      )
          model.eval()
          SCREAMING_SNAKE_CASE_				:      List[str]					=	torch.ones_like(lowercase__    ,					dtype=torch.floataa      )
          SCREAMING_SNAKE_CASE_				:      Tuple					=	model(
              lowercase__    ,					attention_mask=lowercase__    ,					start_positions=lowercase__    ,					end_positions=lowercase__    ,					)
          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    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Dict					=	self.num_labels
          SCREAMING_SNAKE_CASE_				:      List[Any]					=	ErnieMForSequenceClassification(lowercase__      )
          model.to(lowercase__      )
          model.eval()
          SCREAMING_SNAKE_CASE_				:      Optional[int]					=	model(lowercase__    ,					attention_mask=lowercase__    ,					labels=lowercase__      )
          self.parent.assertEqual(result.logits.shape    ,					(self.batch_size, self.num_labels)      )




    def   __lowerCamelCase				( self    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Dict					=	self.num_labels
          SCREAMING_SNAKE_CASE_				:      int					=	ErnieMForTokenClassification(config=lowercase__      )
          model.to(lowercase__      )
          model.eval()
          input_ids.to(lowercase__      )
          input_mask.to(lowercase__      )
          token_labels.to(lowercase__      )

          SCREAMING_SNAKE_CASE_				:      int					=	model(lowercase__    ,					attention_mask=lowercase__    ,					labels=lowercase__      )

          self.parent.assertEqual(result.logits.shape    ,					(self.batch_size, self.seq_length, self.num_labels)      )




    def   __lowerCamelCase				( self    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      List[Any]					=	self.num_choices
          SCREAMING_SNAKE_CASE_				:      Dict					=	ErnieMForMultipleChoice(config=lowercase__      )
          model.to(lowercase__      )
          model.eval()
          SCREAMING_SNAKE_CASE_				:      Any					=	input_ids.unsqueeze(1      ).expand(-1    ,					self.num_choices    ,					-1      ).contiguous()
          SCREAMING_SNAKE_CASE_				:      Dict					=	input_mask.unsqueeze(1      ).expand(-1    ,					self.num_choices    ,					-1      ).contiguous()
          SCREAMING_SNAKE_CASE_				:      Dict					=	model(
              lowercase__    ,					attention_mask=lowercase__    ,					labels=lowercase__    ,					)
          self.parent.assertEqual(result.logits.shape    ,					(self.batch_size, self.num_choices)      )







    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Tuple					=	self.prepare_config_and_inputs()
          (
              SCREAMING_SNAKE_CASE_						
          )				:      Optional[Any]					=	config_and_inputs
          SCREAMING_SNAKE_CASE_				:      Any					=	{"input_ids": input_ids, "attention_mask": input_mask}
          return config, inputs_dict






@require_torch
class      SCREAMING_SNAKE_CASE__      (    _UpperCAmelCase,_UpperCAmelCase,unittest.TestCase				):
    _A         =							(
        (
            ErnieMModel,
            ErnieMForMultipleChoice,
            ErnieMForQuestionAnswering,
            ErnieMForSequenceClassification,
            ErnieMForTokenClassification,
        )
        if is_torch_available()
        else ()
    )
    _A         =							()
    _A         =							(
        {
            "feature-extraction": ErnieMModel,
            "question-answering": ErnieMForQuestionAnswering,
            "text-classification": ErnieMForSequenceClassification,
            "token-classification": ErnieMForTokenClassification,
            "zero-shot": ErnieMForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    _A         =							False




    def   __lowerCamelCase				( self    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__    ,					lowercase__      ):






          """simple docstring"""






          if pipeline_test_casse_name == "QAPipelineTests":
                return True

          return False




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      List[Any]					=	ErnieMModelTester(self      )
          SCREAMING_SNAKE_CASE_				:      List[Any]					=	ConfigTester(self    ,					config_class=lowercase__    ,					hidden_size=37      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          self.config_tester.run_common_tests()




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      List[Any]					=	self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*lowercase__      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Optional[Any]					=	self.model_tester.prepare_config_and_inputs()
          for type in ["absolute", "relative_key", "relative_key_query"]:
                SCREAMING_SNAKE_CASE_				:      Dict					=	type
                self.model_tester.create_and_check_model(*lowercase__      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Optional[int]					=	self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_multiple_choice(*lowercase__      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Any					=	self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_question_answering(*lowercase__      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Any					=	self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_sequence_classification(*lowercase__      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Optional[Any]					=	self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_information_extraction(*lowercase__      )




    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Union[str, Any]					=	self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_token_classification(*lowercase__      )







    @slow
    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          for model_name in ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                SCREAMING_SNAKE_CASE_				:      str					=	ErnieMModel.from_pretrained(lowercase__      )
                self.assertIsNotNone(lowercase__      )






@require_torch
class      SCREAMING_SNAKE_CASE__      (    unittest.TestCase				):




    @slow
    def   __lowerCamelCase				( self      ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_				:      Tuple					=	ErnieMModel.from_pretrained("susnato/ernie-m-base_pytorch"      )
          model.eval()
          SCREAMING_SNAKE_CASE_				:      List[Any]					=	torch.tensor([[0, 1, 2, 3, 4, 5]]      )
          SCREAMING_SNAKE_CASE_				:      Optional[Any]					=	model(lowercase__      )[0]

          # TODO Replace vocab size
          SCREAMING_SNAKE_CASE_				:      Tuple					=	768

          SCREAMING_SNAKE_CASE_				:      Optional[int]					=	torch.Size((1, 6, hidden_size)      )
          self.assertEqual(output.shape    ,					lowercase__      )

          SCREAMING_SNAKE_CASE_				:      List[str]					=	torch.tensor(
              [[[-0.0012, 0.1245, -0.0214], [-0.0742, 0.0244, -0.0771], [-0.0333, 0.1164, -0.1554]]]      )

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




'''simple docstring'''






import requests
from bsa import BeautifulSoup


def  __lowerCamelCase      (				SCREAMING_SNAKE_CASE_					:     int  ,  SCREAMING_SNAKE_CASE_					:     str   )							->       str:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_				:      List[str]					=	(
          "https://www.horoscope.com/us/horoscopes/general/"
          F"horoscope-general-daily-{day}.aspx?sign={zodiac_sign}"
      )
      SCREAMING_SNAKE_CASE_				:      Dict					=	BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE_   ).content  ,  "html.parser"   )
      return soup.find("div"  ,  class_="main-horoscope"   ).p.text


if __name__ == "__main__":
      print('Daily Horoscope. \n')
      print(
          'enter your Zodiac sign number:\n',
          '1. Aries\n',
          '2. Taurus\n',
          '3. Gemini\n',
          '4. Cancer\n',
          '5. Leo\n',
          '6. Virgo\n',
          '7. Libra\n',
          '8. Scorpio\n',
          '9. Sagittarius\n',
          '10. Capricorn\n',
          '11. Aquarius\n',
          '12. Pisces\n',
      )
      snake_case_					  =	int(input('number> ').strip())
      print('choose some day:\n', 'yesterday\n', 'today\n', 'tomorrow\n')
      snake_case_					  =	input('enter the day> ')
      snake_case_					  =	horoscope(zodiac_sign, day)
      print(horoscope_text)

