
"""simple docstring"""






from dataclasses import dataclass
from typing import Optional

import torch
from torch import nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .attention import BasicTransformerBlock
from .modeling_utils import ModelMixin





@dataclass
class 				snake_case    (			SCREAMING_SNAKE_CASE_						):
   a_ :						List[Any]			 =			42






class 				snake_case    (			SCREAMING_SNAKE_CASE_				,    SCREAMING_SNAKE_CASE_						):







   @register_to_config
   def __init__(      self    ,				__UpperCAmelCase = 16    ,				__UpperCAmelCase = 88    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = 1    ,				__UpperCAmelCase = 0.0    ,				__UpperCAmelCase = 32    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = "geglu"    ,				__UpperCAmelCase = True    ,				__UpperCAmelCase = True    ,				)					->Dict:
      super().__init__()
      a_							=			num_attention_heads
      a_							=			attention_head_dim
      a_							=			num_attention_heads * attention_head_dim

      a_							=			in_channels

      a_							=			torch.nn.GroupNorm(num_groups=__UpperCAmelCase    ,				num_channels=__UpperCAmelCase    ,				eps=1E-6    ,				affine=__UpperCAmelCase)
      a_							=			nn.Linear(__UpperCAmelCase    ,				__UpperCAmelCase)

      # 3. Define transformers blocks
      a_							=			nn.ModuleList(
          [
              BasicTransformerBlock(
                  __UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				dropout=__UpperCAmelCase    ,				cross_attention_dim=__UpperCAmelCase    ,				activation_fn=__UpperCAmelCase    ,				attention_bias=__UpperCAmelCase    ,				double_self_attention=__UpperCAmelCase    ,				norm_elementwise_affine=__UpperCAmelCase    ,				)
              for d in range(__UpperCAmelCase)
          ])

      a_							=			nn.Linear(__UpperCAmelCase    ,				__UpperCAmelCase)







   def 					UpperCAmelCase__     (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase=None    ,				__UpperCAmelCase=None    ,				__UpperCAmelCase=None    ,				__UpperCAmelCase=1    ,				__UpperCAmelCase=None    ,				__UpperCAmelCase = True    ,				)					->List[Any]:
      a_							=			hidden_states.shape
      a_							=			batch_frames // num_frames

      a_							=			hidden_states

      a_							=			hidden_states[None, :].reshape(__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase)
      a_							=			hidden_states.permute(0    ,				2    ,				1    ,				3    ,				4)

      a_							=			self.norm(__UpperCAmelCase)
      a_							=			hidden_states.permute(0    ,				3    ,				4    ,				2    ,				1).reshape(batch_size * height * width    ,				__UpperCAmelCase    ,				__UpperCAmelCase)

      a_							=			self.proj_in(__UpperCAmelCase)

      # 2. Blocks
      for block in self.transformer_blocks:
         a_							=			block(
             __UpperCAmelCase    ,				encoder_hidden_states=__UpperCAmelCase    ,				timestep=__UpperCAmelCase    ,				cross_attention_kwargs=__UpperCAmelCase    ,				class_labels=__UpperCAmelCase    ,				)

      # 3. Output
      a_							=			self.proj_out(__UpperCAmelCase)
      a_							=			(
          hidden_states[None, None, :]
          .reshape(__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase)
          .permute(0    ,				3    ,				4    ,				1    ,				2)
          .contiguous()
      )
      a_							=			hidden_states.reshape(__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase)

      a_							=			hidden_states + residual

      if not return_dict:
         return (output,)

      return TransformerTemporalModelOutput(sample=__UpperCAmelCase)

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