



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

import os
import tempfile
import unittest

from transformers import ConvBertConfig, 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 (
          TFConvBertForMaskedLM,
          TFConvBertForMultipleChoice,
          TFConvBertForQuestionAnswering,
          TFConvBertForSequenceClassification,
          TFConvBertForTokenClassification,
          TFConvBertModel,
      )



class    SCREAMING_SNAKE_CASE__						:

   def __init__(     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE=13   ,  _SCREAMING_SNAKE_CASE=7   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=True   ,  _SCREAMING_SNAKE_CASE=99   ,  _SCREAMING_SNAKE_CASE=32   ,  _SCREAMING_SNAKE_CASE=2   ,  _SCREAMING_SNAKE_CASE=4   ,  _SCREAMING_SNAKE_CASE=37   ,  _SCREAMING_SNAKE_CASE="gelu"   ,  _SCREAMING_SNAKE_CASE=0.1   ,  _SCREAMING_SNAKE_CASE=0.1   ,  _SCREAMING_SNAKE_CASE=512   ,  _SCREAMING_SNAKE_CASE=16   ,  _SCREAMING_SNAKE_CASE=2   ,  _SCREAMING_SNAKE_CASE=0.02   ,  _SCREAMING_SNAKE_CASE=3   ,  _SCREAMING_SNAKE_CASE=4   ,  _SCREAMING_SNAKE_CASE=None   ,  )						->   Optional[int]:





    '''simple docstring'''




    UpperCAmelCase			:      Optional[int]			=			parent
    UpperCAmelCase			:      Dict			=			13
    UpperCAmelCase			:      Optional[int]			=			7
    UpperCAmelCase			:      int			=			True
    UpperCAmelCase			:      Tuple			=			True
    UpperCAmelCase			:      Any			=			True
    UpperCAmelCase			:      Any			=			True
    UpperCAmelCase			:      str			=			99
    UpperCAmelCase			:      Dict			=			384
    UpperCAmelCase			:      Dict			=			2
    UpperCAmelCase			:      List[Any]			=			4
    UpperCAmelCase			:      Tuple			=			37
    UpperCAmelCase			:      Optional[int]			=			"""gelu"""
    UpperCAmelCase			:      Tuple			=			0.1
    UpperCAmelCase			:      List[Any]			=			0.1
    UpperCAmelCase			:      Dict			=			512
    UpperCAmelCase			:      str			=			16
    UpperCAmelCase			:      List[Any]			=			2
    UpperCAmelCase			:      Tuple			=			0.02
    UpperCAmelCase			:      int			=			3
    UpperCAmelCase			:      Tuple			=			4
    UpperCAmelCase			:      Tuple			=			128
    UpperCAmelCase			:      List[Any]			=			2
    UpperCAmelCase			:      Union[str, Any]			=			9
    UpperCAmelCase			:      Union[str, Any]			=			1
    UpperCAmelCase			:      List[str]			=			None

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   List[Any]:





    '''simple docstring'''




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

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

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

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

    UpperCAmelCase			:      Tuple			=			ConvBertConfig(
        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   ,  return_dict=_SCREAMING_SNAKE_CASE   ,  )

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

   def 			SCREAMING_SNAKE_CASE  (     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)						->   Dict:





    '''simple docstring'''




    UpperCAmelCase			:      Any			=			TFConvBertModel(config=_SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      Any			=			{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

    UpperCAmelCase			:      Any			=			[input_ids, input_mask]
    UpperCAmelCase			:      Dict			=			model(_SCREAMING_SNAKE_CASE		)

    UpperCAmelCase			:      List[Any]			=			model(_SCREAMING_SNAKE_CASE		)

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

   def 			SCREAMING_SNAKE_CASE  (     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)						->   str:





    '''simple docstring'''




    UpperCAmelCase			:      int			=			TFConvBertForMaskedLM(config=_SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      List[Any]			=			{
        """input_ids""": input_ids,
        """attention_mask""": input_mask,
        """token_type_ids""": token_type_ids,
    }
    UpperCAmelCase			:      List[Any]			=			model(_SCREAMING_SNAKE_CASE		)
    self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.seq_length, self.vocab_size)		)

   def 			SCREAMING_SNAKE_CASE  (     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)						->   Optional[Any]:





    '''simple docstring'''




    UpperCAmelCase			:      Tuple			=			self.num_labels
    UpperCAmelCase			:      str			=			TFConvBertForSequenceClassification(config=_SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      Optional[Any]			=			{
        """input_ids""": input_ids,
        """attention_mask""": input_mask,
        """token_type_ids""": token_type_ids,
    }

    UpperCAmelCase			:      Optional[Any]			=			model(_SCREAMING_SNAKE_CASE		)
    self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.num_labels)		)

   def 			SCREAMING_SNAKE_CASE  (     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)						->   str:





    '''simple docstring'''




    UpperCAmelCase			:      Union[str, Any]			=			self.num_choices
    UpperCAmelCase			:      Optional[Any]			=			TFConvBertForMultipleChoice(config=_SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      List[Any]			=			tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE   ,  1		)   ,  (1, self.num_choices, 1)		)
    UpperCAmelCase			:      List[str]			=			tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE   ,  1		)   ,  (1, self.num_choices, 1)		)
    UpperCAmelCase			:      int			=			tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE   ,  1		)   ,  (1, self.num_choices, 1)		)
    UpperCAmelCase			:      Optional[int]			=			{
        """input_ids""": multiple_choice_inputs_ids,
        """attention_mask""": multiple_choice_input_mask,
        """token_type_ids""": multiple_choice_token_type_ids,
    }
    UpperCAmelCase			:      Optional[Any]			=			model(_SCREAMING_SNAKE_CASE		)
    self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.num_choices)		)

   def 			SCREAMING_SNAKE_CASE  (     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)						->   int:





    '''simple docstring'''




    UpperCAmelCase			:      Any			=			self.num_labels
    UpperCAmelCase			:      int			=			TFConvBertForTokenClassification(config=_SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      Any			=			{
        """input_ids""": input_ids,
        """attention_mask""": input_mask,
        """token_type_ids""": token_type_ids,
    }
    UpperCAmelCase			:      Optional[Any]			=			model(_SCREAMING_SNAKE_CASE		)
    self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.seq_length, self.num_labels)		)

   def 			SCREAMING_SNAKE_CASE  (     self   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)						->   Any:





    '''simple docstring'''




    UpperCAmelCase			:      List[str]			=			TFConvBertForQuestionAnswering(config=_SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      Dict			=			{
        """input_ids""": input_ids,
        """attention_mask""": input_mask,
        """token_type_ids""": token_type_ids,
    }

    UpperCAmelCase			:      Tuple			=			model(_SCREAMING_SNAKE_CASE		)
    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 			SCREAMING_SNAKE_CASE  (     self		)						->   int:





    '''simple docstring'''




    UpperCAmelCase			:      Optional[int]			=			self.prepare_config_and_inputs()
    (
        (
        UpperCAmelCase
    )			,	(
        UpperCAmelCase
    )			,	(
        UpperCAmelCase
    )			,	(
        UpperCAmelCase
    )			,	(
        UpperCAmelCase
    )			,	(
        UpperCAmelCase
    )			,	(
        UpperCAmelCase
    )			,	
    )			:      Tuple			=			config_and_inputs
    UpperCAmelCase			:      Dict			=			{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
    return config, inputs_dict



@require_tf
class    SCREAMING_SNAKE_CASE__						(      UpperCAmelCase__   ,    UpperCAmelCase__   ,    unittest.TestCase				):
   __lowerCAmelCase						:     int		=		(
       (
           TFConvBertModel,
           TFConvBertForMaskedLM,
           TFConvBertForQuestionAnswering,
           TFConvBertForSequenceClassification,
           TFConvBertForTokenClassification,
           TFConvBertForMultipleChoice,
       )
       if is_tf_available()
       else ()
   )
   __lowerCAmelCase						:     Dict		=		(
       {
           'feature-extraction': TFConvBertModel,
           'fill-mask': TFConvBertForMaskedLM,
           'question-answering': TFConvBertForQuestionAnswering,
           'text-classification': TFConvBertForSequenceClassification,
           'token-classification': TFConvBertForTokenClassification,
           'zero-shot': TFConvBertForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   __lowerCAmelCase						:     Union[str, Any]		=		False
   __lowerCAmelCase						:     Dict		=		False
   __lowerCAmelCase						:     Optional[int]		=		False

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   List[Any]:





    '''simple docstring'''




    UpperCAmelCase			:      int			=			TFConvBertModelTester(self		)
    UpperCAmelCase			:      List[Any]			=			ConfigTester(self   ,  config_class=_SCREAMING_SNAKE_CASE   ,  hidden_size=37		)

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   str:





    '''simple docstring'''




    self.config_tester.run_common_tests()

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   str:





    '''simple docstring'''




    UpperCAmelCase			:      Union[str, Any]			=			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE		)

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   List[Any]:





    '''simple docstring'''




    UpperCAmelCase			:      Optional[int]			=			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_masked_lm(*_SCREAMING_SNAKE_CASE		)

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   int:





    '''simple docstring'''




    UpperCAmelCase			:      int			=			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_multiple_choice(*_SCREAMING_SNAKE_CASE		)

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   str:





    '''simple docstring'''




    UpperCAmelCase			:      Optional[Any]			=			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_question_answering(*_SCREAMING_SNAKE_CASE		)

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   Union[str, Any]:





    '''simple docstring'''




    UpperCAmelCase			:      List[Any]			=			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_sequence_classification(*_SCREAMING_SNAKE_CASE		)

   def 			SCREAMING_SNAKE_CASE  (     self		)						->   List[str]:





    '''simple docstring'''




    UpperCAmelCase			:      str			=			self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_token_classification(*_SCREAMING_SNAKE_CASE		)

   @slow
   def 			SCREAMING_SNAKE_CASE  (     self		)						->   List[str]:





    '''simple docstring'''




    UpperCAmelCase			,	UpperCAmelCase			:      Any			=			self.model_tester.prepare_config_and_inputs_for_common()
    UpperCAmelCase			:      Optional[int]			=			True
    UpperCAmelCase			:      List[str]			=			True

    if hasattr(_SCREAMING_SNAKE_CASE   ,  """use_cache"""		):
     UpperCAmelCase			:      List[Any]			=			True

    UpperCAmelCase			:      Dict			=			getattr(self.model_tester   ,  """encoder_seq_length"""   ,  self.model_tester.seq_length		)
    UpperCAmelCase			:      Any			=			getattr(self.model_tester   ,  """key_length"""   ,  _SCREAMING_SNAKE_CASE		)

    for model_class in self.all_model_classes:
     UpperCAmelCase			:      Union[str, Any]			=			self._prepare_for_class(_SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)
     UpperCAmelCase			:      str			=			model_class(_SCREAMING_SNAKE_CASE		)
     UpperCAmelCase			:      Dict			=			len(model(_SCREAMING_SNAKE_CASE		)		)

     with tempfile.TemporaryDirectory() as tmpdirname:
      model.save_pretrained(_SCREAMING_SNAKE_CASE   ,  saved_model=_SCREAMING_SNAKE_CASE		)
      UpperCAmelCase			:      str			=			os.path.join(_SCREAMING_SNAKE_CASE   ,  """saved_model"""   ,  """1"""		)
      UpperCAmelCase			:      Any			=			tf.keras.models.load_model(_SCREAMING_SNAKE_CASE		)
      UpperCAmelCase			:      List[Any]			=			model(_SCREAMING_SNAKE_CASE		)

      if self.is_encoder_decoder:
       UpperCAmelCase			:      Any			=			outputs["""encoder_hidden_states"""]
       UpperCAmelCase			:      Optional[int]			=			outputs["""encoder_attentions"""]
      else:
       UpperCAmelCase			:      Optional[Any]			=			outputs["""hidden_states"""]
       UpperCAmelCase			:      Dict			=			outputs["""attentions"""]

      self.assertEqual(len(_SCREAMING_SNAKE_CASE		)   ,  _SCREAMING_SNAKE_CASE		)

      UpperCAmelCase			:      List[Any]			=			getattr(
          self.model_tester   ,  """expected_num_hidden_layers"""   ,  self.model_tester.num_hidden_layers + 1		)

      self.assertEqual(len(_SCREAMING_SNAKE_CASE		)   ,  _SCREAMING_SNAKE_CASE		)
      self.assertListEqual(
          list(output_hidden_states[0].shape[-2:]		)   ,  [self.model_tester.seq_length, self.model_tester.hidden_size]   ,  )

      self.assertEqual(len(_SCREAMING_SNAKE_CASE		)   ,  self.model_tester.num_hidden_layers		)
      self.assertListEqual(
          list(output_attentions[0].shape[-3:]		)   ,  [self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]   ,  )

   @slow
   def 			SCREAMING_SNAKE_CASE  (     self		)						->   Optional[Any]:





    '''simple docstring'''




    UpperCAmelCase			:      Optional[Any]			=			TFConvBertModel.from_pretrained("""YituTech/conv-bert-base"""		)
    self.assertIsNotNone(_SCREAMING_SNAKE_CASE		)




   def 			SCREAMING_SNAKE_CASE  (     self		)						->   Tuple:





    '''simple docstring'''




    UpperCAmelCase			,	UpperCAmelCase			:      Union[str, Any]			=			self.model_tester.prepare_config_and_inputs_for_common()
    UpperCAmelCase			:      Tuple			=			True
    UpperCAmelCase			:      List[Any]			=			getattr(self.model_tester   ,  """decoder_seq_length"""   ,  self.model_tester.seq_length		)
    UpperCAmelCase			:      Tuple			=			getattr(self.model_tester   ,  """encoder_seq_length"""   ,  self.model_tester.seq_length		)
    UpperCAmelCase			:      int			=			getattr(self.model_tester   ,  """key_length"""   ,  _SCREAMING_SNAKE_CASE		)
    UpperCAmelCase			:      Dict			=			getattr(self.model_tester   ,  """key_length"""   ,  _SCREAMING_SNAKE_CASE		)

    def check_decoder_attentions_output(_SCREAMING_SNAKE_CASE		):
     UpperCAmelCase			:      str			=			len(_SCREAMING_SNAKE_CASE		)
     self.assertEqual(out_len % 2   ,  0		)
     UpperCAmelCase			:      Tuple			=			outputs.decoder_attentions
     self.assertEqual(len(_SCREAMING_SNAKE_CASE		)   ,  self.model_tester.num_hidden_layers		)
     self.assertListEqual(
         list(decoder_attentions[0].shape[-3:]		)   ,  [self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]   ,  )

    def check_encoder_attentions_output(_SCREAMING_SNAKE_CASE		):
     UpperCAmelCase			:      Optional[int]			=			[
         t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
     ]
     self.assertEqual(len(_SCREAMING_SNAKE_CASE		)   ,  self.model_tester.num_hidden_layers		)
     self.assertListEqual(
         list(attentions[0].shape[-3:]		)   ,  [self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]   ,  )

    for model_class in self.all_model_classes:
     UpperCAmelCase			:      Tuple			=			True
     UpperCAmelCase			:      List[str]			=			False
     UpperCAmelCase			:      Union[str, Any]			=			model_class(_SCREAMING_SNAKE_CASE		)
     UpperCAmelCase			:      int			=			model(self._prepare_for_class(_SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)		)
     UpperCAmelCase			:      List[Any]			=			len(_SCREAMING_SNAKE_CASE		)
     self.assertEqual(config.output_hidden_states   ,  _SCREAMING_SNAKE_CASE		)
     check_encoder_attentions_output(_SCREAMING_SNAKE_CASE		)

     if self.is_encoder_decoder:
      UpperCAmelCase			:      Dict			=			model_class(_SCREAMING_SNAKE_CASE		)
      UpperCAmelCase			:      str			=			model(self._prepare_for_class(_SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)		)
      self.assertEqual(config.output_hidden_states   ,  _SCREAMING_SNAKE_CASE		)
      check_decoder_attentions_output(_SCREAMING_SNAKE_CASE		)

     # Check that output attentions can also be changed via the config
     del inputs_dict["output_attentions"]
     UpperCAmelCase			:      List[Any]			=			True
     UpperCAmelCase			:      Any			=			model_class(_SCREAMING_SNAKE_CASE		)
     UpperCAmelCase			:      int			=			model(self._prepare_for_class(_SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)		)
     self.assertEqual(config.output_hidden_states   ,  _SCREAMING_SNAKE_CASE		)
     check_encoder_attentions_output(_SCREAMING_SNAKE_CASE		)

     # Check attention is always last and order is fine
     UpperCAmelCase			:      Any			=			True
     UpperCAmelCase			:      Optional[Any]			=			True
     UpperCAmelCase			:      Optional[Any]			=			model_class(_SCREAMING_SNAKE_CASE		)
     UpperCAmelCase			:      Union[str, Any]			=			model(self._prepare_for_class(_SCREAMING_SNAKE_CASE   ,  _SCREAMING_SNAKE_CASE		)		)

     self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)   ,  len(_SCREAMING_SNAKE_CASE		)		)
     self.assertEqual(model.config.output_hidden_states   ,  _SCREAMING_SNAKE_CASE		)
     check_encoder_attentions_output(_SCREAMING_SNAKE_CASE		)



@require_tf
class    SCREAMING_SNAKE_CASE__						(      unittest.TestCase				):

   @slow
   def 			SCREAMING_SNAKE_CASE  (     self		)						->   List[Any]:





    '''simple docstring'''




    UpperCAmelCase			:      Optional[int]			=			TFConvBertModel.from_pretrained("""YituTech/conv-bert-base"""		)
    UpperCAmelCase			:      Tuple			=			tf.constant([[0, 1, 2, 3, 4, 5]]		)
    UpperCAmelCase			:      List[str]			=			model(_SCREAMING_SNAKE_CASE		)[0]

    UpperCAmelCase			:      Dict			=			[1, 6, 768]
    self.assertEqual(output.shape   ,  _SCREAMING_SNAKE_CASE		)

    UpperCAmelCase			:      Union[str, Any]			=			tf.constant(
        [
            [
                [-0.0347_5493, -0.468_6034, -0.3063_8832],
                [0.2263_7248, -0.2698_8646, -0.742_3424],
                [0.1032_4868, -0.4501_3508, -0.5828_0784],
            ]
        ]		)
    tf.debugging.assert_near(output[:, :3, :3]   ,  _SCREAMING_SNAKE_CASE   ,  atol=1E-4		)





"""simple docstring"""
import requests
from bsa import BeautifulSoup

def    _snake_case		(		UpperCamelCase		:	str = "AAPL"		):
 UpperCAmelCase			:      Any			=			F"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}"
 UpperCAmelCase			:      Optional[int]			=			BeautifulSoup(requests.get(UpperCamelCase		).text    ,	"""html.parser"""		)
 UpperCAmelCase			:      int			=			"""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}""")
