"""simple docstring"""




import torch
from torch import nn
from transformers import CLIPPreTrainedModel, CLIPVisionModel

from ...models.attention import BasicTransformerBlock
from ...utils import logging


__lowerCamelCase											=  logging.get_logger(__name__)  # pylint: disable=invalid-name
class     UpperCamelCase__(			__A ):





						def __init__(       self		,__UpperCAmelCase		,__UpperCAmelCase=7_68     )					->				Tuple:
													super().__init__(__UpperCAmelCase     )
													A__	     =							proj_size

													A__	     =							CLIPVisionModel(__UpperCAmelCase     )
													A__	     =							PaintByExampleMapper(__UpperCAmelCase     )
													A__	     =							nn.LayerNorm(config.hidden_size     )
													A__	     =							nn.Linear(config.hidden_size		,self.proj_size     )

													# uncondition for scaling
													A__	     =							nn.Parameter(torch.randn((1, 1, self.proj_size)     )     )





						def 				snake_case__	(       self		,__UpperCAmelCase		,__UpperCAmelCase=False     )					->				Dict:
													A__	     =							self.model(pixel_values=__UpperCAmelCase     )
													A__	     =							clip_output.pooler_output
													A__	     =							self.mapper(latent_states[:, None]     )
													A__	     =							self.final_layer_norm(__UpperCAmelCase     )
													A__	     =							self.proj_out(__UpperCAmelCase     )
													if return_uncond_vector:
																				return latent_states, self.uncond_vector

													return latent_states






class     UpperCamelCase__(			nn.Module ):





						def __init__(       self		,__UpperCAmelCase     )					->				str:
													super().__init__()
													A__	     =							(config.num_hidden_layers + 1) // 5
													A__	     =							config.hidden_size
													A__	     =							1
													A__	     =							nn.ModuleList(
													    [
													        BasicTransformerBlock(__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase		,activation_fn='gelu'		,attention_bias=__UpperCAmelCase     )
													        for _ in range(__UpperCAmelCase     )
													    ]     )





						def 				snake_case__	(       self		,__UpperCAmelCase     )					->				List[Any]:
													for block in self.blocks:
																				A__	     =							block(__UpperCAmelCase     )

													return hidden_states






"""simple docstring"""




def   UpperCAmelCase					(	UpperCamelCase__				):






							"""simple docstring"""





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

							A__	     =							[]

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

														generate(k - 1       ,    UpperCamelCase__				)

														for i in range(k - 1				):
																					if k % 2 == 0:  # k is even
																												A__     ,  A__	     =							arr[k - 1], arr[i]
																					else:  # k is odd
																												A__     ,  A__	     =							arr[k - 1], arr[0]
																					generate(k - 1       ,    UpperCamelCase__				)

							generate(len(UpperCamelCase__				)       ,    UpperCamelCase__				)
							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))





