



"""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      A__  :




	'''simple docstring'''





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

				"""simple docstring"""

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

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

				"""simple docstring"""

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

				__lowerCAmelCase :    int				=			None
				if self.use_input_mask:
							__lowerCAmelCase :    Union[str, Any]				=			random_attention_mask([self.batch_size, self.seq_length])

				__lowerCAmelCase :    Optional[int]				=			None
				if self.use_token_type_ids:
							__lowerCAmelCase :    List[Any]				=			ids_tensor([self.batch_size, self.seq_length]			,     self.type_vocab_size)

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

				__lowerCAmelCase :    Any				=			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:						Union[str, Any]			,     _SCREAMING_SNAKE_CASE:						str			,     _SCREAMING_SNAKE_CASE:						Tuple			,     _SCREAMING_SNAKE_CASE:						Optional[Any]			,     _SCREAMING_SNAKE_CASE:						Optional[int]			,     _SCREAMING_SNAKE_CASE:						Any			,     _SCREAMING_SNAKE_CASE:						Dict			,     _SCREAMING_SNAKE_CASE:						List[Any])							->			Any:

				"""simple docstring"""

				__lowerCAmelCase :    Tuple				=			TFConvBertModel(config=_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase :    Dict				=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}

				__lowerCAmelCase :    Optional[int]				=			[input_ids, input_mask]
				__lowerCAmelCase :    Union[str, Any]				=			model(_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase :    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:						List[Any]			,     _SCREAMING_SNAKE_CASE:						str			,     _SCREAMING_SNAKE_CASE:						Optional[int]			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						str			,     _SCREAMING_SNAKE_CASE:						List[Any]			,     _SCREAMING_SNAKE_CASE:						Optional[int]			,     _SCREAMING_SNAKE_CASE:						str)							->			List[Any]:

				"""simple docstring"""

				__lowerCAmelCase :    Union[str, Any]				=			TFConvBertForMaskedLM(config=_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase :    Tuple				=			{
				    "input_ids": input_ids,
				    "attention_mask": input_mask,
				    "token_type_ids": token_type_ids,
				}
				__lowerCAmelCase :    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:						int			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						int			,     _SCREAMING_SNAKE_CASE:						Dict			,     _SCREAMING_SNAKE_CASE:						Optional[Any]			,     _SCREAMING_SNAKE_CASE:						Optional[Any]			,     _SCREAMING_SNAKE_CASE:						List[Any]			,     _SCREAMING_SNAKE_CASE:						List[str])							->			List[str]:

				"""simple docstring"""

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

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

	def 				_SCREAMING_SNAKE_CASE  (	self:						Any			,     _SCREAMING_SNAKE_CASE:						int			,     _SCREAMING_SNAKE_CASE:						List[Any]			,     _SCREAMING_SNAKE_CASE:						Tuple			,     _SCREAMING_SNAKE_CASE:						Optional[Any]			,     _SCREAMING_SNAKE_CASE:						Tuple			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						List[str])							->			Union[str, Any]:

				"""simple docstring"""

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

	def 				_SCREAMING_SNAKE_CASE  (	self:						int			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						Optional[int]			,     _SCREAMING_SNAKE_CASE:						Dict			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						Tuple			,     _SCREAMING_SNAKE_CASE:						List[Any])							->			Optional[int]:

				"""simple docstring"""

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

	def 				_SCREAMING_SNAKE_CASE  (	self:						Dict			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]			,     _SCREAMING_SNAKE_CASE:						Tuple			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						str			,     _SCREAMING_SNAKE_CASE:						Optional[int]			,     _SCREAMING_SNAKE_CASE:						Optional[Any]			,     _SCREAMING_SNAKE_CASE:						Optional[Any])							->			List[Any]:

				"""simple docstring"""

				__lowerCAmelCase :    Tuple				=			TFConvBertForQuestionAnswering(config=_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase :    Dict				=			{
				    "input_ids": input_ids,
				    "attention_mask": input_mask,
				    "token_type_ids": token_type_ids,
				}

				__lowerCAmelCase :    int				=			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:						Tuple)							->			Optional[Any]:

				"""simple docstring"""

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






@require_tf
class      A__  (    __SCREAMING_SNAKE_CASE    ,						__SCREAMING_SNAKE_CASE    ,						unittest.TestCase				):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE        =      (
	    (
	        TFConvBertModel,
	        TFConvBertForMaskedLM,
	        TFConvBertForQuestionAnswering,
	        TFConvBertForSequenceClassification,
	        TFConvBertForTokenClassification,
	        TFConvBertForMultipleChoice,
	    )
	    if is_tf_available()
	    else ()
	)
	SCREAMING_SNAKE_CASE        =      (
	    {
	        'feature-extraction': TFConvBertModel,
	        'fill-mask': TFConvBertForMaskedLM,
	        'question-answering': TFConvBertForQuestionAnswering,
	        'text-classification': TFConvBertForSequenceClassification,
	        'token-classification': TFConvBertForTokenClassification,
	        'zero-shot': TFConvBertForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	SCREAMING_SNAKE_CASE        =      False
	SCREAMING_SNAKE_CASE        =      False
	SCREAMING_SNAKE_CASE        =      False

	def 				_SCREAMING_SNAKE_CASE  (	self:						Tuple)							->			List[str]:

				"""simple docstring"""

				__lowerCAmelCase :    int				=			TFConvBertModelTester(self)
				__lowerCAmelCase :    Any				=			ConfigTester(self			,     config_class=_SCREAMING_SNAKE_CASE			,     hidden_size=37)

	def 				_SCREAMING_SNAKE_CASE  (	self:						Dict)							->			List[Any]:

				"""simple docstring"""

				self.config_tester.run_common_tests()

	def 				_SCREAMING_SNAKE_CASE  (	self:						Tuple)							->			Any:

				"""simple docstring"""

				__lowerCAmelCase :    Tuple				=			self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE)

	def 				_SCREAMING_SNAKE_CASE  (	self:						Dict)							->			Dict:

				"""simple docstring"""

				__lowerCAmelCase :    Optional[Any]				=			self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_masked_lm(*_SCREAMING_SNAKE_CASE)

	def 				_SCREAMING_SNAKE_CASE  (	self:						Dict)							->			List[str]:

				"""simple docstring"""

				__lowerCAmelCase :    Dict				=			self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_multiple_choice(*_SCREAMING_SNAKE_CASE)

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

				"""simple docstring"""

				__lowerCAmelCase :    Optional[int]				=			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])							->			Optional[int]:

				"""simple docstring"""

				__lowerCAmelCase :    Dict				=			self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_sequence_classification(*_SCREAMING_SNAKE_CASE)

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

				"""simple docstring"""

				__lowerCAmelCase :    Dict				=			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:						int)							->			List[str]:

				"""simple docstring"""

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

				if hasattr(_SCREAMING_SNAKE_CASE			,     "use_cache"):
							__lowerCAmelCase :    int				=			True

				__lowerCAmelCase :    Any				=			getattr(self.model_tester			,     "encoder_seq_length"			,     self.model_tester.seq_length)
				__lowerCAmelCase :    int				=			getattr(self.model_tester			,     "key_length"			,     _SCREAMING_SNAKE_CASE)

				for model_class in self.all_model_classes:
							__lowerCAmelCase :    List[str]				=			self._prepare_for_class(_SCREAMING_SNAKE_CASE			,     _SCREAMING_SNAKE_CASE)
							__lowerCAmelCase :    int				=			model_class(_SCREAMING_SNAKE_CASE)
							__lowerCAmelCase :    str				=			len(model(_SCREAMING_SNAKE_CASE))

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

										if self.is_encoder_decoder:
													__lowerCAmelCase :    Tuple				=			outputs["encoder_hidden_states"]
													__lowerCAmelCase :    str				=			outputs["encoder_attentions"]
										else:
													__lowerCAmelCase :    List[str]				=			outputs["hidden_states"]
													__lowerCAmelCase :    List[Any]				=			outputs["attentions"]

										self.assertEqual(len(_SCREAMING_SNAKE_CASE)			,     _SCREAMING_SNAKE_CASE)

										__lowerCAmelCase :    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:						Union[str, Any])							->			Optional[int]:

				"""simple docstring"""

				__lowerCAmelCase :    Dict				=			TFConvBertModel.from_pretrained("YituTech/conv-bert-base")
				self.assertIsNotNone(_SCREAMING_SNAKE_CASE)







	def 				_SCREAMING_SNAKE_CASE  (	self:						Dict)							->			Tuple:

				"""simple docstring"""

				__lowerCAmelCase		,      __lowerCAmelCase :    Optional[int]				=			self.model_tester.prepare_config_and_inputs_for_common()
				__lowerCAmelCase :    Optional[Any]				=			True
				__lowerCAmelCase :    List[Any]				=			getattr(self.model_tester			,     "decoder_seq_length"			,     self.model_tester.seq_length)
				__lowerCAmelCase :    Dict				=			getattr(self.model_tester			,     "encoder_seq_length"			,     self.model_tester.seq_length)
				__lowerCAmelCase :    Optional[int]				=			getattr(self.model_tester			,     "key_length"			,     _SCREAMING_SNAKE_CASE)
				__lowerCAmelCase :    Dict				=			getattr(self.model_tester			,     "key_length"			,     _SCREAMING_SNAKE_CASE)

				def check_decoder_attentions_output(_SCREAMING_SNAKE_CASE:						List[Any]):
							__lowerCAmelCase :    List[str]				=			len(_SCREAMING_SNAKE_CASE)
							self.assertEqual(out_len % 2			,     0)
							__lowerCAmelCase :    Optional[Any]				=			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:						Optional[int]):
							__lowerCAmelCase :    Dict				=			[
							    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:
							__lowerCAmelCase :    List[str]				=			True
							__lowerCAmelCase :    str				=			False
							__lowerCAmelCase :    Any				=			model_class(_SCREAMING_SNAKE_CASE)
							__lowerCAmelCase :    Union[str, Any]				=			model(self._prepare_for_class(_SCREAMING_SNAKE_CASE			,     _SCREAMING_SNAKE_CASE))
							__lowerCAmelCase :    str				=			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:
										__lowerCAmelCase :    Dict				=			model_class(_SCREAMING_SNAKE_CASE)
										__lowerCAmelCase :    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"]
							__lowerCAmelCase :    Union[str, Any]				=			True
							__lowerCAmelCase :    Optional[int]				=			model_class(_SCREAMING_SNAKE_CASE)
							__lowerCAmelCase :    List[str]				=			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
							__lowerCAmelCase :    Tuple				=			True
							__lowerCAmelCase :    Tuple				=			True
							__lowerCAmelCase :    int				=			model_class(_SCREAMING_SNAKE_CASE)
							__lowerCAmelCase :    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      A__  (    unittest.TestCase				):




	'''simple docstring'''





	@slow
	def 				_SCREAMING_SNAKE_CASE  (	self:						str)							->			Any:

				"""simple docstring"""

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

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

				__lowerCAmelCase :    Optional[int]				=			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"""






