






'''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        _UpperCAmelCase						:




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






       '''simple docstring'''






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

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




    def 				lowerCAmelCase__				(			self  :       List[str]			):






       '''simple docstring'''






       lowercase_	:    int           =     ids_tensor([self.batch_size, self.seq_length]  ,     self.vocab_size			)

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

       lowercase_	:    int           =     None
       if self.use_token_type_ids:
          lowercase_	:    List[str]           =     ids_tensor([self.batch_size, self.seq_length]  ,     self.type_vocab_size			)

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

       lowercase_	:    Optional[Any]           =     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  :       int  ,     a  :       Tuple  ,     a  :       List[Any]  ,     a  :       List[str]  ,     a  :       List[str]  ,     a  :       Tuple  ,     a  :       Union[str, Any]  ,     a  :       Union[str, Any]  ,     ):






       '''simple docstring'''






       lowercase_	:    int           =     TFFunnelModel(config=a			)
       lowercase_	:    int           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    int           =     model(a			)

       lowercase_	:    Dict           =     [input_ids, input_mask]
       lowercase_	:    Tuple           =     model(a			)

       lowercase_	:    List[Any]           =     model(a			)
       self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, self.seq_length, self.d_model)			)

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

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




    def 				lowerCAmelCase__				(			self  :       str  ,     a  :       str  ,     a  :       Optional[int]  ,     a  :       Tuple  ,     a  :       Any  ,     a  :       List[Any]  ,     a  :       str  ,     a  :       Any  ,     ):






       '''simple docstring'''






       lowercase_	:    int           =     TFFunnelBaseModel(config=a			)
       lowercase_	:    str           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    Optional[int]           =     model(a			)

       lowercase_	:    Optional[int]           =     [input_ids, input_mask]
       lowercase_	:    int           =     model(a			)

       lowercase_	:    str           =     model(a			)
       self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, 2, self.d_model)			)

       lowercase_	:    List[str]           =     False
       lowercase_	:    Optional[int]           =     TFFunnelBaseModel(config=a			)
       lowercase_	:    Optional[int]           =     model(a			)
       self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, 3, self.d_model)			)

       lowercase_	:    str           =     False
       lowercase_	:    Dict           =     TFFunnelBaseModel(config=a			)
       lowercase_	:    Union[str, Any]           =     model(a			)
       self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, 2, self.d_model)			)




    def 				lowerCAmelCase__				(			self  :       int  ,     a  :       Dict  ,     a  :       int  ,     a  :       Optional[int]  ,     a  :       Dict  ,     a  :       Any  ,     a  :       Optional[int]  ,     a  :       Optional[Any]  ,     ):






       '''simple docstring'''






       lowercase_	:    Optional[Any]           =     TFFunnelForPreTraining(config=a			)
       lowercase_	:    List[str]           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    Tuple           =     model(a			)
       self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length)			)




    def 				lowerCAmelCase__				(			self  :       str  ,     a  :       Dict  ,     a  :       Any  ,     a  :       Optional[Any]  ,     a  :       str  ,     a  :       str  ,     a  :       Union[str, Any]  ,     a  :       List[str]  ,     ):






       '''simple docstring'''






       lowercase_	:    Optional[Any]           =     TFFunnelForMaskedLM(config=a			)
       lowercase_	:    List[str]           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    int           =     model(a			)
       self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length, self.vocab_size)			)




    def 				lowerCAmelCase__				(			self  :       Tuple  ,     a  :       Optional[int]  ,     a  :       List[Any]  ,     a  :       Tuple  ,     a  :       str  ,     a  :       Dict  ,     a  :       int  ,     a  :       Dict  ,     ):






       '''simple docstring'''






       lowercase_	:    List[str]           =     self.num_labels
       lowercase_	:    List[Any]           =     TFFunnelForSequenceClassification(config=a			)
       lowercase_	:    int           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    Dict           =     model(a			)
       self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.num_labels)			)




    def 				lowerCAmelCase__				(			self  :       List[Any]  ,     a  :       List[str]  ,     a  :       Any  ,     a  :       int  ,     a  :       str  ,     a  :       Optional[Any]  ,     a  :       List[str]  ,     a  :       Tuple  ,     ):






       '''simple docstring'''






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




    def 				lowerCAmelCase__				(			self  :       int  ,     a  :       int  ,     a  :       List[Any]  ,     a  :       Any  ,     a  :       int  ,     a  :       Union[str, Any]  ,     a  :       Union[str, Any]  ,     a  :       Any  ,     ):






       '''simple docstring'''






       lowercase_	:    Tuple           =     self.num_labels
       lowercase_	:    Tuple           =     TFFunnelForTokenClassification(config=a			)
       lowercase_	:    List[str]           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    str           =     model(a			)
       self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length, self.num_labels)			)




    def 				lowerCAmelCase__				(			self  :       List[str]  ,     a  :       List[str]  ,     a  :       Any  ,     a  :       int  ,     a  :       Optional[int]  ,     a  :       str  ,     a  :       Any  ,     a  :       Union[str, Any]  ,     ):






       '''simple docstring'''






       lowercase_	:    List[str]           =     TFFunnelForQuestionAnswering(config=a			)
       lowercase_	:    List[Any]           =     {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
       lowercase_	:    Dict           =     model(a			)
       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'''






       lowercase_	:    List[str]           =     self.prepare_config_and_inputs()
       (
           (
           lowercase_
       )    ,		(
           lowercase_
       )    ,		(
           lowercase_
       )    ,		(
           lowercase_
       )    ,		(
           lowercase_
       )    ,		(
           lowercase_
       )    ,		(
           lowercase_
       )    ,		
       )	:    Tuple           =     config_and_inputs
       lowercase_	:    Union[str, Any]           =     {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
       return config, inputs_dict


@require_tf
class        _UpperCAmelCase						(		snake_case				,					snake_case				,					unittest.TestCase			):
    __lowerCamelCase:   Union[str, Any]		       =    (
        (
            TFFunnelModel,
            TFFunnelForMaskedLM,
            TFFunnelForPreTraining,
            TFFunnelForQuestionAnswering,
            TFFunnelForTokenClassification,
        )
        if is_tf_available()
        else ()
    )
    __lowerCamelCase:   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 {}
    )
    __lowerCamelCase:   Tuple		       =    False
    __lowerCamelCase:   Union[str, Any]		       =    False




    def 				lowerCAmelCase__				(			self  :       Tuple			):






       '''simple docstring'''






       lowercase_	:    List[str]           =     TFFunnelModelTester(self			)
       lowercase_	:    int           =     ConfigTester(self  ,     config_class=a			)




    def 				lowerCAmelCase__				(			self  :       int			):






       '''simple docstring'''






       self.config_tester.run_common_tests()




    def 				lowerCAmelCase__				(			self  :       Optional[int]			):






       '''simple docstring'''






       lowercase_	:    int           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*a			)




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






       '''simple docstring'''






       lowercase_	:    int           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_pretraining(*a			)




    def 				lowerCAmelCase__				(			self  :       List[Any]			):






       '''simple docstring'''






       lowercase_	:    Union[str, Any]           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*a			)




    def 				lowerCAmelCase__				(			self  :       Dict			):






       '''simple docstring'''






       lowercase_	:    Optional[int]           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_token_classification(*a			)





    def 				lowerCAmelCase__				(			self  :       int			):






       '''simple docstring'''






       lowercase_	:    int           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*a			)


