


import os
import tempfile
import unittest

from transformers import NezhaConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        MODEL_FOR_PRETRAINING_MAPPING,
        NezhaForMaskedLM,
        NezhaForMultipleChoice,
        NezhaForNextSentencePrediction,
        NezhaForPreTraining,
        NezhaForQuestionAnswering,
        NezhaForSequenceClassification,
        NezhaForTokenClassification,
        NezhaModel,
    )
    from transformers.models.nezha.modeling_nezha import NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST



class 							_UpperCamelCase :

   def __init__(  self  : Tuple       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Optional[Any]=1_3       ,  _lowerCamelCase  : List[str]=7       ,  _lowerCamelCase  : str=True       ,  _lowerCamelCase  : Union[str, Any]=True       ,  _lowerCamelCase  : Optional[Any]=True       ,  _lowerCamelCase  : int=True       ,  _lowerCamelCase  : str=9_9       ,  _lowerCamelCase  : List[Any]=3_2       ,  _lowerCamelCase  : Optional[Any]=5       ,  _lowerCamelCase  : int=4       ,  _lowerCamelCase  : Optional[int]=3_7       ,  _lowerCamelCase  : Dict="gelu"       ,  _lowerCamelCase  : List[Any]=0.1       ,  _lowerCamelCase  : Dict=0.1       ,  _lowerCamelCase  : List[str]=1_2_8       ,  _lowerCamelCase  : str=3_2       ,  _lowerCamelCase  : Optional[int]=1_6       ,  _lowerCamelCase  : Optional[Any]=2       ,  _lowerCamelCase  : int=0.02       ,  _lowerCamelCase  : Tuple=3       ,  _lowerCamelCase  : Any=4       ,  _lowerCamelCase  : Dict=None       ,  ):






         '''simple docstring'''



         __lowerCamelCase     :      str       						=						parent
         __lowerCamelCase     :      Dict       						=						batch_size
         __lowerCamelCase     :      List[Any]       						=						seq_length
         __lowerCamelCase     :      List[Any]       						=						is_training
         __lowerCamelCase     :      Union[str, Any]       						=						use_input_mask
         __lowerCamelCase     :      Optional[int]       						=						use_token_type_ids
         __lowerCamelCase     :      int       						=						use_labels
         __lowerCamelCase     :      Any       						=						vocab_size
         __lowerCamelCase     :      Dict       						=						hidden_size
         __lowerCamelCase     :      Union[str, Any]       						=						num_hidden_layers
         __lowerCamelCase     :      List[str]       						=						num_attention_heads
         __lowerCamelCase     :      List[Any]       						=						intermediate_size
         __lowerCamelCase     :      Union[str, Any]       						=						hidden_act
         __lowerCamelCase     :      List[str]       						=						hidden_dropout_prob
         __lowerCamelCase     :      Union[str, Any]       						=						attention_probs_dropout_prob
         __lowerCamelCase     :      Tuple       						=						max_position_embeddings
         __lowerCamelCase     :      Union[str, Any]       						=						type_vocab_size
         __lowerCamelCase     :      Optional[int]       						=						type_sequence_label_size
         __lowerCamelCase     :      Optional[Any]       						=						initializer_range
         __lowerCamelCase     :      List[str]       						=						num_labels
         __lowerCamelCase     :      List[Any]       						=						num_choices
         __lowerCamelCase     :      Optional[int]       						=						scope

   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         __lowerCamelCase     :      str       						=						ids_tensor([self.batch_size, self.seq_length]       ,  self.vocab_size							)

         __lowerCamelCase     :      List[str]       						=						None
         if self.use_input_mask:
               __lowerCamelCase     :      Optional[Any]       						=						random_attention_mask([self.batch_size, self.seq_length]							)

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

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

         __lowerCamelCase     :      List[str]       						=						self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels

   def   _snake_case    (  self  : Dict							):






         '''simple docstring'''



         return NezhaConfig(
             vocab_size=self.vocab_size       ,  hidden_size=self.hidden_size       ,  num_hidden_layers=self.num_hidden_layers       ,  num_attention_heads=self.num_attention_heads       ,  intermediate_size=self.intermediate_size       ,  hidden_act=self.hidden_act       ,  hidden_dropout_prob=self.hidden_dropout_prob       ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,  max_position_embeddings=self.max_position_embeddings       ,  type_vocab_size=self.type_vocab_size       ,  is_decoder=a_       ,  initializer_range=self.initializer_range       ,  )

   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         (
             __lowerCamelCase      
         )     :      Union[str, Any]       						=						self.prepare_config_and_inputs()

         __lowerCamelCase     :      int       						=						True
         __lowerCamelCase     :      Optional[Any]       						=						floats_tensor([self.batch_size, self.seq_length, self.hidden_size]							)
         __lowerCamelCase     :      int       						=						ids_tensor([self.batch_size, self.seq_length]       ,  vocab_size=2							)

         return (
             config,
             input_ids,
             token_type_ids,
             input_mask,
             sequence_labels,
             token_labels,
             choice_labels,
             encoder_hidden_states,
             encoder_attention_mask,
         )

   def   _snake_case    (  self  : Tuple       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Optional[int]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Dict       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : str							):






         '''simple docstring'''



         __lowerCamelCase     :      Dict       						=						NezhaModel(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      Any       						=						model(a_       ,  attention_mask=a_       ,  token_type_ids=a_							)
         __lowerCamelCase     :      Union[str, Any]       						=						model(a_       ,  token_type_ids=a_							)
         __lowerCamelCase     :      List[str]       						=						model(a_							)
         self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, self.seq_length, self.hidden_size)							)
         self.parent.assertEqual(result.pooler_output.shape       ,  (self.batch_size, self.hidden_size)							)

   def   _snake_case    (  self  : List[str]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : Any       ,  ):






         '''simple docstring'''



         __lowerCamelCase     :      str       						=						True
         __lowerCamelCase     :      Dict       						=						NezhaModel(a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      Optional[Any]       						=						model(
             a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  encoder_hidden_states=a_       ,  encoder_attention_mask=a_       ,  )
         __lowerCamelCase     :      Dict       						=						model(
             a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  encoder_hidden_states=a_       ,  )
         __lowerCamelCase     :      Tuple       						=						model(a_       ,  attention_mask=a_       ,  token_type_ids=a_							)
         self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, self.seq_length, self.hidden_size)							)
         self.parent.assertEqual(result.pooler_output.shape       ,  (self.batch_size, self.hidden_size)							)

   def   _snake_case    (  self  : Optional[Any]       ,  _lowerCamelCase  : Union[str, Any]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Dict       ,  _lowerCamelCase  : Optional[int]       ,  _lowerCamelCase  : Optional[Any]							):






         '''simple docstring'''



         __lowerCamelCase     :      Optional[int]       						=						NezhaForMaskedLM(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      Dict       						=						model(a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  labels=a_							)
         self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.vocab_size)							)

   def   _snake_case    (  self  : Tuple       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Union[str, Any]       ,  _lowerCamelCase  : Optional[int]       ,  _lowerCamelCase  : List[Any]							):






         '''simple docstring'''



         __lowerCamelCase     :      Union[str, Any]       						=						NezhaForNextSentencePrediction(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      Optional[int]       						=						model(
             a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  labels=a_       ,  )
         self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, 2)							)

   def   _snake_case    (  self  : Any       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : Union[str, Any]       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Dict							):






         '''simple docstring'''



         __lowerCamelCase     :      Tuple       						=						NezhaForPreTraining(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      int       						=						model(
             a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  labels=a_       ,  next_sentence_label=a_       ,  )
         self.parent.assertEqual(result.prediction_logits.shape       ,  (self.batch_size, self.seq_length, self.vocab_size)							)
         self.parent.assertEqual(result.seq_relationship_logits.shape       ,  (self.batch_size, 2)							)

   def   _snake_case    (  self  : Union[str, Any]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : List[Any]       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Dict							):






         '''simple docstring'''



         __lowerCamelCase     :      List[Any]       						=						NezhaForQuestionAnswering(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      int       						=						model(
             a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  start_positions=a_       ,  end_positions=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   _snake_case    (  self  : int       ,  _lowerCamelCase  : Union[str, Any]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : List[str]       ,  _lowerCamelCase  : Dict							):






         '''simple docstring'''



         __lowerCamelCase     :      Any       						=						self.num_labels
         __lowerCamelCase     :      Union[str, Any]       						=						NezhaForSequenceClassification(a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      int       						=						model(a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  labels=a_							)
         self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.num_labels)							)

   def   _snake_case    (  self  : Dict       ,  _lowerCamelCase  : Any       ,  _lowerCamelCase  : Dict       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : List[Any]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Dict							):






         '''simple docstring'''



         __lowerCamelCase     :      int       						=						self.num_labels
         __lowerCamelCase     :      List[Any]       						=						NezhaForTokenClassification(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      List[Any]       						=						model(a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  labels=a_							)
         self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.num_labels)							)

   def   _snake_case    (  self  : Any       ,  _lowerCamelCase  : Dict       ,  _lowerCamelCase  : Union[str, Any]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : Dict							):






         '''simple docstring'''



         __lowerCamelCase     :      Union[str, Any]       						=						self.num_choices
         __lowerCamelCase     :      Optional[Any]       						=						NezhaForMultipleChoice(config=a_							)
         model.to(a_							)
         model.eval()
         __lowerCamelCase     :      int       						=						input_ids.unsqueeze(1							).expand(-1       ,  self.num_choices       ,  -1							).contiguous()
         __lowerCamelCase     :      List[Any]       						=						token_type_ids.unsqueeze(1							).expand(-1       ,  self.num_choices       ,  -1							).contiguous()
         __lowerCamelCase     :      List[str]       						=						input_mask.unsqueeze(1							).expand(-1       ,  self.num_choices       ,  -1							).contiguous()
         __lowerCamelCase     :      int       						=						model(
             a_       ,  attention_mask=a_       ,  token_type_ids=a_       ,  labels=a_       ,  )
         self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.num_choices)							)


   def   _snake_case    (  self  : Dict							):






         '''simple docstring'''



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