def      _lowercase							(    __snake_case   ,__snake_case      )		->  Tuple:
			# "extended trapezoidal rule"
			# int(f) = dx/2 * (f1 + 2f2 + ... + fn)
			__lowerCAmelCase :    Optional[Any]				=			(boundary[1] - boundary[0]) / steps
			__lowerCAmelCase :    List[Any]				=			boundary[0]
			__lowerCAmelCase :    Any				=			boundary[1]
			__lowerCAmelCase :    Dict				=			make_points(__snake_case   ,__snake_case   ,__snake_case      )
			__lowerCAmelCase :    List[str]				=			0.0
			y += (h / 2.0) * f(__snake_case      )
			for i in x_i:
						# print(i)
						y += h * f(__snake_case      )
			y += (h / 2.0) * f(__snake_case      )
			return y


def      _lowercase							(    __snake_case   ,__snake_case   ,__snake_case      )		->  Union[str, Any]:
			__lowerCAmelCase :    int				=			a + h
			while x < (b - h):
						yield x
						__lowerCAmelCase :    List[str]				=			x + h


def      _lowercase							(    __snake_case      )		->  Tuple:  # enter your function here
			__lowerCAmelCase :    int				=			(x - 0) * (x - 0)
			return y


def      _lowercase							(    )		->  int:
			__lowerCAmelCase :    Tuple				=			0.0  # Lower bound of integration
			__lowerCAmelCase :    Union[str, Any]				=			1.0  # Upper bound of integration
			__lowerCAmelCase :    Dict				=			10.0  # define number of steps or resolution
			__lowerCAmelCase :    Optional[Any]				=			[a, b]  # define boundary of integration
			__lowerCAmelCase :    Optional[int]				=			method_a(__snake_case   ,__snake_case      )
			print(F"""y = {y}"""      )


if __name__ == "__main__":
	main()