





'''simple docstring'''







import argparse
import os
import re


_a   :					List[Any]           =       'src/transformers'

# Pattern that looks at the indentation in a line.
_a   :					Optional[Any]           =       re.compile(r"""^(\s*)\S""")
# Pattern that matches `"key":" and puts `key` in group 0.
_a   :					int           =       re.compile(r"""^\s*\"([^\"]+)\":""")
# Pattern that matches `_import_structure["key"]` and puts `key` in group 0.
_a   :					List[str]           =       re.compile(r"""^\s*_import_structure\[\"([^\"]+)\"\]""")
# Pattern that matches `"key",` and puts `key` in group 0.
_a   :					Any           =       re.compile(r"""^\s*\"([^\"]+)\",\s*$""")
# Pattern that matches any `[stuff]` and puts `stuff` in group 0.
_a   :					List[str]           =       re.compile(r"""\[([^\]]+)\]""")





def   _lowerCAmelCase		(		lowercase      )   ->   Optional[Any]:
			__lowerCAmelCase   		=							_re_indent.search(lowerCAmelCase__      )
			return "" if search is None else search.groups()[0]





def   _lowerCAmelCase		(		lowercase   ,      lowercase=""   ,      lowercase=None   ,      lowercase=None      )   ->   int:
			__lowerCAmelCase   		=							0
			__lowerCAmelCase   		=							code.split("""\n"""      )
			if start_prompt is not None:
						while not lines[index].startswith(lowerCAmelCase__      ):
									index += 1
						__lowerCAmelCase   		=							["""\n""".join(lines[:index]      )]
			else:
						__lowerCAmelCase   		=							[]

			# We split into blocks until we get to the `end_prompt` (or the end of the block).
			__lowerCAmelCase   		=							[lines[index]]
			index += 1
			while index < len(lowerCAmelCase__      ) and (end_prompt is None or not lines[index].startswith(lowerCAmelCase__      )):
						if len(lines[index]      ) > 0 and get_indent(lines[index]      ) == indent_level:
									if len(lowerCAmelCase__      ) > 0 and get_indent(current_block[-1]      ).startswith(indent_level + """ """      ):
												current_block.append(lines[index]      )
												blocks.append("""\n""".join(lowerCAmelCase__      )      )
												if index < len(lowerCAmelCase__      ) - 1:
															__lowerCAmelCase   		=							[lines[index + 1]]
															index += 1
												else:
															__lowerCAmelCase   		=							[]
									else:
												blocks.append("""\n""".join(lowerCAmelCase__      )      )
												__lowerCAmelCase   		=							[lines[index]]
						else:
									current_block.append(lines[index]      )
						index += 1

			# Adds current block if it's nonempty.
			if len(lowerCAmelCase__      ) > 0:
						blocks.append("""\n""".join(lowerCAmelCase__      )      )

			# Add final block after end_prompt if provided.
			if end_prompt is not None and index < len(lowerCAmelCase__      ):
						blocks.append("""\n""".join(lines[index:]      )      )

			return blocks





def   _lowerCAmelCase		(		lowercase      )   ->   Tuple:


			def _inner(lowercase      ):
						return key(lowerCAmelCase__      ).lower().replace("""_"""   ,      """"""      )

			return _inner





def   _lowerCAmelCase		(		lowercase   ,      lowercase=None      )   ->   List[Any]:


			def noop(lowercase      ):
						return x

			if key is None:
						__lowerCAmelCase   		=							noop
			# Constants are all uppercase, they go first.
			__lowerCAmelCase   		=							[obj for obj in objects if key(lowerCAmelCase__      ).isupper()]
			# Classes are not all uppercase but start with a capital, they go second.
			__lowerCAmelCase   		=							[obj for obj in objects if key(lowerCAmelCase__      )[0].isupper() and not key(lowerCAmelCase__      ).isupper()]
			# Functions begin with a lowercase, they go last.
			__lowerCAmelCase   		=							[obj for obj in objects if not key(lowerCAmelCase__      )[0].isupper()]

			__lowerCAmelCase   		=							ignore_underscore(lowerCAmelCase__      )
			return sorted(lowerCAmelCase__   ,      key=lowerCAmelCase__      ) + sorted(lowerCAmelCase__   ,      key=lowerCAmelCase__      ) + sorted(lowerCAmelCase__   ,      key=lowerCAmelCase__      )





