

'''simple docstring'''
from collections import OrderedDict
from typing import List, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_UpperCAmelCase  :		int  =		logging.get_logger(__name__)

_UpperCAmelCase  :		int  =		{
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}

class 						__magic_name__   (							__SCREAMING_SNAKE_CASE ):
 UpperCamelCase__     =       'efficientnet'







 def __init__(       self  , snake_case_ = 3  , snake_case_ = 6_00  , snake_case_ = 2.0  , snake_case_ = 3.1  , snake_case_ = 8  , snake_case_ = [3, 3, 5, 3, 5, 5, 3]  , snake_case_ = [32, 16, 24, 40, 80, 1_12, 1_92]  , snake_case_ = [16, 24, 40, 80, 1_12, 1_92, 3_20]  , snake_case_ = []  , snake_case_ = [1, 2, 2, 2, 1, 2, 1]  , snake_case_ = [1, 2, 2, 3, 3, 4, 1]  , snake_case_ = [1, 6, 6, 6, 6, 6, 6]  , snake_case_ = 0.25  , snake_case_ = "swish"  , snake_case_ = 25_60  , snake_case_ = "mean"  , snake_case_ = 0.02  , snake_case_ = 0.0_01  , snake_case_ = 0.99  , snake_case_ = 0.5  , snake_case_ = 0.2  , **snake_case_  , ):
   super().__init__(**snake_case_   )

   lowercase									=num_channels
   lowercase									=image_size
   lowercase									=width_coefficient
   lowercase									=depth_coefficient
   lowercase									=depth_divisor
   lowercase									=kernel_sizes
   lowercase									=in_channels
   lowercase									=out_channels
   lowercase									=depthwise_padding
   lowercase									=strides
   lowercase									=num_block_repeats
   lowercase									=expand_ratios
   lowercase									=squeeze_expansion_ratio
   lowercase									=hidden_act
   lowercase									=hidden_dim
   lowercase									=pooling_type
   lowercase									=initializer_range
   lowercase									=batch_norm_eps
   lowercase									=batch_norm_momentum
   lowercase									=dropout_rate
   lowercase									=drop_connect_rate
   lowercase									=sum(snake_case_   ) * 4

class 						__magic_name__   (							__SCREAMING_SNAKE_CASE ):
 UpperCamelCase__     =       version.parse('1.11' )







 @property
 def 						_A(       self   ):
   return OrderedDict(
       [
           ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
       ]   )







 @property
 def 						_A(       self   ):
   return 1E-5





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 ):
		SCREAMING_SNAKE_CASE__								=	42



class 	__snake_case   ( SCREAMING_SNAKE_CASE							, SCREAMING_SNAKE_CASE ):
		@register_to_config
		def __init__(							self    ,a_ = 16    ,a_ = 88    ,a_ = None    ,a_ = None    ,a_ = 1    ,a_ = 0.0    ,a_ = 32    ,a_ = None    ,a_ = False    ,a_ = None    ,a_ = "geglu"    ,a_ = True    ,a_ = True    ,):







						"""simple docstring"""
						super().__init__()
						lowerCAmelCase__		  =  num_attention_heads
						lowerCAmelCase__		  =  attention_head_dim
						lowerCAmelCase__		  =  num_attention_heads * attention_head_dim

						lowerCAmelCase__		  =  in_channels

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

						# 3. Define transformers blocks
						lowerCAmelCase__		  =  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_						)
						    ]						)

						lowerCAmelCase__		  =  nn.Linear(a_    ,a_						)



		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_    ,a_=None    ,a_=None    ,a_=None    ,a_=1    ,a_=None    ,a_ = True    ,):







						"""simple docstring"""
						lowerCAmelCase__  ,   lowerCAmelCase__  ,   lowerCAmelCase__  ,   lowerCAmelCase__		  =  hidden_states.shape
						lowerCAmelCase__		  =  batch_frames // num_frames

						lowerCAmelCase__		  =  hidden_states

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

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

						lowerCAmelCase__		  =  self.proj_in(a_						)

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

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

						lowerCAmelCase__		  =  hidden_states + residual

						if not return_dict:
										return (output,)

						return TransformerTemporalModelOutput(sample=a_						)