@require_torch
class 							_UpperCamelCase (						__a,__a,__a,unittest.TestCase						):
   a_				:							List[Any]    = (
       (
           NezhaModel,
           NezhaForMaskedLM,
           NezhaForMultipleChoice,
           NezhaForNextSentencePrediction,
           NezhaForPreTraining,
           NezhaForQuestionAnswering,
           NezhaForSequenceClassification,
           NezhaForTokenClassification,
       )
       if is_torch_available()
       else ()
   )
   a_				:							List[str]    = (
       {
           "feature-extraction": NezhaModel,
           "fill-mask": NezhaForMaskedLM,
           "question-answering": NezhaForQuestionAnswering,
           "text-classification": NezhaForSequenceClassification,
           "token-classification": NezhaForTokenClassification,
           "zero-shot": NezhaForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   a_				:							List[Any]    = True

   def   _snake_case    (  self  : Union[str, Any]       ,  _lowerCamelCase  : int       ,  _lowerCamelCase  : List[Any]       ,  _lowerCamelCase  : List[str]=False							):






         '''simple docstring'''



         __lowerCamelCase     :      Any       						=						super()._prepare_for_class(a_       ,  a_       ,  return_labels=a_							)

         if return_labels:
               if model_class in get_values(a_							):
                     __lowerCamelCase     :      Union[str, Any]       						=						torch.zeros(
                         (self.model_tester.batch_size, self.model_tester.seq_length)       ,  dtype=torch.long       ,  device=a_							)
                     __lowerCamelCase     :      str       						=						torch.zeros(
                         self.model_tester.batch_size       ,  dtype=torch.long       ,  device=a_							)
         return inputs_dict

   def   _snake_case    (  self  : Tuple							):






         '''simple docstring'''



         __lowerCamelCase     :      int       						=						NezhaModelTester(self							)
         __lowerCamelCase     :      List[Any]       						=						ConfigTester(self       ,  config_class=a_       ,  hidden_size=3_7							)

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






         '''simple docstring'''



         self.config_tester.run_common_tests()

   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         __lowerCamelCase     :      Dict       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*a_							)

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






         '''simple docstring'''



         __lowerCamelCase     :      Optional[int]       						=						self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_model_as_decoder(*a_							)

   def   _snake_case    (  self  : List[str]							):






         '''simple docstring'''



         (
             __lowerCamelCase      
         )     :      List[str]       						=						self.model_tester.prepare_config_and_inputs_for_decoder()

         __lowerCamelCase     :      List[Any]       						=						None

         self.model_tester.create_and_check_model_as_decoder(
             a_       ,  a_       ,  a_       ,  a_       ,  a_       ,  a_       ,  a_       ,  a_       ,  a_       ,  )

   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         __lowerCamelCase     :      Optional[int]       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_lm(*a_							)

   def   _snake_case    (  self  : List[Any]							):






         '''simple docstring'''



         __lowerCamelCase     :      Any       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_multiple_choice(*a_							)

   def   _snake_case    (  self  : Tuple							):






         '''simple docstring'''



         __lowerCamelCase     :      Tuple       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_next_sequence_prediction(*a_							)

   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         __lowerCamelCase     :      Optional[int]       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_pretraining(*a_							)

   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         __lowerCamelCase     :      List[Any]       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*a_							)

   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         __lowerCamelCase     :      Dict       						=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*a_							)

   def   _snake_case    (  self  : Optional[int]							):






         '''simple docstring'''



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

   @slow
   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



         for model_name in NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               __lowerCamelCase     :      List[Any]       						=						NezhaModel.from_pretrained(a_							)
               self.assertIsNotNone(a_							)


   @slow
   @require_torch_gpu
   def   _snake_case    (  self  : Optional[int]							):






         '''simple docstring'''



         __lowerCamelCase     :      List[Any]       						=						self.model_tester.prepare_config_and_inputs_for_common()
         for model_class in self.all_model_classes:
               # NezhaForMultipleChoice behaves incorrectly in JIT environments.
               if model_class == NezhaForMultipleChoice:
                     return

               __lowerCamelCase     :      str       						=						True
               __lowerCamelCase     :      Tuple       						=						model_class(config=a_							)

               __lowerCamelCase     :      Optional[int]       						=						self._prepare_for_class(a_       ,  a_							)
               __lowerCamelCase     :      Optional[Any]       						=						torch.jit.trace(
                   a_       ,  (inputs_dict["""input_ids"""].to("""cpu"""							), inputs_dict["""attention_mask"""].to("""cpu"""							))							)

               with tempfile.TemporaryDirectory() as tmp:
                     torch.jit.save(a_       ,  os.path.join(a_       ,  """bert.pt"""							)							)
                     __lowerCamelCase     :      List[str]       						=						torch.jit.load(os.path.join(a_       ,  """bert.pt"""							)       ,  map_location=a_							)
                     loaded(inputs_dict["""input_ids"""].to(a_							)       ,  inputs_dict["""attention_mask"""].to(a_							)							)