def   _lowerCAmelCase		(		lowercase      )   ->   Union[str, Any]:


			def _replace(lowercase      ):
						__lowerCAmelCase   		=							match.groups()[0]
						if "," not in imports:
									return f'[{imports}]'
						__lowerCAmelCase   		=							[part.strip().replace("""\""""   ,      """"""      ) for part in imports.split(""","""      )]
						# We will have a final empty element if the line finished with a comma.
						if len(keys[-1]      ) == 0:
									__lowerCAmelCase   		=							keys[:-1]
						return "[" + ", ".join([f'"{k}"' for k in sort_objects(lowerCAmelCase__      )]      ) + "]"

			__lowerCAmelCase   		=							import_statement.split("""\n"""      )
			if len(lowerCAmelCase__      ) > 3:
						# Here we have to sort internal imports that are on several lines (one per name):
						# key: [
						#     "object1",
						#     "object2",
						#     ...
						# ]

						# We may have to ignore one or two lines on each side.
						__lowerCAmelCase   		=							2 if lines[1].strip() == """[""" else 1
						__lowerCAmelCase   		=							[(i, _re_strip_line.search(lowerCAmelCase__      ).groups()[0]) for i, line in enumerate(lines[idx:-idx]      )]
						__lowerCAmelCase   		=							sort_objects(lowerCAmelCase__   ,      key=lambda lowercase      : x[1]      )
						__lowerCAmelCase   		=							[lines[x[0] + idx] for x in sorted_indices]
						return "\n".join(lines[:idx] + sorted_lines + lines[-idx:]      )
			elif len(lowerCAmelCase__      ) == 3:
						# Here we have to sort internal imports that are on one separate line:
						# key: [
						#     "object1", "object2", ...
						# ]
						if _re_bracket_content.search(lines[1]      ) is not None:
									__lowerCAmelCase   		=							_re_bracket_content.sub(_replace   ,      lines[1]      )
						else:
									__lowerCAmelCase   		=							[part.strip().replace("""\""""   ,      """"""      ) for part in lines[1].split(""","""      )]
									# We will have a final empty element if the line finished with a comma.
									if len(keys[-1]      ) == 0:
												__lowerCAmelCase   		=							keys[:-1]
									__lowerCAmelCase   		=							get_indent(lines[1]      ) + """, """.join([f'"{k}"' for k in sort_objects(lowerCAmelCase__      )]      )
						return "\n".join(lowerCAmelCase__      )
			else:
						# Finally we have to deal with imports fitting on one line
						__lowerCAmelCase   		=							_re_bracket_content.sub(_replace   ,      lowerCAmelCase__      )
						return import_statement





