



import json
import os
import tempfile
import unittest

import numpy as np
from datasets import load_dataset

from transformers.testing_utils import require_torch, require_vision, slow
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
	import torch

if is_vision_available():
	from PIL import Image

	from transformers import ImageGPTImageProcessor







class 				_a				(   unittest.TestCase					):

			def __init__(self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_=7,   SCREAMING_SNAKE_CASE_=3,   SCREAMING_SNAKE_CASE_=18,   SCREAMING_SNAKE_CASE_=30,   SCREAMING_SNAKE_CASE_=400,   SCREAMING_SNAKE_CASE_=True,   SCREAMING_SNAKE_CASE_=None,   SCREAMING_SNAKE_CASE_=True,   )       ->   Union[str, Any]:
						UpperCAmelCase_:		Optional[int]							      =     size if size is not None else {"""height""": 18, """width""": 18}
						UpperCAmelCase_:		Optional[int]							      =     parent
						UpperCAmelCase_:		int							      =     batch_size
						UpperCAmelCase_:		Tuple							      =     num_channels
						UpperCAmelCase_:		Tuple							      =     image_size
						UpperCAmelCase_:		Dict							      =     min_resolution
						UpperCAmelCase_:		List[str]							      =     max_resolution
						UpperCAmelCase_:		Optional[int]							      =     do_resize
						UpperCAmelCase_:		Tuple							      =     size
						UpperCAmelCase_:		Dict							      =     do_normalize

			def      __snake_case       (self					)       ->   Any:
						return {
						    # here we create 2 clusters for the sake of simplicity
						    "clusters": np.asarray(
						        [
						            [0.8_8_6_6_4_4_3_6_3_4_0_3_3_2_0_3, 0.6_6_1_8_8_2_9_3_6_9_5_4_4_9_8_3, 0.3_8_9_1_7_4_6_4_0_1_7_8_6_8_0_4],
						            [-0.6_0_4_2_5_5_9_1_4_6_8_8_1_1_0_4, -0.0_2_2_9_5_0_0_8_8_6_0_5_2_8_4_6_9, 0.5_4_2_3_7_9_7_3_6_9_0_0_3_2_9_6],
						        ]					),
						    "do_resize": self.do_resize,
						    "size": self.size,
						    "do_normalize": self.do_normalize,
						}







