
import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


lowerCamelCase__          =		logging.get_logger(__name__)

lowerCamelCase__          =		{
    """salesforce/blip2-opt-2.7b""": """https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json""",
}







class      A__							(     __magic_name__	):
				lowercase			    =  'blip_2_vision_model'






				def __init__(						self					:      Dict    ,     a					:      Dict=1_408    ,     a					:      str=6_144    ,     a					:      List[str]=39    ,     a					:      List[str]=16    ,     a					:      Union[str, Any]=224    ,     a					:      List[Any]=14    ,     a					:      Union[str, Any]="gelu"    ,     a					:      str=0.0_0_0_0_1    ,     a					:      Dict=0.0    ,     a					:      Optional[Any]=1E-10    ,     a					:      List[str]=True    ,     **a					:      Dict    ,     ):






							'''simple docstring'''







							super().__init__(**a   )

							lowerCAmelCase__      :      Optional[Any]         =		hidden_size
							lowerCAmelCase__      :      Optional[Any]         =		intermediate_size
							lowerCAmelCase__      :      Any         =		num_hidden_layers
							lowerCAmelCase__      :      Dict         =		num_attention_heads
							lowerCAmelCase__      :      Optional[Any]         =		patch_size
							lowerCAmelCase__      :      int         =		image_size
							lowerCAmelCase__      :      Dict         =		initializer_range
							lowerCAmelCase__      :      Optional[int]         =		attention_dropout
							lowerCAmelCase__      :      List[Any]         =		layer_norm_eps
							lowerCAmelCase__      :      List[str]         =		hidden_act
							lowerCAmelCase__      :      str         =		qkv_bias






				@classmethod
				def 							_lowerCamelCase		(						cls					:      Optional[Any]    ,     a					:      Union[str, os.PathLike]    ,     **a					:      str   ):






							'''simple docstring'''







							cls._set_token_in_kwargs(a   )

							lowerCAmelCase__      ,				lowerCAmelCase__      :      Optional[int]         =		cls.get_config_dict(a    ,     **a   )

							# get the vision config dict if we are loading from Blip2Config
							if config_dict.get('model_type'   ) == "blip-2":
										lowerCAmelCase__      :      Union[str, Any]         =		config_dict['vision_config']

							if "model_type" in config_dict and hasattr(cls    ,     'model_type'   ) and config_dict["model_type"] != cls.model_type:
										logger.warning(
										    f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
										    f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''   )

							return cls.from_dict(a    ,     **a   )







class      A__							(     __magic_name__	):
				lowercase			    =  'blip_2_qformer'






				def __init__(						self					:      int    ,     a					:      Dict=30_522    ,     a					:      List[Any]=768    ,     a					:      Optional[Any]=12    ,     a					:      Optional[int]=12    ,     a					:      Union[str, Any]=3_072    ,     a					:      Any="gelu"    ,     a					:      List[str]=0.1    ,     a					:      List[Any]=0.1    ,     a					:      Any=512    ,     a					:      Any=0.0_2    ,     a					:      Tuple=1E-12    ,     a					:      Dict=0    ,     a					:      int="absolute"    ,     a					:      List[Any]=2    ,     a					:      Union[str, Any]=1_408    ,     **a					:      Optional[int]    ,     ):






							'''simple docstring'''







							super().__init__(pad_token_id=a    ,     **a   )

							lowerCAmelCase__      :      Tuple         =		vocab_size
							lowerCAmelCase__      :      int         =		hidden_size
							lowerCAmelCase__      :      List[str]         =		num_hidden_layers
							lowerCAmelCase__      :      str         =		num_attention_heads
							lowerCAmelCase__      :      str         =		hidden_act
							lowerCAmelCase__      :      Optional[int]         =		intermediate_size
							lowerCAmelCase__      :      Optional[int]         =		hidden_dropout_prob
							lowerCAmelCase__      :      Optional[Any]         =		attention_probs_dropout_prob
							lowerCAmelCase__      :      int         =		max_position_embeddings
							lowerCAmelCase__      :      Dict         =		initializer_range
							lowerCAmelCase__      :      int         =		layer_norm_eps
							lowerCAmelCase__      :      Union[str, Any]         =		position_embedding_type
							lowerCAmelCase__      :      List[str]         =		cross_attention_frequency
							lowerCAmelCase__      :      List[Any]         =		encoder_hidden_size






				@classmethod
				def 							_lowerCamelCase		(						cls					:      Any    ,     a					:      Union[str, os.PathLike]    ,     **a					:      Optional[Any]   ):






							'''simple docstring'''







							cls._set_token_in_kwargs(a   )

							lowerCAmelCase__      ,				lowerCAmelCase__      :      Union[str, Any]         =		cls.get_config_dict(a    ,     **a   )

							# get the qformer config dict if we are loading from Blip2Config
							if config_dict.get('model_type'   ) == "blip-2":
										lowerCAmelCase__      :      Any         =		config_dict['qformer_config']

							if "model_type" in config_dict and hasattr(cls    ,     'model_type'   ) and config_dict["model_type"] != cls.model_type:
										logger.warning(
										    f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
										    f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''   )

							return cls.from_dict(a    ,     **a   )







