
'''simple docstring'''




import warnings
from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


lowercase     :							Optional[Any]       						=     logging.get_logger(__name__)

lowercase     :							Optional[int]       						=     {
    'facebook/bart-large': 'https://huggingface.co/facebook/bart-large/resolve/main/config.json',
    # See all BART models at https://huggingface.co/models?filter=bart
}





class 					A							(				__snake_case		):
     __magic_name__          =						'''bart'''
     __magic_name__          =						['''past_key_values''']
     __magic_name__          =						{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}





     def __init__(				self		,     SCREAMING_SNAKE_CASE=50265		,     SCREAMING_SNAKE_CASE=1024		,     SCREAMING_SNAKE_CASE=12		,     SCREAMING_SNAKE_CASE=4096		,     SCREAMING_SNAKE_CASE=16		,     SCREAMING_SNAKE_CASE=12		,     SCREAMING_SNAKE_CASE=4096		,     SCREAMING_SNAKE_CASE=16		,     SCREAMING_SNAKE_CASE=0.0		,     SCREAMING_SNAKE_CASE=0.0		,     SCREAMING_SNAKE_CASE="gelu"		,     SCREAMING_SNAKE_CASE=1024		,     SCREAMING_SNAKE_CASE=0.1		,     SCREAMING_SNAKE_CASE=0.0		,     SCREAMING_SNAKE_CASE=0.0		,     SCREAMING_SNAKE_CASE=0.02		,     SCREAMING_SNAKE_CASE=0.0		,     SCREAMING_SNAKE_CASE=False		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=3		,     SCREAMING_SNAKE_CASE=1		,     SCREAMING_SNAKE_CASE=0		,     SCREAMING_SNAKE_CASE=2		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=2		,     SCREAMING_SNAKE_CASE=2		,     **SCREAMING_SNAKE_CASE		,     )					->							Any:






         """simple docstring"""






         A			:  Tuple   =		vocab_size
         A			:  Optional[int]   =		max_position_embeddings
         A			:  Any   =		d_model
         A			:  Any   =		encoder_ffn_dim
         A			:  Any   =		encoder_layers
         A			:  Optional[int]   =		encoder_attention_heads
         A			:  Tuple   =		decoder_ffn_dim
         A			:  Dict   =		decoder_layers
         A			:  Optional[int]   =		decoder_attention_heads
         A			:  List[Any]   =		dropout
         A			:  str   =		attention_dropout
         A			:  Dict   =		activation_dropout
         A			:  Dict   =		activation_function
         A			:  List[Any]   =		init_std
         A			:  Tuple   =		encoder_layerdrop
         A			:  Any   =		decoder_layerdrop
         A			:  List[str]   =		classifier_dropout
         A			:  Tuple   =		use_cache
         A			:  Dict   =		encoder_layers
         A			:  Any   =		scale_embedding  # scale factor will be sqrt(d_model) if True

         super().__init__(
             num_labels=SCREAMING_SNAKE_CASE		,     pad_token_id=SCREAMING_SNAKE_CASE		,     bos_token_id=SCREAMING_SNAKE_CASE		,     eos_token_id=SCREAMING_SNAKE_CASE		,     is_encoder_decoder=SCREAMING_SNAKE_CASE		,     decoder_start_token_id=SCREAMING_SNAKE_CASE		,     forced_eos_token_id=SCREAMING_SNAKE_CASE		,     **SCREAMING_SNAKE_CASE		,     )

         # ensure backward compatibility for BART CNN models
         if self.forced_bos_token_id is None and kwargs.get('''force_bos_token_to_be_generated'''		,     SCREAMING_SNAKE_CASE      ):
             A			:  List[Any]   =		self.bos_token_id
             warnings.warn(
                 F'Please make sure the config includes `forced_bos_token_id={self.bos_token_id}` in future versions. '
                 '''The config can simply be saved and uploaded again to be fixed.'''      )





