
'''simple docstring'''




import unittest

from transformers import AutoTokenizer, FalconConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
      import torch

      from transformers import (
          FalconForCausalLM,
          FalconForQuestionAnswering,
          FalconForSequenceClassification,
          FalconForTokenClassification,
          FalconModel,
      )





class 					A							:





     def __init__(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE=3		,     SCREAMING_SNAKE_CASE=7		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=False		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=99		,     SCREAMING_SNAKE_CASE=32		,     SCREAMING_SNAKE_CASE=5		,     SCREAMING_SNAKE_CASE=4		,     SCREAMING_SNAKE_CASE=37		,     SCREAMING_SNAKE_CASE="gelu"		,     SCREAMING_SNAKE_CASE=0.1		,     SCREAMING_SNAKE_CASE=0.1		,     SCREAMING_SNAKE_CASE=512		,     SCREAMING_SNAKE_CASE=16		,     SCREAMING_SNAKE_CASE=2		,     SCREAMING_SNAKE_CASE=0.02		,     SCREAMING_SNAKE_CASE=3		,     SCREAMING_SNAKE_CASE=4		,     SCREAMING_SNAKE_CASE=None		,     )					->							List[Any]:






         """simple docstring"""






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





     def 							__lowerCAmelCase				(				self      )					->							int:






         """simple docstring"""






         A			:  Dict   =		ids_tensor([self.batch_size, self.seq_length]		,     self.vocab_size      )

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

         A			:  Union[str, Any]   =		None

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

         A			:  Optional[Any]   =		self.get_config()

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





     def 							__lowerCAmelCase				(				self      )					->							List[str]:






         """simple docstring"""






         return FalconConfig(
             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=SCREAMING_SNAKE_CASE		,     initializer_range=self.initializer_range		,     pad_token_id=1		,     new_decoder_architecture=SCREAMING_SNAKE_CASE		,     )





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )					->							Optional[Any]:






         """simple docstring"""






         A			:  int   =		FalconModel(config=SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  str   =		model(SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE      )
         A			:  List[Any]   =		model(SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.last_hidden_state.shape		,     (self.batch_size, self.seq_length, self.hidden_size)      )





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






         """simple docstring"""






         A			:  Optional[Any]   =		True
         A			:  Optional[int]   =		FalconModel(SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  Optional[int]   =		model(
             SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     encoder_hidden_states=SCREAMING_SNAKE_CASE		,     encoder_attention_mask=SCREAMING_SNAKE_CASE		,     )
         A			:  Union[str, Any]   =		model(
             SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     encoder_hidden_states=SCREAMING_SNAKE_CASE		,     )
         A			:  Optional[int]   =		model(SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.last_hidden_state.shape		,     (self.batch_size, self.seq_length, self.hidden_size)      )





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     )					->							Optional[int]:






         """simple docstring"""






         A			:  Union[str, Any]   =		FalconForCausalLM(config=SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  Optional[Any]   =		model(SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     labels=SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.seq_length, self.vocab_size)      )





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     )					->							str:






         """simple docstring"""






         A			:  int   =		True
         A			:  Tuple   =		True
         A			:  Tuple   =		FalconForCausalLM(config=SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()

         # first forward pass
         A			:  str   =		model(
             SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     encoder_hidden_states=SCREAMING_SNAKE_CASE		,     encoder_attention_mask=SCREAMING_SNAKE_CASE		,     use_cache=SCREAMING_SNAKE_CASE		,     )
         A			:  Optional[int]   =		outputs.past_key_values

         # create hypothetical multiple next token and extent to next_input_ids
         A			:  int   =		ids_tensor((self.batch_size, 3)		,     config.vocab_size      )
         A			:  Optional[int]   =		ids_tensor((self.batch_size, 3)		,     vocab_size=2      )

         # append to next input_ids and
         A			:  Any   =		torch.cat([input_ids, next_tokens]		,     dim=-1      )
         A			:  Optional[int]   =		torch.cat([input_mask, next_mask]		,     dim=-1      )

         A			:  str   =		model(
             SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     encoder_hidden_states=SCREAMING_SNAKE_CASE		,     encoder_attention_mask=SCREAMING_SNAKE_CASE		,     output_hidden_states=SCREAMING_SNAKE_CASE		,     )['''hidden_states'''][0]
         A			:  Dict   =		model(
             SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     encoder_hidden_states=SCREAMING_SNAKE_CASE		,     encoder_attention_mask=SCREAMING_SNAKE_CASE		,     past_key_values=SCREAMING_SNAKE_CASE		,     output_hidden_states=SCREAMING_SNAKE_CASE		,     )['''hidden_states'''][0]

         # select random slice
         A			:  Tuple   =		ids_tensor((1,)		,     output_from_past.shape[-1]      ).item()
         A			:  Optional[Any]   =		output_from_no_past[:, -3:, random_slice_idx].detach()
         A			:  List[str]   =		output_from_past[:, :, random_slice_idx].detach()

         self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]      )

         # test that outputs are equal for slice
         self.parent.assertTrue(torch.allclose(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     atol=1e-3      )      )





     def 							__lowerCAmelCase				(				self      )					->							Dict:






         """simple docstring"""






         A			:  Tuple   =		self.prepare_config_and_inputs()
         (
             (
             A
         ),    (
             A
         ),    (
             A
         ),    (
             A
         ),    (
             A
         ),    (
             A
         ),    (
             A
         ),    
         )			:  Any   =		config_and_inputs
         A			:  str   =		{'''input_ids''': input_ids, '''attention_mask''': input_mask}
         return config, inputs_dict





