






'''simple docstring'''







import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase   )   -> Tuple:




							def wrapper(*UpperCamelCase       ,    **UpperCamelCase   ):
														lowerCamelCase__      :			List[str] 						= timeit.default_timer()
														lowerCamelCase__      :			int 						= func(*UpperCamelCase       ,    **UpperCamelCase   )
														lowerCamelCase__      :			Tuple 						= timeit.default_timer() - starttime
														return delta

							lowerCamelCase__      :			str 						= func.__name__

							return wrapper





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase=100       ,    UpperCamelCase=None   )   -> str:
							lowerCamelCase__      :			Any 						= []
							lowerCamelCase__      :			int 						= seq_shapes or {}
							for i in range(UpperCamelCase   ):
														lowerCamelCase__      :			Optional[Any] 						= {}
														for col_id, (k, v) in enumerate(features.items()   ):
																					if isinstance(UpperCamelCase       ,    _ArrayXD   ):
																												lowerCamelCase__      :			Tuple 						= np.random.rand(*v.shape   ).astype(v.dtype   )
																					elif isinstance(UpperCamelCase       ,    datasets.Value   ):
																												if v.dtype == "string":
																																			lowerCamelCase__      :			int 						= """The small grey turtle was surprisingly fast when challenged."""
																												else:
																																			lowerCamelCase__      :			List[Any] 						= np.random.randint(10       ,    size=1   ).astype(v.dtype   ).item()
																					elif isinstance(UpperCamelCase       ,    datasets.Sequence   ):
																												while isinstance(UpperCamelCase       ,    datasets.Sequence   ):
																																			lowerCamelCase__      :			str 						= v.feature
																												lowerCamelCase__      :			Any 						= seq_shapes[k]
																												lowerCamelCase__      :			Dict 						= np.random.rand(*UpperCamelCase   ).astype(v.dtype   )
																					lowerCamelCase__      :			str 						= data

														dummy_data.append((i, example)   )

							return dummy_data





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase=100       ,    UpperCamelCase=None   )   -> int:
							lowerCamelCase__      :			List[Any] 						= generate_examples(UpperCamelCase       ,    num_examples=UpperCamelCase       ,    seq_shapes=UpperCamelCase   )

							with ArrowWriter(features=UpperCamelCase       ,    path=UpperCamelCase   ) as writer:
														for key, record in dummy_data:
																					lowerCamelCase__      :			Union[str, Any] 						= features.encode_example(UpperCamelCase   )
																					writer.write(UpperCamelCase   )

														lowerCamelCase__						,	lowerCamelCase__      :			str 						= writer.finalize()

							if not num_final_examples == num_examples:
														raise ValueError(
														    f'''Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}.'''   )

							lowerCamelCase__      :			int 						= datasets.Dataset.from_file(filename=UpperCamelCase       ,    info=datasets.DatasetInfo(features=UpperCamelCase   )   )

							return dataset









