






"""simple docstring"""
from __future__ import annotations

import unittest

from transformers import DebertaConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
      import tensorflow as tf

      from transformers import (
          TFDebertaForMaskedLM,
          TFDebertaForQuestionAnswering,
          TFDebertaForSequenceClassification,
          TFDebertaForTokenClassification,
          TFDebertaModel,
      )



class 		a_      :







      '''simple docstring'''

      def __init__(self,     lowerCamelCase_,     lowerCamelCase_=1_3,     lowerCamelCase_=7,     lowerCamelCase_=True,     lowerCamelCase_=True,     lowerCamelCase_=True,     lowerCamelCase_=True,     lowerCamelCase_=9_9,     lowerCamelCase_=3_2,     lowerCamelCase_=2,     lowerCamelCase_=4,     lowerCamelCase_=3_7,     lowerCamelCase_="gelu",     lowerCamelCase_=0.1,     lowerCamelCase_=0.1,     lowerCamelCase_=5_1_2,     lowerCamelCase_=1_6,     lowerCamelCase_=2,     lowerCamelCase_=0.02,     lowerCamelCase_=3,     lowerCamelCase_=4,     lowerCamelCase_=None,     ):

       '''simple docstring'''



       lowerCamelCase__     :			Dict     				=						parent
       lowerCamelCase__     :			Union[str, Any]     				=						1_3
       lowerCamelCase__     :			List[Any]     				=						7
       lowerCamelCase__     :			List[Any]     				=						True
       lowerCamelCase__     :			Optional[int]     				=						True
       lowerCamelCase__     :			List[Any]     				=						True
       lowerCamelCase__     :			Union[str, Any]     				=						True
       lowerCamelCase__     :			str     				=						9_9
       lowerCamelCase__     :			Optional[int]     				=						3_2
       lowerCamelCase__     :			Union[str, Any]     				=						2
       lowerCamelCase__     :			Optional[Any]     				=						4
       lowerCamelCase__     :			Any     				=						3_7
       lowerCamelCase__     :			Tuple     				=						'gelu'
       lowerCamelCase__     :			List[str]     				=						0.1
       lowerCamelCase__     :			Union[str, Any]     				=						0.1
       lowerCamelCase__     :			Union[str, Any]     				=						5_1_2
       lowerCamelCase__     :			Tuple     				=						1_6
       lowerCamelCase__     :			Any     				=						False
       lowerCamelCase__     :			Dict     				=						-1
       lowerCamelCase__     :			List[str]     				=						True
       lowerCamelCase__     :			Union[str, Any]     				=						2
       lowerCamelCase__     :			Tuple     				=						0.02
       lowerCamelCase__     :			str     				=						3
       lowerCamelCase__     :			Optional[int]     				=						4
       lowerCamelCase__     :			List[Any]     				=						None




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			str     				=						ids_tensor([self.batch_size, self.seq_length],     self.vocab_size					)

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

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

       lowerCamelCase__     :			List[str]     				=						None
       lowerCamelCase__     :			Optional[Any]     				=						None
       lowerCamelCase__     :			Optional[Any]     				=						None
       if self.use_labels:
        lowerCamelCase__     :			List[Any]     				=						ids_tensor([self.batch_size],     self.type_sequence_label_size					)
        lowerCamelCase__     :			Any     				=						ids_tensor([self.batch_size, self.seq_length],     self.num_labels					)

       lowerCamelCase__     :			Any     				=						DebertaConfig(
           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,     relative_attention=self.relative_attention,     max_relative_positions=self.max_relative_positions,     position_biased_input=self.position_biased_input,     initializer_range=self.initializer_range,     return_dict=lowerCamelCase_,     )

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




      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_					):

       '''simple docstring'''



       lowerCamelCase__     :			int     				=						TFDebertaModel(config=lowerCamelCase_					)
       lowerCamelCase__     :			Tuple     				=						{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}

       lowerCamelCase__     :			Tuple     				=						[input_ids, input_mask]
       lowerCamelCase__     :			Tuple     				=						model(lowerCamelCase_					)

       lowerCamelCase__     :			int     				=						model(lowerCamelCase_					)

       self.parent.assertEqual(result.last_hidden_state.shape,     (self.batch_size, self.seq_length, self.hidden_size)					)




      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_					):

       '''simple docstring'''



       lowerCamelCase__     :			int     				=						TFDebertaForMaskedLM(config=lowerCamelCase_					)
       lowerCamelCase__     :			List[str]     				=						{
           'input_ids': input_ids,
           'attention_mask': input_mask,
           'token_type_ids': token_type_ids,
       }
       lowerCamelCase__     :			Union[str, Any]     				=						model(lowerCamelCase_					)
       self.parent.assertEqual(result.logits.shape,     (self.batch_size, self.seq_length, self.vocab_size)					)




      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_					):

       '''simple docstring'''



       lowerCamelCase__     :			Union[str, Any]     				=						self.num_labels
       lowerCamelCase__     :			Tuple     				=						TFDebertaForSequenceClassification(config=lowerCamelCase_					)
       lowerCamelCase__     :			List[Any]     				=						{
           'input_ids': input_ids,
           'attention_mask': input_mask,
           'token_type_ids': token_type_ids,
       }

       lowerCamelCase__     :			Any     				=						model(lowerCamelCase_					)
       self.parent.assertEqual(result.logits.shape,     (self.batch_size, self.num_labels)					)




      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_					):

       '''simple docstring'''



       lowerCamelCase__     :			Optional[Any]     				=						self.num_labels
       lowerCamelCase__     :			Union[str, Any]     				=						TFDebertaForTokenClassification(config=lowerCamelCase_					)
       lowerCamelCase__     :			int     				=						{
           'input_ids': input_ids,
           'attention_mask': input_mask,
           'token_type_ids': token_type_ids,
       }
       lowerCamelCase__     :			Tuple     				=						model(lowerCamelCase_					)
       self.parent.assertEqual(result.logits.shape,     (self.batch_size, self.seq_length, self.num_labels)					)




      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_					):

       '''simple docstring'''



       lowerCamelCase__     :			List[Any]     				=						TFDebertaForQuestionAnswering(config=lowerCamelCase_					)
       lowerCamelCase__     :			Optional[int]     				=						{
           'input_ids': input_ids,
           'attention_mask': input_mask,
           'token_type_ids': token_type_ids,
       }

       lowerCamelCase__     :			Tuple     				=						model(lowerCamelCase_					)
       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 			a__							(self					):

       '''simple docstring'''



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