class 					A							(				__snake_case		):





     @property
     def 							__lowerCAmelCase				(				self      )					->							Mapping[str, Mapping[int, str]]:






         """simple docstring"""






         if self.task in ["default", "seq2seq-lm"]:
             A			:  Union[str, Any]   =		OrderedDict(
                 [
                     ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                     ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
                 ]      )

             if self.use_past:
                 A			:  Optional[Any]   =		{0: '''batch'''}
                 A			:  Any   =		{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
             else:
                 A			:  List[Any]   =		{0: '''batch''', 1: '''decoder_sequence'''}
                 A			:  int   =		{0: '''batch''', 1: '''decoder_sequence'''}

             if self.use_past:
                 self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE		,     direction='''inputs'''      )
         elif self.task == "causal-lm":
             # TODO: figure this case out.
             A			:  List[Any]   =		OrderedDict(
                 [
                     ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                     ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
                 ]      )
             if self.use_past:
                 A,    A			:  Optional[Any]   =		self.num_layers
                 for i in range(SCREAMING_SNAKE_CASE      ):
                     A			:  Optional[int]   =		{0: '''batch''', 2: '''past_sequence + sequence'''}
                     A			:  Optional[Any]   =		{0: '''batch''', 2: '''past_sequence + sequence'''}
         else:
             A			:  Tuple   =		OrderedDict(
                 [
                     ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                     ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
                     ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
                     ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
                 ]      )

         return common_inputs





     @property
     def 							__lowerCAmelCase				(				self      )					->							Mapping[str, Mapping[int, str]]:






         """simple docstring"""






         if self.task in ["default", "seq2seq-lm"]:
             A			:  Optional[Any]   =		super().outputs
         else:
             A			:  str   =		super(SCREAMING_SNAKE_CASE		,     self      ).outputs
             if self.use_past:
                 A,    A			:  Optional[Any]   =		self.num_layers
                 for i in range(SCREAMING_SNAKE_CASE      ):
                     A			:  Optional[int]   =		{0: '''batch''', 2: '''past_sequence + sequence'''}
                     A			:  Optional[int]   =		{0: '''batch''', 2: '''past_sequence + sequence'''}
         return common_outputs





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = False		,     SCREAMING_SNAKE_CASE = None		,     )					->							Mapping[str, Any]:






         """simple docstring"""






         A			:  str   =		self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )

         # Generate decoder inputs
         A			:  int   =		seq_length if not self.use_past else 1
         A			:  Any   =		self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )
         A			:  int   =		{F'decoder_{name}': tensor for name, tensor in decoder_inputs.items()}
         A			:  Dict   =		dict(**SCREAMING_SNAKE_CASE		,     **SCREAMING_SNAKE_CASE      )

         if self.use_past:
             if not is_torch_available():
                 raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''      )
             else:
                 import torch
             A,    A			:  List[Any]   =		common_inputs['''input_ids'''].shape
             A			:  Optional[int]   =		common_inputs['''decoder_input_ids'''].shape[1]
             A,    A			:  Optional[int]   =		self.num_attention_heads
             A			:  Dict   =		(
                 batch,
                 num_encoder_attention_heads,
                 encoder_seq_length,
                 self._config.hidden_size // num_encoder_attention_heads,
             )
             A			:  str   =		decoder_seq_length + 3
             A			:  Any   =		(
                 batch,
                 num_decoder_attention_heads,
                 decoder_past_length,
                 self._config.hidden_size // num_decoder_attention_heads,
             )

             A			:  Tuple   =		torch.cat(
                 [common_inputs['''decoder_attention_mask'''], torch.ones(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )]		,     dim=1      )

             A			:  List[Any]   =		[]
             # If the number of encoder and decoder layers are present in the model configuration, both are considered
             A,    A			:  Tuple   =		self.num_layers
             A			:  List[str]   =		min(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )
             A			:  List[str]   =		max(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      ) - min_num_layers
             A			:  List[str]   =		'''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

             for _ in range(SCREAMING_SNAKE_CASE      ):
                 common_inputs["past_key_values"].append(
                     (
                         torch.zeros(SCREAMING_SNAKE_CASE      ),
                         torch.zeros(SCREAMING_SNAKE_CASE      ),
                         torch.zeros(SCREAMING_SNAKE_CASE      ),
                         torch.zeros(SCREAMING_SNAKE_CASE      ),
                     )      )
             # TODO: test this.
             A			:  str   =		encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
             for _ in range(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      ):
                 common_inputs["past_key_values"].append((torch.zeros(SCREAMING_SNAKE_CASE      ), torch.zeros(SCREAMING_SNAKE_CASE      ))      )
         return common_inputs





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = False		,     SCREAMING_SNAKE_CASE = None		,     )					->							Mapping[str, Any]:






         """simple docstring"""






         A			:  Union[str, Any]   =		self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )

         if self.use_past:
             if not is_torch_available():
                 raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''      )
             else:
                 import torch
             A,    A			:  List[str]   =		common_inputs['''input_ids'''].shape
             # Not using the same length for past_key_values
             A			:  Tuple   =		seqlen + 2
             A,    A			:  Tuple   =		self.num_layers
             A,    A			:  List[str]   =		self.num_attention_heads
             A			:  int   =		(
                 batch,
                 num_encoder_attention_heads,
                 past_key_values_length,
                 self._config.hidden_size // num_encoder_attention_heads,
             )

             A			:  Dict   =		common_inputs['''attention_mask'''].dtype
             A			:  List[Any]   =		torch.cat(
                 [common_inputs['''attention_mask'''], torch.ones(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     dtype=SCREAMING_SNAKE_CASE      )]		,     dim=1      )
             A			:  Optional[Any]   =		[
                 (torch.zeros(SCREAMING_SNAKE_CASE      ), torch.zeros(SCREAMING_SNAKE_CASE      )) for _ in range(SCREAMING_SNAKE_CASE      )
             ]
         return common_inputs





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = False		,     SCREAMING_SNAKE_CASE = None		,     )					->							Mapping[str, Any]:






         """simple docstring"""






         A			:  Any   =		compute_effective_axis_dimension(
             SCREAMING_SNAKE_CASE		,     fixed_dimension=OnnxConfig.default_fixed_batch		,     num_token_to_add=0      )

         # If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
         A			:  Union[str, Any]   =		tokenizer.num_special_tokens_to_add(SCREAMING_SNAKE_CASE      )
         A			:  Dict   =		compute_effective_axis_dimension(
             SCREAMING_SNAKE_CASE		,     fixed_dimension=OnnxConfig.default_fixed_sequence		,     num_token_to_add=SCREAMING_SNAKE_CASE      )

         # Generate dummy inputs according to compute batch and sequence
         A			:  Tuple   =		[''' '''.join([tokenizer.unk_token]      ) * seq_length] * batch_size
         A			:  List[str]   =		dict(tokenizer(SCREAMING_SNAKE_CASE		,     return_tensors=SCREAMING_SNAKE_CASE      )      )
         return common_inputs





     def 							__lowerCAmelCase				(				self		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = -1		,     SCREAMING_SNAKE_CASE = False		,     SCREAMING_SNAKE_CASE = None		,     )					->							Mapping[str, Any]:






         """simple docstring"""






         if self.task in ["default", "seq2seq-lm"]:
             A			:  Tuple   =		self._generate_dummy_inputs_for_default_and_seqaseq_lm(
                 SCREAMING_SNAKE_CASE		,     batch_size=SCREAMING_SNAKE_CASE		,     seq_length=SCREAMING_SNAKE_CASE		,     is_pair=SCREAMING_SNAKE_CASE		,     framework=SCREAMING_SNAKE_CASE      )

         elif self.task == "causal-lm":
             A			:  str   =		self._generate_dummy_inputs_for_causal_lm(
                 SCREAMING_SNAKE_CASE		,     batch_size=SCREAMING_SNAKE_CASE		,     seq_length=SCREAMING_SNAKE_CASE		,     is_pair=SCREAMING_SNAKE_CASE		,     framework=SCREAMING_SNAKE_CASE      )
         else:
             A			:  List[Any]   =		self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                 SCREAMING_SNAKE_CASE		,     batch_size=SCREAMING_SNAKE_CASE		,     seq_length=SCREAMING_SNAKE_CASE		,     is_pair=SCREAMING_SNAKE_CASE		,     framework=SCREAMING_SNAKE_CASE      )

         return common_inputs





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






         """simple docstring"""






         if self.task in ["default", "seq2seq-lm"]:
             A			:  Dict   =		super()._flatten_past_key_values_(SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )
         else:
             A			:  Optional[int]   =		super(SCREAMING_SNAKE_CASE		,     self      )._flatten_past_key_values_(
                 SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE		,     SCREAMING_SNAKE_CASE      )






'''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))