def   _lowerCAmelCase		(		lowercase   ,      lowercase=True      )   ->   Optional[Any]:


			with open(lowerCAmelCase__   ,      encoding="""utf-8"""      ) as f:
						__lowerCAmelCase   		=							f.read()

			if "_import_structure" not in code:
						return

			# Blocks of indent level 0
			__lowerCAmelCase   		=							split_code_in_indented_blocks(
			    lowerCAmelCase__   ,      start_prompt="""_import_structure = {"""   ,      end_prompt="""if TYPE_CHECKING:"""      )

			# We ignore block 0 (everything untils start_prompt) and the last block (everything after end_prompt).
			for block_idx in range(1   ,      len(lowerCAmelCase__      ) - 1      ):
						# Check if the block contains some `_import_structure`s thingy to sort.
						__lowerCAmelCase   		=							main_blocks[block_idx]
						__lowerCAmelCase   		=							block.split("""\n"""      )

						# Get to the start of the imports.
						__lowerCAmelCase   		=							0
						while line_idx < len(lowerCAmelCase__      ) and "_import_structure" not in block_lines[line_idx]:
									# Skip dummy import blocks
									if "import dummy" in block_lines[line_idx]:
												__lowerCAmelCase   		=							len(lowerCAmelCase__      )
									else:
												line_idx += 1
						if line_idx >= len(lowerCAmelCase__      ):
									continue

						# Ignore beginning and last line: they don't contain anything.
						__lowerCAmelCase   		=							"""\n""".join(block_lines[line_idx:-1]      )
						__lowerCAmelCase   		=							get_indent(block_lines[1]      )
						# Slit the internal block into blocks of indent level 1.
						__lowerCAmelCase   		=							split_code_in_indented_blocks(lowerCAmelCase__   ,      indent_level=lowerCAmelCase__      )
						# We have two categories of import key: list or _import_structure[key].append/extend
						__lowerCAmelCase   		=							_re_direct_key if """_import_structure = {""" in block_lines[0] else _re_indirect_key
						# Grab the keys, but there is a trap: some lines are empty or just comments.
						__lowerCAmelCase   		=							[(pattern.search(lowerCAmelCase__      ).groups()[0] if pattern.search(lowerCAmelCase__      ) is not None else None) for b in internal_blocks]
						# We only sort the lines with a key.
						__lowerCAmelCase   		=							[(i, key) for i, key in enumerate(lowerCAmelCase__      ) if key is not None]
						__lowerCAmelCase   		=							[x[0] for x in sorted(lowerCAmelCase__   ,      key=lambda lowercase      : x[1]      )]

						# We reorder the blocks by leaving empty lines/comments as they were and reorder the rest.
						__lowerCAmelCase   		=							0
						__lowerCAmelCase   		=							[]
						for i in range(len(lowerCAmelCase__      )      ):
									if keys[i] is None:
												reorderded_blocks.append(internal_blocks[i]      )
									else:
												__lowerCAmelCase   		=							sort_objects_in_import(internal_blocks[sorted_indices[count]]      )
												reorderded_blocks.append(lowerCAmelCase__      )
												count += 1

        # And we put our main block back together with its first and last line.
						__lowerCAmelCase   		=							"""\n""".join(block_lines[:line_idx] + reorderded_blocks + [block_lines[-1]]      )

			if code != "\n".join(lowerCAmelCase__      ):
						if check_only:
									return True
						else:
									print(f'Overwriting {file}.'      )
									with open(lowerCAmelCase__   ,      """w"""   ,      encoding="""utf-8"""      ) as f:
												f.write("""\n""".join(lowerCAmelCase__      )      )





def   _lowerCAmelCase		(		lowercase=True      )   ->   Optional[Any]:
			__lowerCAmelCase   		=							[]
			for root, _, files in os.walk(lowerCAmelCase__      ):
						if "__init__.py" in files:
									__lowerCAmelCase   		=							sort_imports(os.path.join(lowerCAmelCase__   ,      """__init__.py"""      )   ,      check_only=lowerCAmelCase__      )
									if result:
												__lowerCAmelCase   		=							[os.path.join(lowerCAmelCase__   ,      """__init__.py"""      )]
			if len(lowerCAmelCase__      ) > 0:
						raise ValueError(f'Would overwrite {len(lowerCAmelCase__      )} files, run `make style`.'      )


if __name__ == "__main__":
	_a   :					Any           =       argparse.ArgumentParser()
	parser.add_argument("""--check_only""", action="""store_true""", help="""Whether to only check or fix style.""")
	_a   :					Optional[Any]           =       parser.parse_args()

	sort_imports_in_all_inits(check_only=args.check_only)






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_					)