@require_tf
class 		a_      (	snake_case_  ,						snake_case_  ,						unittest.TestCase ):







      '''simple docstring'''

      lowerCamelCase__       :				Any =	(
          (
              TFDebertaModel,
              TFDebertaForMaskedLM,
              TFDebertaForQuestionAnswering,
              TFDebertaForSequenceClassification,
              TFDebertaForTokenClassification,
          )
          if is_tf_available()
          else ()
      )
      lowerCamelCase__       :				Dict =	(
          {
              'feature-extraction': TFDebertaModel,
              'fill-mask': TFDebertaForMaskedLM,
              'question-answering': TFDebertaForQuestionAnswering,
              'text-classification': TFDebertaForSequenceClassification,
              'token-classification': TFDebertaForTokenClassification,
              'zero-shot': TFDebertaForSequenceClassification,
          }
          if is_tf_available()
          else {}
      )

      lowerCamelCase__       :				Any =	False
      lowerCamelCase__       :				int =	False




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			Dict     				=						TFDebertaModelTester(self					)
       lowerCamelCase__     :			List[str]     				=						ConfigTester(self,     config_class=lowerCamelCase_,     hidden_size=3_7					)




      def 			a__							(self					):

       '''simple docstring'''



       self.config_tester.run_common_tests()




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			Optional[int]     				=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*lowerCamelCase_					)




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			Tuple     				=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase_					)




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			int     				=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*lowerCamelCase_					)




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			Optional[int]     				=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase_					)




      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			List[str]     				=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_token_classification(*lowerCamelCase_					)





      @slow
      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			List[Any]     				=						TFDebertaModel.from_pretrained('kamalkraj/deberta-base'					)
       self.assertIsNotNone(lowerCamelCase_					)



@require_tf
class 		a_      (	unittest.TestCase ):







      '''simple docstring'''

      @unittest.skip(reason='Model not available yet'					)
      def 			a__							(self					):

       '''simple docstring'''



       pass





      @slow
      def 			a__							(self					):

       '''simple docstring'''



       lowerCamelCase__     :			Dict     				=						TFDebertaModel.from_pretrained('kamalkraj/deberta-base'					)
       lowerCamelCase__     :			Union[str, Any]     				=						tf.constant([[0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9, 4_6_0_7_8, 1_5_8_8, 2]]					)
       lowerCamelCase__     :			List[str]     				=						tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]					)
       lowerCamelCase__     :			List[str]     				=						model(lowerCamelCase_,     attention_mask=lowerCamelCase_					)[0]

       lowerCamelCase__     :			Optional[Any]     				=						tf.constant(
           [
               [
                   [-0.59_855_896, -0.80_552_566, -0.8_462_135],
                   [1.4_484_025, -0.93_483_794, -0.80_593_085],
                   [0.3_122_741, 0.00_316_059, -1.4_131_377],
               ]
           ]					)
       tf.debugging.assert_near(output[:, 1:4, 1:4],     lowerCamelCase_,     atol=1e-4					)









"""simple docstring"""
import bsa
import requests






def        lowerCamelCase_  (						_lowerCamelCase				):
 return {
     "name": soup.ha.a.text,
     "genre": soup.find('span'			,   class_='genre'				).text.strip(),
     "rating": soup.strong.text,
     "page_link": f'''https://www.imdb.com{soup.a.get('href'				)}''',
 }






def        lowerCamelCase_  (						_lowerCamelCase = 5				):
 lowerCamelCase__     :			Optional[int]     				=						int(float(_lowerCamelCase				)				)
 if num_movies < 1:
  return ()
 lowerCamelCase__     :			Any     				=						(
     'https://www.imdb.com/search/title?title_type='
     f'''feature&sort=num_votes,desc&count={num_movies}'''
 )
 lowerCamelCase__     :			Union[str, Any]     				=						bsa.BeautifulSoup(requests.get(_lowerCamelCase				).content			,   'html.parser'				)
 return tuple(
     get_movie_data_from_soup(_lowerCamelCase				)
     for movie in source.find_all('div'			,   class_='lister-item mode-advanced'				)				)


if __name__ == "__main__":
      import json

      A_			: str				=			int(input("How many movies would you like to see? "))
      print(
          ", ".join(
              json.dumps(movie, indent=4) for movie in get_imdb_top_movies(num_movies)
          )
      )

