
"""simple docstring"""


from __future__ import annotations

import unittest

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

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
      import tensorflow as tf

      from transformers import (
          TFFunnelBaseModel,
          TFFunnelForMaskedLM,
          TFFunnelForMultipleChoice,
          TFFunnelForPreTraining,
          TFFunnelForQuestionAnswering,
          TFFunnelForSequenceClassification,
          TFFunnelForTokenClassification,
          TFFunnelModel,
      )



class   __a  :






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







              """simple docstring"""
              UpperCamelCase					 =		parent
              UpperCamelCase					 =		batch_size
              UpperCamelCase					 =		seq_length
              UpperCamelCase					 =		is_training
              UpperCamelCase					 =		use_input_mask
              UpperCamelCase					 =		use_token_type_ids
              UpperCamelCase					 =		use_labels
              UpperCamelCase					 =		vocab_size
              UpperCamelCase					 =		block_sizes
              UpperCamelCase					 =		num_decoder_layers
              UpperCamelCase					 =		d_model
              UpperCamelCase					 =		n_head
              UpperCamelCase					 =		d_head
              UpperCamelCase					 =		d_inner
              UpperCamelCase					 =		hidden_act
              UpperCamelCase					 =		hidden_dropout
              UpperCamelCase					 =		attention_dropout
              UpperCamelCase					 =		activation_dropout
              UpperCamelCase					 =		max_position_embeddings
              UpperCamelCase					 =		type_vocab_size
              UpperCamelCase					 =		2
              UpperCamelCase					 =		num_labels
              UpperCamelCase					 =		num_choices
              UpperCamelCase					 =		scope
              UpperCamelCase					 =		initializer_std

              # Used in the tests to check the size of the first attention layer
              UpperCamelCase					 =		n_head
              # Used in the tests to check the size of the first hidden state
              UpperCamelCase					 =		self.d_model
              # Used in the tests to check the number of output hidden states/attentions
              UpperCamelCase					 =		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					 =		self.num_hidden_layers + 2






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







              """simple docstring"""
              UpperCamelCase					 =		ids_tensor([self.batch_size, self.seq_length]       ,      self.vocab_size			)

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

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

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

              UpperCamelCase					 =		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 :							List[Any]       ,      UpperCAmelCase_ :							List[Any]       ,      UpperCAmelCase_ :							Optional[Any]       ,      UpperCAmelCase_ :							Optional[Any]       ,      UpperCAmelCase_ :							str       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							List[Any]       ,      )->  Dict:







              """simple docstring"""
              UpperCamelCase					 =		TFFunnelModel(config=UpperCAmelCase_			)
              UpperCamelCase					 =		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
              UpperCamelCase					 =		model(UpperCAmelCase_			)

              UpperCamelCase					 =		[input_ids, input_mask]
              UpperCamelCase					 =		model(UpperCAmelCase_			)

              UpperCamelCase					 =		model(UpperCAmelCase_			)
              self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, self.seq_length, self.d_model)			)

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

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






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







              """simple docstring"""
              UpperCamelCase					 =		TFFunnelBaseModel(config=UpperCAmelCase_			)
              UpperCamelCase					 =		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
              UpperCamelCase					 =		model(UpperCAmelCase_			)

              UpperCamelCase					 =		[input_ids, input_mask]
              UpperCamelCase					 =		model(UpperCAmelCase_			)

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

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

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






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[str]       ,      UpperCAmelCase_ :							List[str]       ,      UpperCAmelCase_ :							Tuple       ,      UpperCAmelCase_ :							List[Any]       ,      UpperCAmelCase_ :							List[Any]       ,      UpperCAmelCase_ :							Optional[Any]       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							str       ,      )->  str:







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






       def 	_SCREAMING_SNAKE_CASE       (  self :							Dict       ,      UpperCAmelCase_ :							str       ,      UpperCAmelCase_ :							Optional[int]       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							List[Any]       ,      UpperCAmelCase_ :							List[Any]       ,      UpperCAmelCase_ :							Optional[Any]       ,      UpperCAmelCase_ :							Optional[Any]       ,      )->  str:







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






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[str]       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							Union[str, Any]       ,      UpperCAmelCase_ :							str       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							Any       ,      UpperCAmelCase_ :							str       ,      )->  List[Any]:







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






       def 	_SCREAMING_SNAKE_CASE       (  self :							Any       ,      UpperCAmelCase_ :							Optional[int]       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							List[Any]       ,      UpperCAmelCase_ :							Tuple       ,      UpperCAmelCase_ :							Any       ,      UpperCAmelCase_ :							Any       ,      UpperCAmelCase_ :							Union[str, Any]       ,      )->  Tuple:







              """simple docstring"""
              UpperCamelCase					 =		self.num_choices
              UpperCamelCase					 =		TFFunnelForMultipleChoice(config=UpperCAmelCase_			)
              UpperCamelCase					 =		tf.tile(tf.expand_dims(UpperCAmelCase_       ,      1			)       ,      (1, self.num_choices, 1)			)
              UpperCamelCase					 =		tf.tile(tf.expand_dims(UpperCAmelCase_       ,      1			)       ,      (1, self.num_choices, 1)			)
              UpperCamelCase					 =		tf.tile(tf.expand_dims(UpperCAmelCase_       ,      1			)       ,      (1, self.num_choices, 1)			)
              UpperCamelCase					 =		{
                  "input_ids": multiple_choice_inputs_ids,
                  "attention_mask": multiple_choice_input_mask,
                  "token_type_ids": multiple_choice_token_type_ids,
              }
              UpperCamelCase					 =		model(UpperCAmelCase_			)
              self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.num_choices)			)






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







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






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]       ,      UpperCAmelCase_ :							Optional[Any]       ,      UpperCAmelCase_ :							List[str]       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							Optional[int]       ,      UpperCAmelCase_ :							str       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							Union[str, Any]       ,      )->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		TFFunnelForQuestionAnswering(config=UpperCAmelCase_			)
              UpperCamelCase					 =		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
              UpperCamelCase					 =		model(UpperCAmelCase_			)
              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 :							Any			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		self.prepare_config_and_inputs()
              (
                  (
                  UpperCamelCase
              ) ,       (
                  UpperCamelCase
              ) ,       (
                  UpperCamelCase
              ) ,       (
                  UpperCamelCase
              ) ,       (
                  UpperCamelCase
              ) ,       (
                  UpperCamelCase
              ) ,       (
                  UpperCamelCase
              ) ,       
              )					 =		config_and_inputs
              UpperCamelCase					 =		{"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	):
       UpperCamelCase_		:					str   =			(
           (
               TFFunnelModel,
               TFFunnelForMaskedLM,
               TFFunnelForPreTraining,
               TFFunnelForQuestionAnswering,
               TFFunnelForTokenClassification,
           )
           if is_tf_available()
           else ()
       )
       UpperCamelCase_		:					List[str]   =			(
           {
               '''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_		:					Dict   =			False
       UpperCamelCase_		:					int   =			False






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







              """simple docstring"""
              UpperCamelCase					 =		TFFunnelModelTester(self			)
              UpperCamelCase					 =		ConfigTester(self       ,      config_class=UpperCAmelCase_			)






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







              """simple docstring"""
              self.config_tester.run_common_tests()






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]			)->  int:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_model(*UpperCAmelCase_			)






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







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_pretraining(*UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							int			)->  Optional[Any]:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_masked_lm(*UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Tuple			)->  Any:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_token_classification(*UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  int:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_question_answering(*UpperCAmelCase_			)





@require_tf
class   __a  (      _lowerCAmelCase    ,     unittest.TestCase	):
       UpperCamelCase_		:					List[str]   =			(
           (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
       )
       UpperCamelCase_		:					Optional[Any]   =			False
       UpperCamelCase_		:					Tuple   =			False






       def 	_SCREAMING_SNAKE_CASE       (  self :							Union[str, Any]			)->  Tuple:







              """simple docstring"""
              UpperCamelCase					 =		TFFunnelModelTester(self       ,      base=UpperCAmelCase_			)
              UpperCamelCase					 =		ConfigTester(self       ,      config_class=UpperCAmelCase_			)






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







              """simple docstring"""
              self.config_tester.run_common_tests()






       def 	_SCREAMING_SNAKE_CASE       (  self :							Tuple			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_base_model(*UpperCAmelCase_			)






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







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_sequence_classification(*UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[str]			)->  Tuple:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_multiple_choice(*UpperCAmelCase_			)







"""simple docstring"""


def 	lowerCamelCase__			(							UpperCAmelCase_				)->							list:







       """simple docstring"""

       if len(UpperCAmelCase_				) <= 1:
              return [tuple(UpperCAmelCase_				)]

       UpperCamelCase					 =		[]

       def generate(UpperCAmelCase_		,      UpperCAmelCase_				):
              if k == 1:
                     res.append(tuple(arr[:]				)				)
                     return

              generate(k - 1		,      UpperCAmelCase_				)

              for i in range(k - 1				):
                     if k % 2 == 0:  # k is even
                            UpperCamelCase ,       UpperCamelCase					 =		arr[k - 1], arr[i]
                     else:  # k is odd
                            UpperCamelCase ,       UpperCamelCase					 =		arr[k - 1], arr[0]
                     generate(k - 1		,      UpperCAmelCase_				)

       generate(len(UpperCAmelCase_				)		,      UpperCAmelCase_				)
       return res


if __name__ == "__main__":
      SCREAMING_SNAKE_CASE      =     input("""Enter numbers separated by a comma:\n""").strip()
      SCREAMING_SNAKE_CASE      =     [int(item) for item in user_input.split(""",""")]
      print(heaps(arr))