'''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 _lowercase			:




							def __init__(							self:       int    ,							UpperCamelCase__:       Dict    ,							UpperCamelCase__:       List[str]=13    ,							UpperCamelCase__:       Union[str, Any]=7    ,							UpperCamelCase__:       Union[str, Any]=True    ,							UpperCamelCase__:       List[Any]=True    ,							UpperCamelCase__:       Optional[Any]=True    ,							UpperCamelCase__:       int=True    ,							UpperCamelCase__:       List[Any]=99    ,							UpperCamelCase__:       Tuple=32    ,							UpperCamelCase__:       List[str]=2    ,							UpperCamelCase__:       Optional[Any]=4    ,							UpperCamelCase__:       Optional[int]=37    ,							UpperCamelCase__:       Any="gelu"    ,							UpperCamelCase__:       Any=0.1    ,							UpperCamelCase__:       int=0.1    ,							UpperCamelCase__:       Optional[Any]=512    ,							UpperCamelCase__:       List[str]=16    ,							UpperCamelCase__:       Optional[int]=2    ,							UpperCamelCase__:       Dict=0.02    ,							UpperCamelCase__:       Tuple=3    ,							UpperCamelCase__:       Optional[int]=4    ,							UpperCamelCase__:       Union[str, Any]=None    ,							):
														lowerCamelCase__      :			Dict 						= parent
														lowerCamelCase__      :			Union[str, Any] 						= 13
														lowerCamelCase__      :			Any 						= 7
														lowerCamelCase__      :			int 						= True
														lowerCamelCase__      :			Optional[Any] 						= True
														lowerCamelCase__      :			Dict 						= True
														lowerCamelCase__      :			List[str] 						= True
														lowerCamelCase__      :			str 						= 99
														lowerCamelCase__      :			Dict 						= 384
														lowerCamelCase__      :			Optional[Any] 						= 2
														lowerCamelCase__      :			Optional[int] 						= 4
														lowerCamelCase__      :			Optional[Any] 						= 37
														lowerCamelCase__      :			Union[str, Any] 						= """gelu"""
														lowerCamelCase__      :			int 						= 0.1
														lowerCamelCase__      :			Optional[Any] 						= 0.1
														lowerCamelCase__      :			List[Any] 						= 512
														lowerCamelCase__      :			Optional[Any] 						= 16
														lowerCamelCase__      :			Any 						= 2
														lowerCamelCase__      :			Optional[Any] 						= 0.02
														lowerCamelCase__      :			int 						= 3
														lowerCamelCase__      :			List[str] 						= 4
														lowerCamelCase__      :			Any 						= 128
														lowerCamelCase__      :			List[Any] 						= 2
														lowerCamelCase__      :			Optional[Any] 						= 9
														lowerCamelCase__      :			Any 						= 1
														lowerCamelCase__      :			Optional[int] 						= None




							def 	lowerCamelCase_       (							self:       List[Any]  ):
														lowerCamelCase__      :			Tuple 						= ids_tensor([self.batch_size, self.seq_length]    ,							self.vocab_size  )

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

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

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

														lowerCamelCase__      :			List[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=UpperCamelCase__    ,							)

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




							def 	lowerCamelCase_       (							self:       Optional[int]    ,							UpperCamelCase__:       Dict    ,							UpperCamelCase__:       List[str]    ,							UpperCamelCase__:       Any    ,							UpperCamelCase__:       Any    ,							UpperCamelCase__:       Any    ,							UpperCamelCase__:       str    ,							UpperCamelCase__:       Any  ):
														lowerCamelCase__      :			List[Any] 						= TFConvBertModel(config=UpperCamelCase__  )
														lowerCamelCase__      :			str 						= {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

														lowerCamelCase__      :			List[str] 						= [input_ids, input_mask]
														lowerCamelCase__      :			Optional[int] 						= model(UpperCamelCase__  )

														lowerCamelCase__      :			Optional[Any] 						= model(UpperCamelCase__  )

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




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




							def 	lowerCamelCase_       (							self:       str    ,							UpperCamelCase__:       List[str]    ,							UpperCamelCase__:       Optional[int]    ,							UpperCamelCase__:       List[Any]    ,							UpperCamelCase__:       Optional[int]    ,							UpperCamelCase__:       Any    ,							UpperCamelCase__:       Any    ,							UpperCamelCase__:       Union[str, Any]  ):
														lowerCamelCase__      :			int 						= self.num_labels
														lowerCamelCase__      :			Dict 						= TFConvBertForSequenceClassification(config=UpperCamelCase__  )
														lowerCamelCase__      :			Dict 						= {
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}

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




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




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




							def 	lowerCamelCase_       (							self:       Any    ,							UpperCamelCase__:       List[Any]    ,							UpperCamelCase__:       str    ,							UpperCamelCase__:       Tuple    ,							UpperCamelCase__:       Optional[int]    ,							UpperCamelCase__:       Optional[Any]    ,							UpperCamelCase__:       List[str]    ,							UpperCamelCase__:       Optional[Any]  ):
														lowerCamelCase__      :			Optional[int] 						= TFConvBertForQuestionAnswering(config=UpperCamelCase__  )
														lowerCamelCase__      :			int 						= {
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}

														lowerCamelCase__      :			Optional[int] 						= model(UpperCamelCase__  )
														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:       Optional[Any]  ):
														lowerCamelCase__      :			str 						= self.prepare_config_and_inputs()
														(
														    (
														    lowerCamelCase__
														)						,	(
														    lowerCamelCase__
														)						,	(
														    lowerCamelCase__
														)						,	(
														    lowerCamelCase__
														)						,	(
														    lowerCamelCase__
														)						,	(
														    lowerCamelCase__
														)						,	(
														    lowerCamelCase__
														)						,	
														)      :			str 						= config_and_inputs
														lowerCamelCase__      :			Optional[Any] 						= {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
														return config, inputs_dict



@require_tf
class _lowercase			(       _lowercase       ,   _lowercase       ,   unittest.TestCase	):
							a          = (
							    (
							        TFConvBertModel,
							        TFConvBertForMaskedLM,
							        TFConvBertForQuestionAnswering,
							        TFConvBertForSequenceClassification,
							        TFConvBertForTokenClassification,
							        TFConvBertForMultipleChoice,
							    )
							    if is_tf_available()
							    else ()
							)
							a          = (
							    {
							        """feature-extraction""": TFConvBertModel,
							        """fill-mask""": TFConvBertForMaskedLM,
							        """question-answering""": TFConvBertForQuestionAnswering,
							        """text-classification""": TFConvBertForSequenceClassification,
							        """token-classification""": TFConvBertForTokenClassification,
							        """zero-shot""": TFConvBertForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							a          = False
							a          = False
							a          = False




							def 	lowerCamelCase_       (							self:       str  ):
														lowerCamelCase__      :			Dict 						= TFConvBertModelTester(self  )
														lowerCamelCase__      :			Dict 						= ConfigTester(self    ,							config_class=UpperCamelCase__    ,							hidden_size=37  )




							def 	lowerCamelCase_       (							self:       List[str]  ):
														self.config_tester.run_common_tests()




							def 	lowerCamelCase_       (							self:       Union[str, Any]  ):
														lowerCamelCase__      :			List[str] 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Any  ):
														lowerCamelCase__      :			Dict 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_masked_lm(*UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Tuple  ):
														lowerCamelCase__      :			int 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_multiple_choice(*UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Union[str, Any]  ):
														lowerCamelCase__      :			int 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_question_answering(*UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Any  ):
														lowerCamelCase__      :			Union[str, Any] 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       str  ):
														lowerCamelCase__      :			Tuple 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_token_classification(*UpperCamelCase__  )




							@slow
							def 	lowerCamelCase_       (							self:       Optional[Any]  ):
														lowerCamelCase__						,	lowerCamelCase__      :			List[str] 						= self.model_tester.prepare_config_and_inputs_for_common()
														lowerCamelCase__      :			Dict 						= True
														lowerCamelCase__      :			Tuple 						= True

														if hasattr(UpperCamelCase__    ,							"""use_cache"""  ):
																					lowerCamelCase__      :			Union[str, Any] 						= True

														lowerCamelCase__      :			List[str] 						= getattr(self.model_tester    ,							"""encoder_seq_length"""    ,							self.model_tester.seq_length  )
														lowerCamelCase__      :			Tuple 						= getattr(self.model_tester    ,							"""key_length"""    ,							UpperCamelCase__  )

														for model_class in self.all_model_classes:
																					lowerCamelCase__      :			int 						= self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )
																					lowerCamelCase__      :			List[Any] 						= model_class(UpperCamelCase__  )
																					lowerCamelCase__      :			Dict 						= len(model(UpperCamelCase__  )  )

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

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

																												self.assertEqual(len(UpperCamelCase__  )    ,							UpperCamelCase__  )

																												lowerCamelCase__      :			Union[str, Any] 						= getattr(
																												    self.model_tester    ,							"""expected_num_hidden_layers"""    ,							self.model_tester.num_hidden_layers + 1  )

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

																												self.assertEqual(len(UpperCamelCase__  )    ,							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 	lowerCamelCase_       (							self:       int  ):
														lowerCamelCase__      :			Union[str, Any] 						= TFConvBertModel.from_pretrained("""YituTech/conv-bert-base"""  )
														self.assertIsNotNone(UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       List[str]  ):
														lowerCamelCase__						,	lowerCamelCase__      :			Any 						= self.model_tester.prepare_config_and_inputs_for_common()
														lowerCamelCase__      :			Union[str, Any] 						= True
														lowerCamelCase__      :			int 						= getattr(self.model_tester    ,							"""decoder_seq_length"""    ,							self.model_tester.seq_length  )
														lowerCamelCase__      :			Any 						= getattr(self.model_tester    ,							"""encoder_seq_length"""    ,							self.model_tester.seq_length  )
														lowerCamelCase__      :			Optional[int] 						= getattr(self.model_tester    ,							"""key_length"""    ,							UpperCamelCase__  )
														lowerCamelCase__      :			List[Any] 						= getattr(self.model_tester    ,							"""key_length"""    ,							UpperCamelCase__  )

														def check_decoder_attentions_output(UpperCamelCase__:       Union[str, Any]  ):
																					lowerCamelCase__      :			List[Any] 						= len(UpperCamelCase__  )
																					self.assertEqual(out_len % 2    ,							0  )
																					lowerCamelCase__      :			Any 						= outputs.decoder_attentions
																					self.assertEqual(len(UpperCamelCase__  )    ,							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(UpperCamelCase__:       List[str]  ):
																					lowerCamelCase__      :			Any 						= [
																					    t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
																					]
																					self.assertEqual(len(UpperCamelCase__  )    ,							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__      :			int 						= True
																					lowerCamelCase__      :			Any 						= False
																					lowerCamelCase__      :			Union[str, Any] 						= model_class(UpperCamelCase__  )
																					lowerCamelCase__      :			List[str] 						= model(self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )
																					lowerCamelCase__      :			Optional[int] 						= len(UpperCamelCase__  )
																					self.assertEqual(config.output_hidden_states    ,							UpperCamelCase__  )
																					check_encoder_attentions_output(UpperCamelCase__  )

																					if self.is_encoder_decoder:
																												lowerCamelCase__      :			str 						= model_class(UpperCamelCase__  )
																												lowerCamelCase__      :			Tuple 						= model(self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )
																												self.assertEqual(config.output_hidden_states    ,							UpperCamelCase__  )
																												check_decoder_attentions_output(UpperCamelCase__  )

																					# Check that output attentions can also be changed via the config
																					del inputs_dict["output_attentions"]
																					lowerCamelCase__      :			Optional[int] 						= True
																					lowerCamelCase__      :			Dict 						= model_class(UpperCamelCase__  )
																					lowerCamelCase__      :			Union[str, Any] 						= model(self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )
																					self.assertEqual(config.output_hidden_states    ,							UpperCamelCase__  )
																					check_encoder_attentions_output(UpperCamelCase__  )

																					# Check attention is always last and order is fine
																					lowerCamelCase__      :			List[Any] 						= True
																					lowerCamelCase__      :			int 						= True
																					lowerCamelCase__      :			List[Any] 						= model_class(UpperCamelCase__  )
																					lowerCamelCase__      :			List[Any] 						= model(self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )

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



@require_tf
class _lowercase			(       unittest.TestCase	):




							@slow
							def 	lowerCamelCase_       (							self:       List[str]  ):
														lowerCamelCase__      :			Dict 						= TFConvBertModel.from_pretrained("""YituTech/conv-bert-base"""  )
														lowerCamelCase__      :			Optional[Any] 						= tf.constant([[0, 1, 2, 3, 4, 5]]  )
														lowerCamelCase__      :			Optional[Any] 						= model(UpperCamelCase__  )[0]

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

														lowerCamelCase__      :			Dict 						= tf.constant(
														    [
														        [
														            [-0.03_475_493, -0.4_686_034, -0.30_638_832],
														            [0.22_637_248, -0.26_988_646, -0.7_423_424],
														            [0.10_324_868, -0.45_013_508, -0.58_280_784],
														        ]
														    ]  )
														tf.debugging.assert_near(output[:, :3, :3]    ,							UpperCamelCase__    ,							atol=1e-4  )