@require_torch
class 							_UpperCamelCase (						unittest.TestCase						):

   @slow
   def   _snake_case    (  self  : str							):






         '''simple docstring'''



         __lowerCamelCase     :      int       						=						NezhaModel.from_pretrained("""sijunhe/nezha-cn-base"""							)
         __lowerCamelCase     :      int       						=						torch.tensor([[0, 1, 2, 3, 4, 5]]							)
         __lowerCamelCase     :      Tuple       						=						torch.tensor([[0, 1, 1, 1, 1, 1]]							)
         with torch.no_grad():
               __lowerCamelCase     :      List[Any]       						=						model(a_       ,  attention_mask=a_							)[0]
         __lowerCamelCase     :      str       						=						torch.Size((1, 6, 7_6_8)							)
         self.assertEqual(output.shape       ,  a_							)
         __lowerCamelCase     :      List[Any]       						=						torch.tensor([[[0.0_685, 0.2_441, 0.1_102], [0.0_600, 0.1_906, 0.1_349], [0.0_221, 0.0_819, 0.0_586]]]							)

         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]       ,  a_       ,  atol=1E-4							)							)


   @slow
   def   _snake_case    (  self  : Tuple							):






         '''simple docstring'''



         __lowerCamelCase     :      Tuple       						=						NezhaForMaskedLM.from_pretrained("""sijunhe/nezha-cn-base"""							)
         __lowerCamelCase     :      Any       						=						torch.tensor([[0, 1, 2, 3, 4, 5]]							)
         __lowerCamelCase     :      int       						=						torch.tensor([[1, 1, 1, 1, 1, 1]]							)
         with torch.no_grad():
               __lowerCamelCase     :      Any       						=						model(a_       ,  attention_mask=a_							)[0]
         __lowerCamelCase     :      Optional[int]       						=						torch.Size((1, 6, 2_1_1_2_8)							)
         self.assertEqual(output.shape       ,  a_							)
         __lowerCamelCase     :      int       						=						torch.tensor(
             [[-2.7_939, -1.7_902, -2.2_189], [-2.8_585, -1.8_908, -2.3_723], [-2.6_499, -1.7_750, -2.2_558]]							)

         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]       ,  a_       ,  atol=1E-4							)							)







def   _UpperCAmelCase       (     UpperCAmelCase      :			list      ):
      """simple docstring"""




      __lowerCamelCase     :      Optional[int]       						=						len(UpperCAmelCase      )
      for _ in range(UpperCAmelCase      ):
            for i in range(_ % 2						,	arr_size - 1						,	2      ):
                  if arr[i + 1] < arr[i]:
                        __lowerCamelCase						, __lowerCamelCase     :      List[str]       						=						arr[i + 1], arr[i]

      return arr


if __name__ == "__main__":
    __UpperCamelCase    :						str     =							list(range(10, 0, -1))
    print(F'''Original: {arr}. Sorted: {odd_even_transposition(arr)}''')