class      A__							(     __magic_name__	):
				lowercase			    =  'blip-2'
				lowercase			    =  True






				def __init__(						self					:      Optional[int]    ,     a					:      int=None    ,     a					:      Optional[int]=None    ,     a					:      List[str]=None    ,     a					:      Dict=32    ,     **a					:      str   ):






							'''simple docstring'''







							super().__init__(**a   )

							if vision_config is None:
										lowerCAmelCase__      :      List[str]         =		{}
										logger.info('vision_config is None. initializing the Blip2VisionConfig with default values.'   )

							if qformer_config is None:
										lowerCAmelCase__      :      Optional[Any]         =		{}
										logger.info('qformer_config is None. Initializing the Blip2QFormerConfig with default values.'   )

							if text_config is None:
										lowerCAmelCase__      :      Optional[Any]         =		{}
										logger.info('text_config is None. Initializing the text config with default values (`OPTConfig`).'   )

							lowerCAmelCase__      :      Any         =		BlipaVisionConfig(**a   )
							lowerCAmelCase__      :      List[str]         =		BlipaQFormerConfig(**a   )
							lowerCAmelCase__      :      List[Any]         =		text_config['model_type'] if 'model_type' in text_config else 'opt'
							lowerCAmelCase__      :      Optional[int]         =		CONFIG_MAPPING[text_model_type](**a   )

							lowerCAmelCase__      :      Optional[int]         =		self.text_config.tie_word_embeddings
							lowerCAmelCase__      :      Any         =		self.text_config.is_encoder_decoder

							lowerCAmelCase__      :      List[Any]         =		num_query_tokens
							lowerCAmelCase__      :      Dict         =		self.vision_config.hidden_size
							lowerCAmelCase__      :      List[str]         =		self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
							lowerCAmelCase__      :      Any         =		1.0
							lowerCAmelCase__      :      str         =		0.0_2






				@classmethod
				def 							_lowerCamelCase		(						cls					:      List[Any]    ,     a					:      BlipaVisionConfig    ,     a					:      BlipaQFormerConfig    ,     a					:      PretrainedConfig    ,     **a					:      Union[str, Any]    ,     ):






							'''simple docstring'''







							return cls(
							    vision_config=vision_config.to_dict()    ,     qformer_config=qformer_config.to_dict()    ,     text_config=text_config.to_dict()    ,     **a    ,     )






				def 							_lowerCamelCase		(						self					:      Tuple   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Union[str, Any]         =		copy.deepcopy(self.__dict__   )
							lowerCAmelCase__      :      Dict         =		self.vision_config.to_dict()
							lowerCAmelCase__      :      Any         =		self.qformer_config.to_dict()
							lowerCAmelCase__      :      List[str]         =		self.text_config.to_dict()
							lowerCAmelCase__      :      str         =		self.__class__.model_type
							return output

def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		list:

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

			lowerCAmelCase__      :      Optional[Any]         =		[]

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

						generate(k - 1       ,							SCREAMING_SNAKE_CASE_     )

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

			generate(len(SCREAMING_SNAKE_CASE_     )       ,							SCREAMING_SNAKE_CASE_     )
			return res


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