@require_torch
class 					A							(				__snake_case       ,     __snake_case       ,     __snake_case       ,     unittest.TestCase		):
     __magic_name__          =						(
         (
             FalconModel,
             FalconForCausalLM,
             FalconForSequenceClassification,
             FalconForTokenClassification,
             FalconForQuestionAnswering,
         )
         if is_torch_available()
         else ()
     )
     __magic_name__          =						(FalconForCausalLM,) if is_torch_available() else ()
     __magic_name__          =						(
         {
             '''feature-extraction''': FalconModel,
             '''text-classification''': FalconForSequenceClassification,
             '''text-generation''': FalconForCausalLM,
             '''question-answering''': FalconForQuestionAnswering,
             '''token-classification''': FalconForTokenClassification,
             '''zero-shot''': FalconForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     __magic_name__          =						False
     __magic_name__          =						False





     def 							__lowerCAmelCase				(				self      )					->							Tuple:






         """simple docstring"""






         A			:  str   =		FalconModelTester(self      )
         A			:  Dict   =		ConfigTester(self		,     config_class=SCREAMING_SNAKE_CASE		,     hidden_size=37      )





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






         """simple docstring"""






         self.config_tester.run_common_tests()





     def 							__lowerCAmelCase				(				self      )					->							str:






         """simple docstring"""






         A			:  str   =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE      )





     def 							__lowerCAmelCase				(				self      )					->							List[str]:






         """simple docstring"""






         A,    *A			:  Any   =		self.model_tester.prepare_config_and_inputs()
         for alibi in [True, False]:
             A			:  Tuple   =		alibi
             self.model_tester.create_and_check_model(SCREAMING_SNAKE_CASE		,     *SCREAMING_SNAKE_CASE      )





     def 							__lowerCAmelCase				(				self      )					->							int:






         """simple docstring"""






         A,    A			:  List[str]   =		self.model_tester.prepare_config_and_inputs_for_common()
         A			:  List[str]   =		3
         A			:  Union[str, Any]   =		input_dict['''input_ids''']
         A			:  List[str]   =		input_ids.ne(1      ).to(SCREAMING_SNAKE_CASE      )
         A			:  str   =		ids_tensor([self.model_tester.batch_size]		,     self.model_tester.type_sequence_label_size      )
         A			:  Union[str, Any]   =		FalconForSequenceClassification(SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  str   =		model(SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     labels=SCREAMING_SNAKE_CASE      )
         self.assertEqual(result.logits.shape		,     (self.model_tester.batch_size, self.model_tester.num_labels)      )





     def 							__lowerCAmelCase				(				self      )					->							Any:






         """simple docstring"""






         A,    A			:  List[Any]   =		self.model_tester.prepare_config_and_inputs_for_common()
         A			:  Any   =		3
         A			:  Optional[Any]   =		'''single_label_classification'''
         A			:  List[str]   =		input_dict['''input_ids''']
         A			:  Optional[Any]   =		input_ids.ne(1      ).to(SCREAMING_SNAKE_CASE      )
         A			:  Dict   =		ids_tensor([self.model_tester.batch_size]		,     self.model_tester.type_sequence_label_size      )
         A			:  List[str]   =		FalconForSequenceClassification(SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  int   =		model(SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     labels=SCREAMING_SNAKE_CASE      )
         self.assertEqual(result.logits.shape		,     (self.model_tester.batch_size, self.model_tester.num_labels)      )





     def 							__lowerCAmelCase				(				self      )					->							Any:






         """simple docstring"""






         A,    A			:  List[Any]   =		self.model_tester.prepare_config_and_inputs_for_common()
         A			:  str   =		input_dict['''input_ids''']
         A			:  Dict   =		FalconForCausalLM(SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  Any   =		model(SCREAMING_SNAKE_CASE		,     use_cache=SCREAMING_SNAKE_CASE      )
         A			:  Optional[Any]   =		input_ids.shape[0]
         A			:  Dict   =		model._convert_to_rw_cache(result.past_key_values      )
         A			:  Union[str, Any]   =		model._convert_cache_to_standard_format(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )
         for layer in range(len(SCREAMING_SNAKE_CASE      )      ):
             for tensor_idx in range(2      ):
                 self.assertTrue(rw_cache[layer][tensor_idx].ndim == 3      )
                 self.assertTrue(result.past_key_values[layer][tensor_idx].ndim == 4      )
                 self.assertTrue(
                     torch.all(result.past_key_values[layer][tensor_idx] == standard_cache[layer][tensor_idx]      )      )





     def 							__lowerCAmelCase				(				self      )					->							str:






         """simple docstring"""






         A,    A			:  int   =		self.model_tester.prepare_config_and_inputs_for_common()
         A			:  Dict   =		3
         A			:  List[Any]   =		'''multi_label_classification'''
         A			:  List[str]   =		input_dict['''input_ids''']
         A			:  int   =		input_ids.ne(1      ).to(SCREAMING_SNAKE_CASE      )
         A			:  int   =		ids_tensor(
             [self.model_tester.batch_size, config.num_labels]		,     self.model_tester.type_sequence_label_size      ).to(torch.float      )
         A			:  Tuple   =		FalconForSequenceClassification(SCREAMING_SNAKE_CASE      )
         model.to(SCREAMING_SNAKE_CASE      )
         model.eval()
         A			:  List[Any]   =		model(SCREAMING_SNAKE_CASE		,     attention_mask=SCREAMING_SNAKE_CASE		,     labels=SCREAMING_SNAKE_CASE      )
         self.assertEqual(result.logits.shape		,     (self.model_tester.batch_size, self.model_tester.num_labels)      )





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






         """simple docstring"""






         for model_class in self.all_generative_model_classes:
             A,    A			:  Dict   =		self.model_tester.prepare_config_and_inputs_for_common()

             # If it doesn't support cache, pass the test
             if not hasattr(SCREAMING_SNAKE_CASE		,     '''use_cache'''      ):
                 return

             A			:  int   =		model_class(SCREAMING_SNAKE_CASE      ).to(SCREAMING_SNAKE_CASE      )
             if "use_cache" not in inputs:
                 A			:  Optional[int]   =		True
             A			:  Union[str, Any]   =		model(**SCREAMING_SNAKE_CASE      )

             # If "past_key_values" is not returned, pass the test (e.g. RWKV uses a different cache name and format)
             if "past_key_values" not in outputs:
                 return

             A			:  List[Any]   =		(
                 getattr(SCREAMING_SNAKE_CASE		,     '''decoder_layers'''		,     SCREAMING_SNAKE_CASE      )
                 or getattr(SCREAMING_SNAKE_CASE		,     '''num_decoder_layers'''		,     SCREAMING_SNAKE_CASE      )
                 or config.num_hidden_layers
             )
             A			:  Optional[Any]   =		getattr(SCREAMING_SNAKE_CASE		,     '''num_kv_heads'''		,     config.num_attention_heads      )
             A			:  str   =		getattr(SCREAMING_SNAKE_CASE		,     '''d_model'''		,     config.hidden_size      )
             A			:  Dict   =		embed_dim // num_attention_heads

             A			:  int   =		outputs['''past_key_values''']
             self.assertEqual(len(SCREAMING_SNAKE_CASE      )		,     SCREAMING_SNAKE_CASE      )

             A,    A			:  Optional[int]   =		inputs['''input_ids'''].shape
             for i in range(SCREAMING_SNAKE_CASE      ):
                 if config.new_decoder_architecture:
                     A			:  Union[str, Any]   =		config.num_attention_heads
                 elif config.multi_query:
                     A			:  Optional[int]   =		1
                 self.assertEqual(len(past_kv[0]      )		,     2      )  # K V for the decoder = 2
                 self.assertEqual(
                     past_kv[i][0].shape		,     (batch_size, num_attention_heads, seq_length, per_head_embed_dim)      )
                 self.assertEqual(
                     past_kv[i][1].shape		,     (batch_size, num_attention_heads, seq_length, per_head_embed_dim)      )





@require_torch
class 					A							(				unittest.TestCase		):





     @slow
     def 							__lowerCAmelCase				(				self      )					->							Optional[Any]:






         """simple docstring"""






         A			:  Union[str, Any]   =		AutoTokenizer.from_pretrained('''Rocketknight1/falcon-rw-1b'''      )
         A			:  Any   =		FalconForCausalLM.from_pretrained('''Rocketknight1/falcon-rw-1b'''      )
         model.eval()
         model.to(SCREAMING_SNAKE_CASE      )
         A			:  Any   =		tokenizer('''My favorite food is'''		,     return_tensors='''pt'''      ).to(SCREAMING_SNAKE_CASE      )

         A			:  Tuple   =		(
             '''My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday.'''
         )

         A			:  int   =		model.generate(**SCREAMING_SNAKE_CASE		,     do_sample=SCREAMING_SNAKE_CASE		,     max_new_tokens=19      )
         A			:  Union[str, Any]   =		tokenizer.batch_decode(SCREAMING_SNAKE_CASE      )[0]

         self.assertEqual(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )





     @slow
     def 							__lowerCAmelCase				(				self      )					->							Tuple:






         """simple docstring"""






         for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
             A			:  Union[str, Any]   =		AutoTokenizer.from_pretrained(SCREAMING_SNAKE_CASE      )
             A			:  int   =		FalconForCausalLM.from_pretrained(SCREAMING_SNAKE_CASE      )
             model.eval()
             model.to(SCREAMING_SNAKE_CASE      )
             A			:  Union[str, Any]   =		tokenizer('''My favorite food is'''		,     return_tensors='''pt'''      ).to(SCREAMING_SNAKE_CASE      )

             # We just test that these run without errors - the models are randomly initialized
             # and so the actual text outputs will be garbage
             model.generate(**SCREAMING_SNAKE_CASE		,     do_sample=SCREAMING_SNAKE_CASE		,     max_new_tokens=4      )
             model.generate(**SCREAMING_SNAKE_CASE		,     do_sample=SCREAMING_SNAKE_CASE		,     max_new_tokens=4      )
             model.generate(**SCREAMING_SNAKE_CASE		,     num_beams=2		,     max_new_tokens=4      )





     @slow
     def 							__lowerCAmelCase				(				self      )					->							Union[str, Any]:






         """simple docstring"""






         with torch.no_grad():
             for repo in [
                 "Rocketknight1/falcon-rw-1b",
                 "Rocketknight1/tiny-random-falcon-7b",
                 "Rocketknight1/tiny-random-falcon-40b",
             ]:
                 A			:  Optional[Any]   =		AutoTokenizer.from_pretrained(SCREAMING_SNAKE_CASE      )
                 A			:  str   =		FalconForCausalLM.from_pretrained(SCREAMING_SNAKE_CASE      )
                 model.eval()
                 model.to(device=SCREAMING_SNAKE_CASE      )
                 A			:  Tuple   =		tokenizer('''My favorite food is'''		,     return_tensors='''pt'''      ).to(SCREAMING_SNAKE_CASE      )

                 # Test results are the same with and without cache
                 A			:  Tuple   =		model.generate(**SCREAMING_SNAKE_CASE		,     do_sample=SCREAMING_SNAKE_CASE		,     max_new_tokens=20		,     use_cache=SCREAMING_SNAKE_CASE      )
                 A			:  Dict   =		model.generate(**SCREAMING_SNAKE_CASE		,     do_sample=SCREAMING_SNAKE_CASE		,     max_new_tokens=20		,     use_cache=SCREAMING_SNAKE_CASE      )
                 self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0      )






'''simple docstring'''




def 						lowerCAmelCase_							(  snake_case__		):




    '''simple docstring'''



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

    A			:  int   =		[]

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

        generate(k - 1						,							snake_case__		)

        for i in range(k - 1		):
            if k % 2 == 0:  # k is even
                A,    A			:  Any   =		arr[k - 1], arr[i]
            else:  # k is odd
                A,    A			:  List[str]   =		arr[k - 1], arr[0]
            generate(k - 1						,							snake_case__		)

    generate(len(snake_case__		)						,							snake_case__		)
    return res


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