@require_tf
class        _UpperCAmelCase						(		snake_case				,					unittest.TestCase			):
    __lowerCamelCase:   Any		       =    (
        (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
    )
    __lowerCamelCase:   int		       =    False
    __lowerCamelCase:   List[Any]		       =    False




    def 				lowerCAmelCase__				(			self  :       int			):






       '''simple docstring'''






       lowercase_	:    List[Any]           =     TFFunnelModelTester(self  ,     base=a			)
       lowercase_	:    int           =     ConfigTester(self  ,     config_class=a			)




    def 				lowerCAmelCase__				(			self  :       List[str]			):






       '''simple docstring'''






       self.config_tester.run_common_tests()




    def 				lowerCAmelCase__				(			self  :       Any			):






       '''simple docstring'''






       lowercase_	:    str           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_base_model(*a			)




    def 				lowerCAmelCase__				(			self  :       List[Any]			):






       '''simple docstring'''






       lowercase_	:    List[Any]           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*a			)





    def 				lowerCAmelCase__				(			self  :       Any			):






       '''simple docstring'''






       lowercase_	:    Dict           =     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_multiple_choice(*a			)












'''simple docstring'''
def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase							):


   """simple docstring"""




   lowercase_	:    Any           =     False
   while is_sorted is False:  # Until all the indices are traversed keep looping
      lowercase_	:    List[str]           =     True
      for i in range(0						,		len(_UpperCamelCase							) - 1						,		2							):  # iterating over all even indices
         if input_list[i] > input_list[i + 1]:
            lowercase_    ,		lowercase_	:    Union[str, Any]           =     input_list[i + 1], input_list[i]
            # swapping if elements not in order
            lowercase_	:    Any           =     False

      for i in range(1						,		len(_UpperCamelCase							) - 1						,		2							):  # iterating over all odd indices
         if input_list[i] > input_list[i + 1]:
            lowercase_    ,		lowercase_	:    Tuple           =     input_list[i + 1], input_list[i]
            # swapping if elements not in order
            lowercase_	:    List[Any]           =     False
   return input_list


if __name__ == "__main__":
 print('Enter list to be sorted')
 UpperCamelCase__ =			[int(x) for x in input().split()]
 # inputing elements of the list in one line
 UpperCamelCase__ =			odd_even_sort(input_list)
 print('The sorted list is')
 print(sorted_list)