@require_torch
@require_vision
class 				_a				(   _lowerCAmelCase ,		unittest.TestCase					):
			A      		=	ImageGPTImageProcessor if is_vision_available() else None

			def      __snake_case       (self					)       ->   Tuple:
						UpperCAmelCase_:		List[Any]							      =     ImageGPTImageProcessingTester(self					)

			@property
			def      __snake_case       (self					)       ->   List[Any]:
						return self.image_processor_tester.prepare_image_processor_dict()

			def      __snake_case       (self					)       ->   Tuple:
						UpperCAmelCase_:		Optional[Any]							      =     self.image_processing_class(**self.image_processor_dict					)
						self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,   """clusters"""					)					)
						self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,   """do_resize"""					)					)
						self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,   """size"""					)					)
						self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,   """do_normalize"""					)					)

			def      __snake_case       (self					)       ->   Optional[Any]:
						UpperCAmelCase_:		Optional[int]							      =     self.image_processing_class.from_dict(self.image_processor_dict					)
						self.assertEqual(image_processor.size,   {"""height""": 18, """width""": 18}					)

						UpperCAmelCase_:		int							      =     self.image_processing_class.from_dict(self.image_processor_dict,   size=42					)
						self.assertEqual(image_processor.size,   {"""height""": 42, """width""": 42}					)

			def      __snake_case       (self					)       ->   Optional[Any]:
						UpperCAmelCase_:		List[str]							      =     self.image_processing_class(**self.image_processor_dict					)
						UpperCAmelCase_:		Dict							      =     json.loads(image_processor.to_json_string()					)
						for key, value in self.image_processor_dict.items():
									if key == "clusters":
												self.assertTrue(np.array_equal(SCREAMING_SNAKE_CASE_,   obj[key]					)					)
									else:
												self.assertEqual(obj[key],   SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   str:
						UpperCAmelCase_:		Optional[Any]							      =     self.image_processing_class(**self.image_processor_dict					)

						with tempfile.TemporaryDirectory() as tmpdirname:
									UpperCAmelCase_:		Tuple							      =     os.path.join(SCREAMING_SNAKE_CASE_,   """image_processor.json"""					)
									image_processor_first.to_json_file(SCREAMING_SNAKE_CASE_					)
									UpperCAmelCase_:		Optional[Any]							      =     self.image_processing_class.from_json_file(SCREAMING_SNAKE_CASE_					).to_dict()

						UpperCAmelCase_:		Optional[int]							      =     image_processor_first.to_dict()
						for key, value in image_processor_first.items():
									if key == "clusters":
												self.assertTrue(np.array_equal(SCREAMING_SNAKE_CASE_,   image_processor_second[key]					)					)
									else:
												self.assertEqual(image_processor_first[key],   SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   List[Any]:
						UpperCAmelCase_:		Tuple							      =     self.image_processing_class(**self.image_processor_dict					)

						with tempfile.TemporaryDirectory() as tmpdirname:
									image_processor_first.save_pretrained(SCREAMING_SNAKE_CASE_					)
									UpperCAmelCase_:		Union[str, Any]							      =     self.image_processing_class.from_pretrained(SCREAMING_SNAKE_CASE_					).to_dict()

						UpperCAmelCase_:		Any							      =     image_processor_first.to_dict()
						for key, value in image_processor_first.items():
									if key == "clusters":
												self.assertTrue(np.array_equal(SCREAMING_SNAKE_CASE_,   image_processor_second[key]					)					)
									else:
												self.assertEqual(image_processor_first[key],   SCREAMING_SNAKE_CASE_					)

			@unittest.skip("""ImageGPT requires clusters at initialization"""					)
			def      __snake_case       (self					)       ->   Dict:
						pass







def  lowerCAmelCase_	():





			"""simple docstring"""


			UpperCAmelCase_:		Any							      =     load_dataset("""hf-internal-testing/fixtures_image_utils"""		,						split="""test"""  )

			UpperCAmelCase_:		Tuple							      =     Image.open(dataset[4]["""file"""]  )
			UpperCAmelCase_:		Optional[Any]							      =     Image.open(dataset[5]["""file"""]  )

			UpperCAmelCase_:		Any							      =     [imagea, imagea]

			return images







@require_vision
@require_torch
class 				_a				(   unittest.TestCase					):

			@slow
			def      __snake_case       (self					)       ->   Optional[Any]:
						UpperCAmelCase_:		Optional[Any]							      =     ImageGPTImageProcessor.from_pretrained("""openai/imagegpt-small"""					)

						UpperCAmelCase_:		Optional[int]							      =     prepare_images()

						# test non-batched
						UpperCAmelCase_:		List[Any]							      =     image_processing(images[0],   return_tensors="""pt"""					)

						self.assertIsInstance(encoding.input_ids,   torch.LongTensor					)
						self.assertEqual(encoding.input_ids.shape,   (1, 1024)					)

						UpperCAmelCase_:		Any							      =     [306, 191, 191]
						self.assertEqual(encoding.input_ids[0, :3].tolist(),   SCREAMING_SNAKE_CASE_					)

						# test batched
						UpperCAmelCase_:		Union[str, Any]							      =     image_processing(SCREAMING_SNAKE_CASE_,   return_tensors="""pt"""					)

						self.assertIsInstance(encoding.input_ids,   torch.LongTensor					)
						self.assertEqual(encoding.input_ids.shape,   (2, 1024)					)

						UpperCAmelCase_:		Tuple							      =     [303, 13, 13]
						self.assertEqual(encoding.input_ids[1, -3:].tolist(),   SCREAMING_SNAKE_CASE_					)











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,   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_=[1, 1, 2],   SCREAMING_SNAKE_CASE_=1,   SCREAMING_SNAKE_CASE_=32,   SCREAMING_SNAKE_CASE_=4,   SCREAMING_SNAKE_CASE_=8,   SCREAMING_SNAKE_CASE_=37,   SCREAMING_SNAKE_CASE_="gelu_new",   SCREAMING_SNAKE_CASE_=0.1,   SCREAMING_SNAKE_CASE_=0.1,   SCREAMING_SNAKE_CASE_=0.0,   SCREAMING_SNAKE_CASE_=512,   SCREAMING_SNAKE_CASE_=3,   SCREAMING_SNAKE_CASE_=0.0_2,   SCREAMING_SNAKE_CASE_=3,   SCREAMING_SNAKE_CASE_=4,   SCREAMING_SNAKE_CASE_=None,   SCREAMING_SNAKE_CASE_=False,   )       ->   Tuple:
						UpperCAmelCase_:		Any							      =     parent
						UpperCAmelCase_:		Optional[Any]							      =     batch_size
						UpperCAmelCase_:		Dict							      =     seq_length
						UpperCAmelCase_:		Union[str, Any]							      =     is_training
						UpperCAmelCase_:		Optional[Any]							      =     use_input_mask
						UpperCAmelCase_:		Optional[Any]							      =     use_token_type_ids
						UpperCAmelCase_:		int							      =     use_labels
						UpperCAmelCase_:		List[str]							      =     vocab_size
						UpperCAmelCase_:		Optional[int]							      =     block_sizes
						UpperCAmelCase_:		Tuple							      =     num_decoder_layers
						UpperCAmelCase_:		List[Any]							      =     d_model
						UpperCAmelCase_:		Dict							      =     n_head
						UpperCAmelCase_:		Optional[Any]							      =     d_head
						UpperCAmelCase_:		Optional[Any]							      =     d_inner
						UpperCAmelCase_:		str							      =     hidden_act
						UpperCAmelCase_:		str							      =     hidden_dropout
						UpperCAmelCase_:		Union[str, Any]							      =     attention_dropout
						UpperCAmelCase_:		Dict							      =     activation_dropout
						UpperCAmelCase_:		str							      =     max_position_embeddings
						UpperCAmelCase_:		Dict							      =     type_vocab_size
						UpperCAmelCase_:		str							      =     2
						UpperCAmelCase_:		Dict							      =     num_labels
						UpperCAmelCase_:		Optional[int]							      =     num_choices
						UpperCAmelCase_:		Optional[int]							      =     scope
						UpperCAmelCase_:		List[Any]							      =     initializer_std

						# Used in the tests to check the size of the first attention layer
						UpperCAmelCase_:		Tuple							      =     n_head
						# Used in the tests to check the size of the first hidden state
						UpperCAmelCase_:		Union[str, Any]							      =     self.d_model
						# Used in the tests to check the number of output hidden states/attentions
						UpperCAmelCase_:		str							      =     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:
									UpperCAmelCase_:		Dict							      =     self.num_hidden_layers + 2

			def      __snake_case       (self					)       ->   Union[str, Any]:
						UpperCAmelCase_:		Dict							      =     ids_tensor([self.batch_size, self.seq_length],   self.vocab_size					)

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

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

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

						UpperCAmelCase_:		Dict							      =     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      __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:
						UpperCAmelCase_:		str							      =     TFFunnelModel(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		List[Any]							      =     {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
						UpperCAmelCase_:		Tuple							      =     model(SCREAMING_SNAKE_CASE_					)

						UpperCAmelCase_:		int							      =     [input_ids, input_mask]
						UpperCAmelCase_:		Dict							      =     model(SCREAMING_SNAKE_CASE_					)

						UpperCAmelCase_:		Union[str, Any]							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.last_hidden_state.shape,   (self.batch_size, self.seq_length, self.d_model)					)

						UpperCAmelCase_:		Union[str, Any]							      =     False
						UpperCAmelCase_:		int							      =     TFFunnelModel(config=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.d_model)					)

						UpperCAmelCase_:		Optional[Any]							      =     False
						UpperCAmelCase_:		str							      =     TFFunnelModel(config=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.d_model)					)

			def      __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:
						UpperCAmelCase_:		Dict							      =     TFFunnelBaseModel(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Tuple							      =     {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
						UpperCAmelCase_:		Tuple							      =     model(SCREAMING_SNAKE_CASE_					)

						UpperCAmelCase_:		Optional[int]							      =     [input_ids, input_mask]
						UpperCAmelCase_:		List[str]							      =     model(SCREAMING_SNAKE_CASE_					)

						UpperCAmelCase_:		int							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.last_hidden_state.shape,   (self.batch_size, 2, self.d_model)					)

						UpperCAmelCase_:		List[str]							      =     False
						UpperCAmelCase_:		str							      =     TFFunnelBaseModel(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Any							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.last_hidden_state.shape,   (self.batch_size, 3, self.d_model)					)

						UpperCAmelCase_:		List[Any]							      =     False
						UpperCAmelCase_:		List[Any]							      =     TFFunnelBaseModel(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		List[Any]							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.last_hidden_state.shape,   (self.batch_size, 2, self.d_model)					)

			def      __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:
						UpperCAmelCase_:		List[Any]							      =     TFFunnelForPreTraining(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Union[str, 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)					)

			def      __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:
						UpperCAmelCase_:		Union[str, Any]							      =     TFFunnelForMaskedLM(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		List[str]							      =     {"""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      __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:
						UpperCAmelCase_:		Tuple							      =     self.num_labels
						UpperCAmelCase_:		Optional[int]							      =     TFFunnelForSequenceClassification(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Union[str, Any]							      =     {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
						UpperCAmelCase_:		Dict							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.logits.shape,   (self.batch_size, self.num_labels)					)

			def      __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:
						UpperCAmelCase_:		Tuple							      =     self.num_choices
						UpperCAmelCase_:		List[str]							      =     TFFunnelForMultipleChoice(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		int							      =     tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_,   1					),   (1, self.num_choices, 1)					)
						UpperCAmelCase_:		Any							      =     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_:		Tuple							      =     {
						    """input_ids""": multiple_choice_inputs_ids,
						    """attention_mask""": multiple_choice_input_mask,
						    """token_type_ids""": multiple_choice_token_type_ids,
						}
						UpperCAmelCase_:		Tuple							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.logits.shape,   (self.batch_size, self.num_choices)					)

			def      __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:
						UpperCAmelCase_:		List[Any]							      =     self.num_labels
						UpperCAmelCase_:		Dict							      =     TFFunnelForTokenClassification(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Tuple							      =     {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
						UpperCAmelCase_:		Union[str, Any]							      =     model(SCREAMING_SNAKE_CASE_					)
						self.parent.assertEqual(result.logits.shape,   (self.batch_size, self.seq_length, self.num_labels)					)

			def      __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:
						UpperCAmelCase_:		Any							      =     TFFunnelForQuestionAnswering(config=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Dict							      =     {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
						UpperCAmelCase_:		Union[str, Any]							      =     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      __snake_case       (self					)       ->   int:
						UpperCAmelCase_:		Optional[Any]							      =     self.prepare_config_and_inputs()
						(
						    (
						    UpperCAmelCase_
						)      ,							(
						    UpperCAmelCase_
						)      ,							(
						    UpperCAmelCase_
						)      ,							(
						    UpperCAmelCase_
						)      ,							(
						    UpperCAmelCase_
						)      ,							(
						    UpperCAmelCase_
						)      ,							(
						    UpperCAmelCase_
						)      ,							
						):		Tuple							      =     config_and_inputs
						UpperCAmelCase_:		Tuple							      =     {"""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					):
			A      		=	(
			    (
			        TFFunnelModel,
			        TFFunnelForMaskedLM,
			        TFFunnelForPreTraining,
			        TFFunnelForQuestionAnswering,
			        TFFunnelForTokenClassification,
			    )
			    if is_tf_available()
			    else ()
			)
			A      		=	(
			    {
			        '''feature-extraction''': (TFFunnelBaseModel, TFFunnelModel),
			        '''fill-mask''': TFFunnelForMaskedLM,
			        '''question-answering''': TFFunnelForQuestionAnswering,
			        '''text-classification''': TFFunnelForSequenceClassification,
			        '''token-classification''': TFFunnelForTokenClassification,
			        '''zero-shot''': TFFunnelForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			A      		=	False
			A      		=	False

			def      __snake_case       (self					)       ->   Tuple:
						UpperCAmelCase_:		Union[str, Any]							      =     TFFunnelModelTester(self					)
						UpperCAmelCase_:		List[str]							      =     ConfigTester(self,   config_class=SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   Any:
						self.config_tester.run_common_tests()

			def      __snake_case       (self					)       ->   int:
						UpperCAmelCase_:		List[str]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   int:
						UpperCAmelCase_:		Union[str, Any]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   Optional[int]:
						UpperCAmelCase_:		Union[str, Any]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   Optional[Any]:
						UpperCAmelCase_:		Tuple							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   List[Any]:
						UpperCAmelCase_:		Union[str, Any]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_					)







@require_tf
class 				_a				(   _lowerCAmelCase ,		unittest.TestCase					):
			A      		=	(
			    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
			)
			A      		=	False
			A      		=	False

			def      __snake_case       (self					)       ->   Dict:
						UpperCAmelCase_:		List[Any]							      =     TFFunnelModelTester(self,   base=SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Dict							      =     ConfigTester(self,   config_class=SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   Union[str, Any]:
						self.config_tester.run_common_tests()

			def      __snake_case       (self					)       ->   Union[str, Any]:
						UpperCAmelCase_:		Optional[Any]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_base_model(*SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   Union[str, Any]:
						UpperCAmelCase_:		Union[str, Any]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_					)

			def      __snake_case       (self					)       ->   Tuple:
						UpperCAmelCase_:		Optional[Any]							      =     self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_					)






