




'''simple docstring'''

import tempfile
import unittest
from pathlib import Path
from shutil import copyfile

from transformers import BatchEncoding, MarianTokenizer
from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow
from transformers.utils import is_sentencepiece_available, is_tf_available, is_torch_available


if is_sentencepiece_available():
							from transformers.models.marian.tokenization_marian import VOCAB_FILES_NAMES, save_json

from ...test_tokenization_common import TokenizerTesterMixin


a    :							Dict										=    get_tests_dir('fixtures/test_sentencepiece.model')

a    :							Union[str, Any]										=    {'target_lang': 'fi', 'source_lang': 'en'}
a    :							Any										=    '>>zh<<'
a    :							Optional[int]										=    'Helsinki-NLP/'

if is_torch_available():
							a    :							List[Any]										=    'pt'
elif is_tf_available():
							a    :							Union[str, Any]										=    'tf'
else:
							a    :							Any										=    'jax'






@require_sentencepiece
class 		a							(  _lowerCamelCase  ,	unittest.TestCase	):
				snake_case_           =						MarianTokenizer
				snake_case_           =						False
				snake_case_           =						True


				def     A_					(						self       :   str   ):
									super().setUp()
									snake_case_		     =							['''</s>''', '''<unk>''', '''▁This''', '''▁is''', '''▁a''', '''▁t''', '''est''', '''\u0120''', '''<pad>''']
									snake_case_		     =							dict(zip(lowercase_			,							range(len(lowercase_   )   )   )   )
									snake_case_		     =							Path(self.tmpdirname   )
									save_json(lowercase_			,							save_dir / VOCAB_FILES_NAMES['''vocab''']   )
									save_json(lowercase_			,							save_dir / VOCAB_FILES_NAMES['''tokenizer_config_file''']   )
									if not (save_dir / VOCAB_FILES_NAMES["source_spm"]).exists():
														copyfile(lowercase_			,							save_dir / VOCAB_FILES_NAMES['''source_spm''']   )
														copyfile(lowercase_			,							save_dir / VOCAB_FILES_NAMES['''target_spm''']   )

									snake_case_		     =							MarianTokenizer.from_pretrained(self.tmpdirname   )
									tokenizer.save_pretrained(self.tmpdirname   )


				def     A_					(						self       :   Optional[Any]			,							**lowercase_       :   List[str]   ):
									return MarianTokenizer.from_pretrained(self.tmpdirname			,							**lowercase_   )


				def     A_					(						self       :   Dict			,							lowercase_       :   Tuple   ):
									return (
									    "This is a test",
									    "This is a test",
									)


				def     A_					(						self       :   Any   ):
									snake_case_		     =							'''</s>'''
									snake_case_		     =							0

									self.assertEqual(self.get_tokenizer()._convert_token_to_id(lowercase_   )			,							lowercase_   )
									self.assertEqual(self.get_tokenizer()._convert_id_to_token(lowercase_   )			,							lowercase_   )


				def     A_					(						self       :   int   ):
									snake_case_		     =							list(self.get_tokenizer().get_vocab().keys()   )

									self.assertEqual(vocab_keys[0]			,							'''</s>'''   )
									self.assertEqual(vocab_keys[1]			,							'''<unk>'''   )
									self.assertEqual(vocab_keys[-1]			,							'''<pad>'''   )
									self.assertEqual(len(lowercase_   )			,							9   )


				def     A_					(						self       :   List[str]   ):
									self.assertEqual(self.get_tokenizer().vocab_size			,							9   )


				def     A_					(						self       :   Tuple   ):
									snake_case_		     =							MarianTokenizer.from_pretrained(F"{ORG_NAME}opus-mt-en-de"   )
									snake_case_		     =							en_de_tokenizer(['''I am a small frog''']			,							return_tensors=lowercase_   )
									self.assertIsInstance(lowercase_			,							lowercase_   )
									snake_case_		     =							[38, 121, 14, 697, 3_8848, 0]
									self.assertListEqual(lowercase_			,							batch.input_ids[0]   )

									snake_case_		     =							tempfile.mkdtemp()
									en_de_tokenizer.save_pretrained(lowercase_   )
									snake_case_		     =							[x.name for x in Path(lowercase_   ).glob('''*'''   )]
									self.assertIn('''source.spm'''			,							lowercase_   )
									MarianTokenizer.from_pretrained(lowercase_   )


				def     A_					(						self       :   Any   ):
									snake_case_		     =							self.get_tokenizer()

									snake_case_		     =							tok(
									    ['''I am a small frog''' * 1000, '''I am a small frog''']			,							padding=lowercase_			,							truncation=lowercase_			,							return_tensors=lowercase_   )
									self.assertIsInstance(lowercase_			,							lowercase_   )
									self.assertEqual(batch.input_ids.shape			,							(2, 512)   )


				def     A_					(						self       :   Union[str, Any]   ):
									snake_case_		     =							self.get_tokenizer()
									snake_case_		     =							tok(['''I am a tiny frog''', '''I am a small frog''']			,							padding=lowercase_			,							return_tensors=lowercase_   )
									self.assertIsInstance(lowercase_			,							lowercase_   )
									self.assertEqual(batch_smaller.input_ids.shape			,							(2, 10)   )


				@slow
				def     A_					(						self       :   Tuple   ):
									# fmt: off
									snake_case_		     =							{'''input_ids''': [[4_3495, 462, 20, 4_2164, 1369, 52, 464, 132, 1703, 492, 13, 7491, 3_8999, 6, 8, 464, 132, 1703, 492, 13, 4669, 3_7867, 13, 7525, 27, 1593, 988, 13, 3_3972, 7029, 6, 20, 8251, 383, 2, 270, 5866, 3788, 2, 2353, 8251, 1_2338, 2, 1_3958, 387, 2, 3629, 6953, 188, 2900, 2, 1_3958, 8011, 1_1501, 23, 8460, 4073, 3_4009, 20, 435, 1_1439, 27, 8, 8460, 4073, 6004, 20, 9988, 375, 27, 33, 266, 1945, 1076, 1350, 3_7867, 3288, 5, 577, 1076, 4374, 8, 5082, 5, 2_6453, 257, 556, 403, 2, 242, 132, 383, 316, 492, 8, 1_0767, 6, 316, 304, 4239, 3, 0], [148, 1_5722, 19, 1839, 12, 1350, 13, 2_2327, 5082, 5418, 4_7567, 3_5938, 59, 318, 1_9552, 108, 2183, 54, 1_4976, 4835, 32, 547, 1114, 8, 315, 2417, 5, 92, 1_9088, 3, 0, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100], [36, 6395, 1_2570, 3_9147, 1_1597, 6, 266, 4, 4_5405, 7296, 3, 0, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100, 5_8100]], '''attention_mask''': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
									# fmt: on

									self.tokenizer_integration_test_util(
									    expected_encoding=lowercase_			,							model_name='''Helsinki-NLP/opus-mt-en-de'''			,							revision='''1a8c2263da11e68e50938f97e10cd57820bd504c'''			,							decode_kwargs={'''use_source_tokenizer''': True}			,							)


				def     A_					(						self       :   int   ):
									snake_case_		     =							MarianTokenizer.from_pretrained('''hf-internal-testing/test-marian-two-vocabs'''   )

									snake_case_		     =							'''Tämä on testi'''
									snake_case_		     =							'''This is a test'''

									snake_case_		     =							[76, 7, 2047, 2]
									snake_case_		     =							[69, 12, 11, 940, 2]

									snake_case_		     =							tokenizer(lowercase_   ).input_ids
									self.assertListEqual(lowercase_			,							lowercase_   )

									snake_case_		     =							tokenizer(text_target=lowercase_   ).input_ids
									self.assertListEqual(lowercase_			,							lowercase_   )

									snake_case_		     =							tokenizer.decode(lowercase_			,							skip_special_tokens=lowercase_   )
									self.assertEqual(lowercase_			,							lowercase_   )







'''simple docstring'''

from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

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 (
							    TFFunnelBaseModel,
							    TFFunnelForMaskedLM,
							    TFFunnelForMultipleChoice,
							    TFFunnelForPreTraining,
							    TFFunnelForQuestionAnswering,
							    TFFunnelForSequenceClassification,
							    TFFunnelForTokenClassification,
							    TFFunnelModel,
							)






class 		a							:


				def __init__(						self       :   Dict			,							lowercase_       :   str			,							lowercase_       :   Union[str, Any]=13			,							lowercase_       :   Union[str, Any]=7			,							lowercase_       :   Tuple=True			,							lowercase_       :   int=True			,							lowercase_       :   Dict=True			,							lowercase_       :   Any=True			,							lowercase_       :   Union[str, Any]=99			,							lowercase_       :   Tuple=[1, 1, 2]			,							lowercase_       :   List[Any]=1			,							lowercase_       :   int=32			,							lowercase_       :   List[Any]=4			,							lowercase_       :   Tuple=8			,							lowercase_       :   Union[str, Any]=37			,							lowercase_       :   Union[str, Any]="gelu_new"			,							lowercase_       :   str=0.1			,							lowercase_       :   Tuple=0.1			,							lowercase_       :   Optional[int]=0.0			,							lowercase_       :   Optional[int]=512			,							lowercase_       :   int=3			,							lowercase_       :   Dict=0.02			,							lowercase_       :   Union[str, Any]=3			,							lowercase_       :   Dict=4			,							lowercase_       :   List[str]=None			,							lowercase_       :   Tuple=False			,							):
									snake_case_		     =							parent
									snake_case_		     =							batch_size
									snake_case_		     =							seq_length
									snake_case_		     =							is_training
									snake_case_		     =							use_input_mask
									snake_case_		     =							use_token_type_ids
									snake_case_		     =							use_labels
									snake_case_		     =							vocab_size
									snake_case_		     =							block_sizes
									snake_case_		     =							num_decoder_layers
									snake_case_		     =							d_model
									snake_case_		     =							n_head
									snake_case_		     =							d_head
									snake_case_		     =							d_inner
									snake_case_		     =							hidden_act
									snake_case_		     =							hidden_dropout
									snake_case_		     =							attention_dropout
									snake_case_		     =							activation_dropout
									snake_case_		     =							max_position_embeddings
									snake_case_		     =							type_vocab_size
									snake_case_		     =							2
									snake_case_		     =							num_labels
									snake_case_		     =							num_choices
									snake_case_		     =							scope
									snake_case_		     =							initializer_std

									# Used in the tests to check the size of the first attention layer
									snake_case_		     =							n_head
									# Used in the tests to check the size of the first hidden state
									snake_case_		     =							self.d_model
									# Used in the tests to check the number of output hidden states/attentions
									snake_case_		     =							sum(self.block_sizes   ) + (0 if base else self.num_decoder_layers)
									# FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
									# the last hidden state of the first block (which is the first hidden state of the decoder).
									if not base:
														snake_case_		     =							self.num_hidden_layers + 2


				def     A_					(						self       :   Union[str, Any]   ):
									snake_case_		     =							ids_tensor([self.batch_size, self.seq_length]			,							self.vocab_size   )

									snake_case_		     =							None
									if self.use_input_mask:
														snake_case_		     =							random_attention_mask([self.batch_size, self.seq_length]   )

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

									snake_case_		     =							None
									snake_case_		     =							None
									snake_case_		     =							None
									if self.use_labels:
														snake_case_		     =							ids_tensor([self.batch_size]			,							self.type_sequence_label_size   )
														snake_case_		     =							ids_tensor([self.batch_size, self.seq_length]			,							self.num_labels   )
														snake_case_		     =							ids_tensor([self.batch_size]			,							self.num_choices   )

									snake_case_		     =							FunnelConfig(
									    vocab_size=self.vocab_size			,							block_sizes=self.block_sizes			,							num_decoder_layers=self.num_decoder_layers			,							d_model=self.d_model			,							n_head=self.n_head			,							d_head=self.d_head			,							d_inner=self.d_inner			,							hidden_act=self.hidden_act			,							hidden_dropout=self.hidden_dropout			,							attention_dropout=self.attention_dropout			,							activation_dropout=self.activation_dropout			,							max_position_embeddings=self.max_position_embeddings			,							type_vocab_size=self.type_vocab_size			,							initializer_std=self.initializer_std			,							)

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


				def     A_					(						self       :   Optional[Any]			,							lowercase_       :   int			,							lowercase_       :   Tuple			,							lowercase_       :   List[str]			,							lowercase_       :   Union[str, Any]			,							lowercase_       :   Optional[int]			,							lowercase_       :   List[Any]			,							lowercase_       :   Optional[int]			,							):
									snake_case_		     =							TFFunnelModel(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(lowercase_   )

									snake_case_		     =							[input_ids, input_mask]
									snake_case_		     =							model(lowercase_   )

									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, self.seq_length, self.d_model)   )

									snake_case_		     =							False
									snake_case_		     =							TFFunnelModel(config=lowercase_   )
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, self.seq_length, self.d_model)   )

									snake_case_		     =							False
									snake_case_		     =							TFFunnelModel(config=lowercase_   )
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, self.seq_length, self.d_model)   )


				def     A_					(						self       :   List[Any]			,							lowercase_       :   Tuple			,							lowercase_       :   Dict			,							lowercase_       :   List[Any]			,							lowercase_       :   Dict			,							lowercase_       :   int			,							lowercase_       :   int			,							lowercase_       :   List[Any]			,							):
									snake_case_		     =							TFFunnelBaseModel(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(lowercase_   )

									snake_case_		     =							[input_ids, input_mask]
									snake_case_		     =							model(lowercase_   )

									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, 2, self.d_model)   )

									snake_case_		     =							False
									snake_case_		     =							TFFunnelBaseModel(config=lowercase_   )
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, 3, self.d_model)   )

									snake_case_		     =							False
									snake_case_		     =							TFFunnelBaseModel(config=lowercase_   )
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, 2, self.d_model)   )


				def     A_					(						self       :   Any			,							lowercase_       :   Optional[int]			,							lowercase_       :   str			,							lowercase_       :   int			,							lowercase_       :   Optional[int]			,							lowercase_       :   Optional[int]			,							lowercase_       :   Dict			,							lowercase_       :   Union[str, Any]			,							):
									snake_case_		     =							TFFunnelForPreTraining(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.seq_length)   )


				def     A_					(						self       :   Any			,							lowercase_       :   Union[str, Any]			,							lowercase_       :   Tuple			,							lowercase_       :   str			,							lowercase_       :   Tuple			,							lowercase_       :   List[str]			,							lowercase_       :   Union[str, Any]			,							lowercase_       :   Union[str, Any]			,							):
									snake_case_		     =							TFFunnelForMaskedLM(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.seq_length, self.vocab_size)   )


				def     A_					(						self       :   Dict			,							lowercase_       :   Dict			,							lowercase_       :   str			,							lowercase_       :   Optional[Any]			,							lowercase_       :   Tuple			,							lowercase_       :   Optional[Any]			,							lowercase_       :   Tuple			,							lowercase_       :   Tuple			,							):
									snake_case_		     =							self.num_labels
									snake_case_		     =							TFFunnelForSequenceClassification(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.num_labels)   )


				def     A_					(						self       :   int			,							lowercase_       :   Optional[int]			,							lowercase_       :   Any			,							lowercase_       :   List[str]			,							lowercase_       :   Optional[int]			,							lowercase_       :   str			,							lowercase_       :   str			,							lowercase_       :   int			,							):
									snake_case_		     =							self.num_choices
									snake_case_		     =							TFFunnelForMultipleChoice(config=lowercase_   )
									snake_case_		     =							tf.tile(tf.expand_dims(lowercase_			,							1   )			,							(1, self.num_choices, 1)   )
									snake_case_		     =							tf.tile(tf.expand_dims(lowercase_			,							1   )			,							(1, self.num_choices, 1)   )
									snake_case_		     =							tf.tile(tf.expand_dims(lowercase_			,							1   )			,							(1, self.num_choices, 1)   )
									snake_case_		     =							{
									    '''input_ids''': multiple_choice_inputs_ids,
									    '''attention_mask''': multiple_choice_input_mask,
									    '''token_type_ids''': multiple_choice_token_type_ids,
									}
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.num_choices)   )


				def     A_					(						self       :   Any			,							lowercase_       :   str			,							lowercase_       :   Dict			,							lowercase_       :   int			,							lowercase_       :   Optional[int]			,							lowercase_       :   List[str]			,							lowercase_       :   Any			,							lowercase_       :   Optional[Any]			,							):
									snake_case_		     =							self.num_labels
									snake_case_		     =							TFFunnelForTokenClassification(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(lowercase_   )
									self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.seq_length, self.num_labels)   )


				def     A_					(						self       :   Optional[Any]			,							lowercase_       :   Any			,							lowercase_       :   Dict			,							lowercase_       :   Any			,							lowercase_       :   int			,							lowercase_       :   Tuple			,							lowercase_       :   List[str]			,							lowercase_       :   Optional[Any]			,							):
									snake_case_		     =							TFFunnelForQuestionAnswering(config=lowercase_   )
									snake_case_		     =							{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
									snake_case_		     =							model(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     A_					(						self       :   Any   ):
									snake_case_		     =							self.prepare_config_and_inputs()
									(
									    (
									    snake_case_
									)     ,(
									    snake_case_
									)     ,(
									    snake_case_
									)     ,(
									    snake_case_
									)     ,(
									    snake_case_
									)     ,(
									    snake_case_
									)     ,(
									    snake_case_
									)     ,
									)		     =							config_and_inputs
									snake_case_		     =							{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
									return config, inputs_dict







@require_tf
class 		a							(  _lowerCamelCase  ,	_lowerCamelCase  ,	unittest.TestCase	):
				snake_case_           =						(
				    (
				        TFFunnelModel,
				        TFFunnelForMaskedLM,
				        TFFunnelForPreTraining,
				        TFFunnelForQuestionAnswering,
				        TFFunnelForTokenClassification,
				    )
				    if is_tf_available()
				    else ()
				)
				snake_case_           =						(
				    {
				        "feature-extraction": (TFFunnelBaseModel, TFFunnelModel),
				        "fill-mask": TFFunnelForMaskedLM,
				        "question-answering": TFFunnelForQuestionAnswering,
				        "text-classification": TFFunnelForSequenceClassification,
				        "token-classification": TFFunnelForTokenClassification,
				        "zero-shot": TFFunnelForSequenceClassification,
				    }
				    if is_tf_available()
				    else {}
				)
				snake_case_           =						False
				snake_case_           =						False


				def     A_					(						self       :   int   ):
									snake_case_		     =							TFFunnelModelTester(self   )
									snake_case_		     =							ConfigTester(self			,							config_class=lowercase_   )


				def     A_					(						self       :   Union[str, Any]   ):
									self.config_tester.run_common_tests()


				def     A_					(						self       :   List[Any]   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*lowercase_   )


				def     A_					(						self       :   List[str]   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_pretraining(*lowercase_   )


				def     A_					(						self       :   str   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_lm(*lowercase_   )


				def     A_					(						self       :   List[str]   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_token_classification(*lowercase_   )


				def     A_					(						self       :   List[Any]   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_question_answering(*lowercase_   )







@require_tf
class 		a							(  _lowerCamelCase  ,	unittest.TestCase	):
				snake_case_           =						(
				    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
				)
				snake_case_           =						False
				snake_case_           =						False


				def     A_					(						self       :   Union[str, Any]   ):
									snake_case_		     =							TFFunnelModelTester(self			,							base=lowercase_   )
									snake_case_		     =							ConfigTester(self			,							config_class=lowercase_   )


				def     A_					(						self       :   Dict   ):
									self.config_tester.run_common_tests()


				def     A_					(						self       :   List[str]   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_base_model(*lowercase_   )


				def     A_					(						self       :   Union[str, Any]   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_sequence_classification(*lowercase_   )


				def     A_					(						self       :   str   ):
									snake_case_		     =							self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_multiple_choice(*lowercase_   )

