






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        __UpperCamelCase    (     _lowerCAmelCase   ):
	__snake_case	:torch.FloatTensor


class        __UpperCamelCase    (     _lowerCAmelCase   ,			_lowerCAmelCase   ):







	@register_to_config
	def __init__(  self      :							str       ,				_lowerCAmelCase      :							int = 16       ,				_lowerCAmelCase      :							int = 88       ,				_lowerCAmelCase      :							Optional[int] = None       ,				_lowerCAmelCase      :							Optional[int] = None       ,				_lowerCAmelCase      :							int = 1       ,				_lowerCAmelCase      :							float = 0.0       ,				_lowerCAmelCase      :							int = 32       ,				_lowerCAmelCase      :							Optional[int] = None       ,				_lowerCAmelCase      :							bool = False       ,				_lowerCAmelCase      :							Optional[int] = None       ,				_lowerCAmelCase      :							str = "geglu"       ,				_lowerCAmelCase      :							bool = True       ,				_lowerCAmelCase      :							bool = True       ,				)		-> Optional[int]:
					"""simple docstring"""







					super().__init__()
					__lowercase             =  num_attention_heads
					__lowercase             =  attention_head_dim
					__lowercase             =  num_attention_heads * attention_head_dim

					__lowercase             =  in_channels

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

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

					__lowercase             =  nn.Linear(_lowerCAmelCase       ,				_lowerCAmelCase			)







	def  _a   (  self      :							Optional[int]       ,				_lowerCAmelCase      :							str       ,				_lowerCAmelCase      :							List[Any]=None       ,				_lowerCAmelCase      :							int=None       ,				_lowerCAmelCase      :							Any=None       ,				_lowerCAmelCase      :							List[str]=1       ,				_lowerCAmelCase      :							Any=None       ,				_lowerCAmelCase      :							bool = True       ,				)		-> Tuple:
					"""simple docstring"""







					__lowercase       ,						__lowercase       ,						__lowercase       ,						__lowercase             =  hidden_states.shape
					__lowercase             =  batch_frames // num_frames

					__lowercase             =  hidden_states

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

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

					__lowercase             =  self.proj_in(_lowerCAmelCase			)

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

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

					__lowercase             =  hidden_states + residual

					if not return_dict:
									return (output,)

					return TransformerTemporalModelOutput(sample=_lowerCAmelCase			)









from math import sqrt





def 				snake_case  (     lowerCamelCase					):




	'''simple docstring'''







	if 1 < number < 4:
		# 2 and 3 are primes
		return True
	elif number < 2 or number % 2 == 0 or number % 3 == 0:
		# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
		return False

	# All primes number are in format of 6k +/- 1
	for i in range(5				,  int(sqrt(lowerCamelCase					) + 1					)				,  6					):
		if number % i == 0 or number % (i + 2) == 0:
			return False
	return True





def 				snake_case  (     lowerCamelCase = 10_001					):




	'''simple docstring'''







	__lowercase             =  0
	__lowercase             =  1
	while count != nth and number < 3:
		number += 1
		if is_prime(lowerCamelCase					):
			count += 1
	while count != nth:
		number += 2
		if is_prime(lowerCamelCase					):
			count += 1
	return number


if __name__ == "__main__":
						print(F'''{solution() = }''')

