


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      UpperCamelCase:


					def __init__(    self						:		Any  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Tuple=1_3  ,     SCREAMING_SNAKE_CASE						:		List[str]=7  ,     SCREAMING_SNAKE_CASE						:		List[str]=True  ,     SCREAMING_SNAKE_CASE						:		Tuple=True  ,     SCREAMING_SNAKE_CASE						:		List[Any]=True  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]=True  ,     SCREAMING_SNAKE_CASE						:		List[str]=9_9  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]=[1, 1, 2]  ,     SCREAMING_SNAKE_CASE						:		Optional[int]=1  ,     SCREAMING_SNAKE_CASE						:		int=3_2  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]=4  ,     SCREAMING_SNAKE_CASE						:		Tuple=8  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]=3_7  ,     SCREAMING_SNAKE_CASE						:		str="gelu_new"  ,     SCREAMING_SNAKE_CASE						:		List[Any]=0.1  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]=0.1  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]=0.0  ,     SCREAMING_SNAKE_CASE						:		Any=5_1_2  ,     SCREAMING_SNAKE_CASE						:		Dict=3  ,     SCREAMING_SNAKE_CASE						:		List[str]=0.02  ,     SCREAMING_SNAKE_CASE						:		Any=3  ,     SCREAMING_SNAKE_CASE						:		Tuple=4  ,     SCREAMING_SNAKE_CASE						:		Dict=None  ,     SCREAMING_SNAKE_CASE						:		Optional[int]=False  ,     )      ->						Dict:




											'''simple docstring'''

											__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 				SCREAMING_SNAKE_CASE_	(    self						:		Union[str, Any]    )      ->						Tuple:




											'''simple docstring'''

											__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 				SCREAMING_SNAKE_CASE_	(    self						:		Any  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		str  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     )      ->						List[Any]:




											'''simple docstring'''

											__snake_case				=		TFFunnelModel(config=SCREAMING_SNAKE_CASE    )
											__snake_case				=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )

											__snake_case				=		[input_ids, input_mask]
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )

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

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

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


					def 				SCREAMING_SNAKE_CASE_	(    self						:		int  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Any  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     )      ->						Any:




											'''simple docstring'''

											__snake_case				=		TFFunnelBaseModel(config=SCREAMING_SNAKE_CASE    )
											__snake_case				=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )

											__snake_case				=		[input_ids, input_mask]
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )

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

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

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


					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		Any  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     )      ->						Dict:




											'''simple docstring'''

											__snake_case				=		TFFunnelForPreTraining(config=SCREAMING_SNAKE_CASE    )
											__snake_case				=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )
											self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		str  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		str  ,     )      ->						str:




											'''simple docstring'''

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


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Any  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     )      ->						Tuple:




											'''simple docstring'''

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


					def 				SCREAMING_SNAKE_CASE_	(    self						:		str  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		str  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     )      ->						Union[str, Any]:




											'''simple docstring'''

											__snake_case				=		self.num_choices
											__snake_case				=		TFFunnelForMultipleChoice(config=SCREAMING_SNAKE_CASE    )
											__snake_case				=		tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE  ,     1    )  ,     (1, self.num_choices, 1)    )
											__snake_case				=		tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE  ,     1    )  ,     (1, self.num_choices, 1)    )
											__snake_case				=		tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE  ,     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(SCREAMING_SNAKE_CASE    )
											self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.num_choices)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Optional[int]  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		int  ,     )      ->						Any:




											'''simple docstring'''

											__snake_case				=		self.num_labels
											__snake_case				=		TFFunnelForTokenClassification(config=SCREAMING_SNAKE_CASE    )
											__snake_case				=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
											__snake_case				=		model(SCREAMING_SNAKE_CASE    )
											self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length, self.num_labels)    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Union[str, Any]  ,     SCREAMING_SNAKE_CASE						:		Dict  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		List[Any]  ,     SCREAMING_SNAKE_CASE						:		int  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     SCREAMING_SNAKE_CASE						:		Tuple  ,     )      ->						List[str]:




											'''simple docstring'''

											__snake_case				=		TFFunnelForQuestionAnswering(config=SCREAMING_SNAKE_CASE    )
											__snake_case				=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
											__snake_case				=		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 				SCREAMING_SNAKE_CASE_	(    self						:		int    )      ->						int:




											'''simple docstring'''

											__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      UpperCamelCase(	_a  ,				_a  ,				unittest.TestCase ):
					snake_case_		:					Union[str, Any]    					=						(
					    (
					        TFFunnelModel,
					        TFFunnelForMaskedLM,
					        TFFunnelForPreTraining,
					        TFFunnelForQuestionAnswering,
					        TFFunnelForTokenClassification,
					    )
					    if is_tf_available()
					    else ()
					)
					snake_case_		:					Union[str, 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 {}
					)
					snake_case_		:					str    					=						False
					snake_case_		:					Tuple    					=						False


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Any    )      ->						Tuple:




											'''simple docstring'''

											__snake_case				=		TFFunnelModelTester(self    )
											__snake_case				=		ConfigTester(self  ,     config_class=SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[Any]    )      ->						Optional[Any]:




											'''simple docstring'''

											self.config_tester.run_common_tests()


					def 				SCREAMING_SNAKE_CASE_	(    self						:		str    )      ->						str:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Any    )      ->						Any:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[Any]    )      ->						Union[str, Any]:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Any    )      ->						List[str]:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE    )






					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[Any]    )      ->						str:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE    )






@require_tf
class      UpperCamelCase(	_a  ,				unittest.TestCase ):
					snake_case_		:					Optional[int]    					=						(
					    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
					)
					snake_case_		:					Tuple    					=						False
					snake_case_		:					Union[str, Any]    					=						False


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[Any]    )      ->						Tuple:




											'''simple docstring'''

											__snake_case				=		TFFunnelModelTester(self  ,     base=SCREAMING_SNAKE_CASE    )
											__snake_case				=		ConfigTester(self  ,     config_class=SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[str]    )      ->						List[Any]:




											'''simple docstring'''

											self.config_tester.run_common_tests()


					def 				SCREAMING_SNAKE_CASE_	(    self						:		List[str]    )      ->						Optional[Any]:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_base_model(*SCREAMING_SNAKE_CASE    )


					def 				SCREAMING_SNAKE_CASE_	(    self						:		str    )      ->						Any:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE    )






					def 				SCREAMING_SNAKE_CASE_	(    self						:		Optional[Any]    )      ->						List[Any]:




											'''simple docstring'''

											__snake_case				=		self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE    )









def 						_lowerCAmelCase							(     _lowerCAmelCase = 1000			)    ->						int:


						'''simple docstring'''






						__snake_case				=		2**power
						__snake_case				=		str(_lowerCAmelCase			)
						__snake_case				=		list(_lowerCAmelCase			)
						__snake_case				=		0

						for i in list_num:
												sum_of_num += int(_lowerCAmelCase			)

						return sum_of_num


if __name__ == "__main__":
	A				:       Optional[Any]      =  int(input('Enter the power of 2: ').strip())
	print('2 ^ ', power, ' = ', 2**power)
	A				:       List[Any]      =  solution(power)
	print('Sum of the digits is: ', result)





