"""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 lowerCamelCase		(UpperCamelCase__      ):






					'''simple docstring'''


					a   	=		4_2



class lowerCamelCase		(UpperCamelCase__    ,    UpperCamelCase__      ):






					'''simple docstring'''


					@register_to_config
					def __init__(						self			:				Optional[Any]   , _snake_case			:				int = 16   , _snake_case			:				int = 88   , _snake_case			:				Optional[int] = None   , _snake_case			:				Optional[int] = None   , _snake_case			:				int = 1   , _snake_case			:				float = 0.0   , _snake_case			:				int = 32   , _snake_case			:				Optional[int] = None   , _snake_case			:				bool = False   , _snake_case			:				Optional[int] = None   , _snake_case			:				str = "geglu"   , _snake_case			:				bool = True   , _snake_case			:				bool = True   , )							->       List[Any]:
									super().__init__()
									SCREAMING_SNAKE_CASE__		  =				num_attention_heads
									SCREAMING_SNAKE_CASE__		  =				attention_head_dim
									SCREAMING_SNAKE_CASE__		  =				num_attention_heads * attention_head_dim

									SCREAMING_SNAKE_CASE__		  =				in_channels

									SCREAMING_SNAKE_CASE__		  =				torch.nn.GroupNorm(num_groups=__A   , num_channels=__A   , eps=1e-6   , affine=__A		)
									SCREAMING_SNAKE_CASE__		  =				nn.Linear(__A   , __A		)

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

									SCREAMING_SNAKE_CASE__		  =				nn.Linear(__A   , __A		)



					def 			lowerCAmelCase_					(						self			:				Any   , _snake_case			:				int   , _snake_case			:				int=None   , _snake_case			:				Tuple=None   , _snake_case			:				str=None   , _snake_case			:				str=1   , _snake_case			:				str=None   , _snake_case			:				bool = True   , )							->       List[str]:
									SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				hidden_states.shape
									SCREAMING_SNAKE_CASE__		  =				batch_frames // num_frames

									SCREAMING_SNAKE_CASE__		  =				hidden_states

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

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

									SCREAMING_SNAKE_CASE__		  =				self.proj_in(__A		)

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

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

									SCREAMING_SNAKE_CASE__		  =				hidden_states + residual

									if not return_dict:
													return (output,)

									return TransformerTemporalModelOutput(sample=__A		)





"""simple docstring"""






import os

from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home


_A   					=    HUGGINGFACE_HUB_CACHE


_A   					=    'config.json'
_A   					=    'diffusion_pytorch_model.bin'
_A   					=    'diffusion_flax_model.msgpack'
_A   					=    'model.onnx'
_A   					=    'diffusion_pytorch_model.safetensors'
_A   					=    'weights.pb'
_A   					=    'https://huggingface.co'
_A   					=    default_cache_path
_A   					=    'diffusers_modules'
_A   					=    os.getenv('HF_MODULES_CACHE', os.path.join(hf_cache_home, 'modules'))
_A   					=    ['fp16', 'non-ema']
_A   					=    '.self_attn'




