



from typing import List, Union

from ..utils import (
    add_end_docstrings,
    is_tf_available,
    is_torch_available,
    is_vision_available,
    logging,
    requires_backends,
)
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
			from PIL import Image

			from ..image_utils import load_image

if is_tf_available():
			from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_VISION_2_SEQ_MAPPING

if is_torch_available():
			import torch

			from ..models.auto.modeling_auto import MODEL_FOR_VISION_2_SEQ_MAPPING

_lowerCamelCase    :		Dict		      =    logging.get_logger(__name__)


@add_end_docstrings(SCREAMING_SNAKE_CASE_)
class 						lowercase    (							SCREAMING_SNAKE_CASE_):
						'''simple docstring'''


						def __init__(  self    :				Union[str, Any]       ,	*snake_case    :				List[Any]       ,	**snake_case    :				str	):



											'''simple docstring'''


											super().__init__(*snake_case       ,	**snake_case	)
											requires_backends(self       ,	'vision'	)
											self.check_model_type(
											    TF_MODEL_FOR_VISION_2_SEQ_MAPPING if self.framework == 'tf' else MODEL_FOR_VISION_2_SEQ_MAPPING	)







						def       lowerCamelCase_				(  self    :				Union[str, Any]       ,	snake_case    :				Union[str, Any]=None       ,	snake_case    :				int=None       ,	snake_case    :				Union[str, Any]=None	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     str						=				{}
											SCREAMING_SNAKE_CASE							:     Any						=				{}

											if prompt is not None:
																SCREAMING_SNAKE_CASE							:     str						=				prompt

											if generate_kwargs is not None:
																SCREAMING_SNAKE_CASE							:     str						=				generate_kwargs
											if max_new_tokens is not None:
																if "generate_kwargs" not in forward_kwargs:
																					SCREAMING_SNAKE_CASE							:     Optional[Any]						=				{}
																if "max_new_tokens" in forward_kwargs["generate_kwargs"]:
																					raise ValueError(
																					    '\'max_new_tokens\' is defined twice, once in \'generate_kwargs\' and once as a direct parameter,'
																					    ' please use only one'	)
																SCREAMING_SNAKE_CASE							:     List[str]						=				max_new_tokens
											return preprocess_params, forward_kwargs, {}







						def __call__(  self    :				int       ,	snake_case    :				Union[str, List[str], "Image.Image", List["Image.Image"]]       ,	**snake_case    :				Union[str, Any]	):



											'''simple docstring'''


											return super().__call__(snake_case       ,	**snake_case	)







						def       lowerCamelCase_				(  self    :				Union[str, Any]       ,	snake_case    :				Optional[int]       ,	snake_case    :				Tuple=None	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Any						=				load_image(snake_case	)

											if prompt is not None:
																if not isinstance(snake_case       ,	snake_case	):
																					raise ValueError(
																					    f'''Received an invalid text input, got - {type(snake_case	)} - but expected a single string. '''
																					    'Note also that one single text can be provided for conditional image to text generation.'	)

																SCREAMING_SNAKE_CASE							:     Dict						=				self.model.config.model_type

																if model_type == "git":
																					SCREAMING_SNAKE_CASE							:     Tuple						=				self.image_processor(images=snake_case       ,	return_tensors=self.framework	)
																					SCREAMING_SNAKE_CASE							:     str						=				self.tokenizer(text=snake_case       ,	add_special_tokens=snake_case	).input_ids
																					SCREAMING_SNAKE_CASE							:     Optional[Any]						=				[self.tokenizer.cls_token_id] + input_ids
																					SCREAMING_SNAKE_CASE							:     Optional[Any]						=				torch.tensor(snake_case	).unsqueeze(0	)
																					model_inputs.update({'input_ids': input_ids}	)

																elif model_type == "pix2struct":
																					SCREAMING_SNAKE_CASE							:     Dict						=				self.image_processor(images=snake_case       ,	header_text=snake_case       ,	return_tensors=self.framework	)

																elif model_type != "vision-encoder-decoder":
																					# vision-encoder-decoder does not support conditional generation
																					SCREAMING_SNAKE_CASE							:     List[Any]						=				self.image_processor(images=snake_case       ,	return_tensors=self.framework	)
																					SCREAMING_SNAKE_CASE							:     Optional[Any]						=				self.tokenizer(snake_case       ,	return_tensors=self.framework	)
																					model_inputs.update(snake_case	)

																else:
																					raise ValueError(f'''Model type {model_type} does not support conditional text generation'''	)

											else:
																SCREAMING_SNAKE_CASE							:     str						=				self.image_processor(images=snake_case       ,	return_tensors=self.framework	)

											if self.model.config.model_type == "git" and prompt is None:
																SCREAMING_SNAKE_CASE							:     int						=				None

											return model_inputs







						def       lowerCamelCase_				(  self    :				Tuple       ,	snake_case    :				Any       ,	snake_case    :				int=None	):



											'''simple docstring'''


											if (
											    "input_ids" in model_inputs
											    and isinstance(model_inputs['input_ids']       ,	snake_case	)
											    and all(x is None for x in model_inputs['input_ids']	)
											):
																SCREAMING_SNAKE_CASE							:     Optional[int]						=				None

											if generate_kwargs is None:
																SCREAMING_SNAKE_CASE							:     Optional[Any]						=				{}
											# FIXME: We need to pop here due to a difference in how `generation.py` and `generation.tf_utils.py`
											#  parse inputs. In the Tensorflow version, `generate` raises an error if we don't use `input_ids` whereas
											#  the PyTorch version matches it with `self.model.main_input_name` or `self.model.encoder.main_input_name`
											#  in the `_prepare_model_inputs` method.
											SCREAMING_SNAKE_CASE							:     str						=				model_inputs.pop(self.model.main_input_name	)
											SCREAMING_SNAKE_CASE							:     List[str]						=				self.model.generate(snake_case       ,	**snake_case       ,	**snake_case	)
											return model_outputs







						def       lowerCamelCase_				(  self    :				Optional[Any]       ,	snake_case    :				Dict	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     List[Any]						=				[]
											for output_ids in model_outputs:
																SCREAMING_SNAKE_CASE							:     Any						=				{
																    'generated_text': self.tokenizer.decode(
																        snake_case       ,	skip_special_tokens=snake_case       ,	)
																}
																records.append(snake_case	)
											return records




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 						lowercase    :
						'''simple docstring'''


						def __init__(  self    :				List[Any]       ,	snake_case    :				Optional[Any]       ,	snake_case    :				int=13       ,	snake_case    :				int=7       ,	snake_case    :				Dict=True       ,	snake_case    :				Union[str, Any]=True       ,	snake_case    :				Union[str, Any]=True       ,	snake_case    :				List[Any]=True       ,	snake_case    :				Tuple=99       ,	snake_case    :				Any=[1, 1, 2]       ,	snake_case    :				Dict=1       ,	snake_case    :				Optional[int]=32       ,	snake_case    :				Union[str, Any]=4       ,	snake_case    :				Optional[Any]=8       ,	snake_case    :				Dict=37       ,	snake_case    :				int="gelu_new"       ,	snake_case    :				Optional[Any]=0.1       ,	snake_case    :				List[str]=0.1       ,	snake_case    :				Any=0.0       ,	snake_case    :				Dict=512       ,	snake_case    :				List[str]=3       ,	snake_case    :				Any=0.02       ,	snake_case    :				List[str]=3       ,	snake_case    :				Optional[Any]=4       ,	snake_case    :				Dict=None       ,	snake_case    :				Any=False       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				parent
											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				batch_size
											SCREAMING_SNAKE_CASE							:     List[str]						=				seq_length
											SCREAMING_SNAKE_CASE							:     int						=				is_training
											SCREAMING_SNAKE_CASE							:     Any						=				use_input_mask
											SCREAMING_SNAKE_CASE							:     Tuple						=				use_token_type_ids
											SCREAMING_SNAKE_CASE							:     Dict						=				use_labels
											SCREAMING_SNAKE_CASE							:     Dict						=				vocab_size
											SCREAMING_SNAKE_CASE							:     Dict						=				block_sizes
											SCREAMING_SNAKE_CASE							:     Dict						=				num_decoder_layers
											SCREAMING_SNAKE_CASE							:     int						=				d_model
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				n_head
											SCREAMING_SNAKE_CASE							:     Optional[int]						=				d_head
											SCREAMING_SNAKE_CASE							:     int						=				d_inner
											SCREAMING_SNAKE_CASE							:     List[Any]						=				hidden_act
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				hidden_dropout
											SCREAMING_SNAKE_CASE							:     Any						=				attention_dropout
											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				activation_dropout
											SCREAMING_SNAKE_CASE							:     str						=				max_position_embeddings
											SCREAMING_SNAKE_CASE							:     int						=				type_vocab_size
											SCREAMING_SNAKE_CASE							:     str						=				2
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				num_labels
											SCREAMING_SNAKE_CASE							:     Tuple						=				num_choices
											SCREAMING_SNAKE_CASE							:     str						=				scope
											SCREAMING_SNAKE_CASE							:     int						=				initializer_std

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







						def       lowerCamelCase_				(  self    :				int	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Any						=				ids_tensor([self.batch_size, self.seq_length]       ,	self.vocab_size	)

											SCREAMING_SNAKE_CASE							:     Dict						=				None
											if self.use_input_mask:
																SCREAMING_SNAKE_CASE							:     Optional[int]						=				random_attention_mask([self.batch_size, self.seq_length]	)

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

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

											SCREAMING_SNAKE_CASE							:     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       lowerCamelCase_				(  self    :				Dict       ,	snake_case    :				List[str]       ,	snake_case    :				Tuple       ,	snake_case    :				Union[str, Any]       ,	snake_case    :				Any       ,	snake_case    :				Dict       ,	snake_case    :				Any       ,	snake_case    :				Union[str, Any]       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     List[str]						=				TFFunnelModel(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Dict						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				model(snake_case	)

											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				[input_ids, input_mask]
											SCREAMING_SNAKE_CASE							:     List[Any]						=				model(snake_case	)

											SCREAMING_SNAKE_CASE							:     int						=				model(snake_case	)
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, self.seq_length, self.d_model)	)

											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				False
											SCREAMING_SNAKE_CASE							:     Any						=				TFFunnelModel(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Dict						=				model(snake_case	)
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, self.seq_length, self.d_model)	)

											SCREAMING_SNAKE_CASE							:     Any						=				False
											SCREAMING_SNAKE_CASE							:     int						=				TFFunnelModel(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     List[Any]						=				model(snake_case	)
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, self.seq_length, self.d_model)	)







						def       lowerCamelCase_				(  self    :				str       ,	snake_case    :				Any       ,	snake_case    :				Dict       ,	snake_case    :				Any       ,	snake_case    :				Optional[Any]       ,	snake_case    :				Tuple       ,	snake_case    :				Dict       ,	snake_case    :				Optional[Any]       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     str						=				TFFunnelBaseModel(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     List[str]						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				model(snake_case	)

											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				[input_ids, input_mask]
											SCREAMING_SNAKE_CASE							:     Tuple						=				model(snake_case	)

											SCREAMING_SNAKE_CASE							:     Any						=				model(snake_case	)
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, 2, self.d_model)	)

											SCREAMING_SNAKE_CASE							:     Optional[int]						=				False
											SCREAMING_SNAKE_CASE							:     int						=				TFFunnelBaseModel(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Any						=				model(snake_case	)
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, 3, self.d_model)	)

											SCREAMING_SNAKE_CASE							:     int						=				False
											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				TFFunnelBaseModel(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				model(snake_case	)
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, 2, self.d_model)	)







						def       lowerCamelCase_				(  self    :				Optional[int]       ,	snake_case    :				Any       ,	snake_case    :				str       ,	snake_case    :				Optional[int]       ,	snake_case    :				List[str]       ,	snake_case    :				Union[str, Any]       ,	snake_case    :				List[Any]       ,	snake_case    :				Dict       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Any						=				TFFunnelForPreTraining(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     str						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     List[str]						=				model(snake_case	)
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length)	)







						def       lowerCamelCase_				(  self    :				List[str]       ,	snake_case    :				Any       ,	snake_case    :				int       ,	snake_case    :				List[str]       ,	snake_case    :				Tuple       ,	snake_case    :				int       ,	snake_case    :				str       ,	snake_case    :				List[Any]       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Dict						=				TFFunnelForMaskedLM(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Tuple						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     Tuple						=				model(snake_case	)
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length, self.vocab_size)	)







						def       lowerCamelCase_				(  self    :				Any       ,	snake_case    :				Optional[Any]       ,	snake_case    :				Optional[int]       ,	snake_case    :				Dict       ,	snake_case    :				Optional[Any]       ,	snake_case    :				Dict       ,	snake_case    :				Tuple       ,	snake_case    :				str       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Tuple						=				self.num_labels
											SCREAMING_SNAKE_CASE							:     Any						=				TFFunnelForSequenceClassification(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Tuple						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     Tuple						=				model(snake_case	)
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.num_labels)	)







						def       lowerCamelCase_				(  self    :				Optional[Any]       ,	snake_case    :				List[Any]       ,	snake_case    :				Optional[Any]       ,	snake_case    :				Any       ,	snake_case    :				Dict       ,	snake_case    :				Dict       ,	snake_case    :				int       ,	snake_case    :				Tuple       ,	):



											'''simple docstring'''


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







						def       lowerCamelCase_				(  self    :				Any       ,	snake_case    :				Optional[Any]       ,	snake_case    :				Dict       ,	snake_case    :				Any       ,	snake_case    :				int       ,	snake_case    :				Union[str, Any]       ,	snake_case    :				Any       ,	snake_case    :				Optional[Any]       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     int						=				self.num_labels
											SCREAMING_SNAKE_CASE							:     List[Any]						=				TFFunnelForTokenClassification(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     Optional[int]						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     Tuple						=				model(snake_case	)
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length, self.num_labels)	)







						def       lowerCamelCase_				(  self    :				str       ,	snake_case    :				Optional[Any]       ,	snake_case    :				Any       ,	snake_case    :				Dict       ,	snake_case    :				Any       ,	snake_case    :				Union[str, Any]       ,	snake_case    :				List[Any]       ,	snake_case    :				Dict       ,	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Tuple						=				TFFunnelForQuestionAnswering(config=snake_case	)
											SCREAMING_SNAKE_CASE							:     List[str]						=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											SCREAMING_SNAKE_CASE							:     Dict						=				model(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       lowerCamelCase_				(  self    :				Optional[Any]	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				self.prepare_config_and_inputs()
											(
											    (
											    SCREAMING_SNAKE_CASE
											)					,  (
											    SCREAMING_SNAKE_CASE
											)					,  (
											    SCREAMING_SNAKE_CASE
											)					,  (
											    SCREAMING_SNAKE_CASE
											)					,  (
											    SCREAMING_SNAKE_CASE
											)					,  (
											    SCREAMING_SNAKE_CASE
											)					,  (
											    SCREAMING_SNAKE_CASE
											)					,  
											)							:     Any						=				config_and_inputs
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict


@require_tf
class 						lowercase    (							SCREAMING_SNAKE_CASE_      ,    SCREAMING_SNAKE_CASE_      ,    unittest.TestCase):
						'''simple docstring'''


						UpperCAmelCase			:		int		=		(
						    (
						        TFFunnelModel,
						        TFFunnelForMaskedLM,
						        TFFunnelForPreTraining,
						        TFFunnelForQuestionAnswering,
						        TFFunnelForTokenClassification,
						    )
						    if is_tf_available()
						    else ()
						)
						UpperCAmelCase			:		Optional[Any]		=		(
						    {
						        'feature-extraction': (TFFunnelBaseModel, TFFunnelModel),
						        'fill-mask': TFFunnelForMaskedLM,
						        'question-answering': TFFunnelForQuestionAnswering,
						        'text-classification': TFFunnelForSequenceClassification,
						        'token-classification': TFFunnelForTokenClassification,
						        'zero-shot': TFFunnelForSequenceClassification,
						    }
						    if is_tf_available()
						    else {}
						)
						UpperCAmelCase			:		Any		=		False
						UpperCAmelCase			:		Tuple		=		False







						def       lowerCamelCase_				(  self    :				str	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     int						=				TFFunnelModelTester(self	)
											SCREAMING_SNAKE_CASE							:     Any						=				ConfigTester(self       ,	config_class=snake_case	)







						def       lowerCamelCase_				(  self    :				Any	):



											'''simple docstring'''


											self.config_tester.run_common_tests()







						def       lowerCamelCase_				(  self    :				Any	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*snake_case	)







						def       lowerCamelCase_				(  self    :				str	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     str						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_pretraining(*snake_case	)







						def       lowerCamelCase_				(  self    :				List[Any]	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Tuple						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*snake_case	)







						def       lowerCamelCase_				(  self    :				Union[str, Any]	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_token_classification(*snake_case	)







						def       lowerCamelCase_				(  self    :				List[Any]	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     int						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*snake_case	)


@require_tf
class 						lowercase    (							SCREAMING_SNAKE_CASE_      ,    unittest.TestCase):
						'''simple docstring'''


						UpperCAmelCase			:		Any		=		(
						    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
						)
						UpperCAmelCase			:		List[str]		=		False
						UpperCAmelCase			:		Tuple		=		False







						def       lowerCamelCase_				(  self    :				Optional[Any]	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				TFFunnelModelTester(self       ,	base=snake_case	)
											SCREAMING_SNAKE_CASE							:     Optional[int]						=				ConfigTester(self       ,	config_class=snake_case	)







						def       lowerCamelCase_				(  self    :				int	):



											'''simple docstring'''


											self.config_tester.run_common_tests()







						def       lowerCamelCase_				(  self    :				int	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     str						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_base_model(*snake_case	)







						def       lowerCamelCase_				(  self    :				Dict	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     str						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*snake_case	)







						def       lowerCamelCase_				(  self    :				int	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_multiple_choice(*snake_case	)