from dataclasses import dataclass
from typing import Optional, Tuple, Union

import torch
import torch.nn as nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, apply_forward_hook
from .modeling_utils import ModelMixin
from .vae import Decoder, DecoderOutput, Encoder, VectorQuantizer




@dataclass
class    _UpperCamelCase      (						_UpperCAmelCase ):


			"""simple docstring"""






			__a  : torch.FloatTensor




class    _UpperCamelCase      (						_UpperCAmelCase						,_UpperCAmelCase ):


			"""simple docstring"""






			@register_to_config
			def __init__(   self      ,   lowerCAmelCase__ = 3      ,   lowerCAmelCase__ = 3      ,   lowerCAmelCase__ = ("DownEncoderBlock2D",)      ,   lowerCAmelCase__ = ("UpDecoderBlock2D",)      ,   lowerCAmelCase__ = (64,)      ,   lowerCAmelCase__ = 1      ,   lowerCAmelCase__ = "silu"      ,   lowerCAmelCase__ = 3      ,   lowerCAmelCase__ = 32      ,   lowerCAmelCase__ = 2_56      ,   lowerCAmelCase__ = 32      ,   lowerCAmelCase__ = None      ,   lowerCAmelCase__ = 0.1_8215      ,   lowerCAmelCase__ = "group"      ,   )     ->					Any:

							'''simple docstring'''


							super().__init__()

							# pass init params to Encoder
							__lowercase 			=							Encoder(
							    in_channels=lowerCAmelCase__      ,   out_channels=lowerCAmelCase__      ,   down_block_types=lowerCAmelCase__      ,   block_out_channels=lowerCAmelCase__      ,   layers_per_block=lowerCAmelCase__      ,   act_fn=lowerCAmelCase__      ,   norm_num_groups=lowerCAmelCase__      ,   double_z=lowerCAmelCase__      ,   )

							__lowercase 			=							vq_embed_dim if vq_embed_dim is not None else latent_channels

							__lowercase 			=							nn.Convad(lowerCAmelCase__      ,   lowerCAmelCase__      ,   1						)
							__lowercase 			=							VectorQuantizer(lowerCAmelCase__      ,   lowerCAmelCase__      ,   beta=0.25      ,   remap=lowerCAmelCase__      ,   sane_index_shape=lowerCAmelCase__						)
							__lowercase 			=							nn.Convad(lowerCAmelCase__      ,   lowerCAmelCase__      ,   1						)

							# pass init params to Decoder
							__lowercase 			=							Decoder(
							    in_channels=lowerCAmelCase__      ,   out_channels=lowerCAmelCase__      ,   up_block_types=lowerCAmelCase__      ,   block_out_channels=lowerCAmelCase__      ,   layers_per_block=lowerCAmelCase__      ,   act_fn=lowerCAmelCase__      ,   norm_num_groups=lowerCAmelCase__      ,   norm_type=lowerCAmelCase__      ,   )





			@apply_forward_hook
			def        _SCREAMING_SNAKE_CASE			(   self      ,   lowerCAmelCase__      ,   lowerCAmelCase__ = True						)     ->					VQEncoderOutput:

							'''simple docstring'''


							__lowercase 			=							self.encoder(lowerCAmelCase__						)
							__lowercase 			=							self.quant_conv(lowerCAmelCase__						)

							if not return_dict:
											return (h,)

							return VQEncoderOutput(latents=lowerCAmelCase__						)





			@apply_forward_hook
			def        _SCREAMING_SNAKE_CASE			(   self      ,   lowerCAmelCase__      ,   lowerCAmelCase__ = False      ,   lowerCAmelCase__ = True						)     ->					Union[DecoderOutput, torch.FloatTensor]:

							'''simple docstring'''


							if not force_not_quantize:
											__lowercase			,     __lowercase			,     __lowercase 			=							self.quantize(lowerCAmelCase__						)
							else:
											__lowercase 			=							h
							__lowercase 			=							self.post_quant_conv(lowerCAmelCase__						)
							__lowercase 			=							self.decoder(lowerCAmelCase__      ,   quant if self.config.norm_type == '''spatial''' else None						)

							if not return_dict:
											return (dec,)

							return DecoderOutput(sample=lowerCAmelCase__						)





			def        _SCREAMING_SNAKE_CASE			(   self      ,   lowerCAmelCase__      ,   lowerCAmelCase__ = True						)     ->					Union[DecoderOutput, torch.FloatTensor]:

							'''simple docstring'''


							__lowercase 			=							sample
							__lowercase 			=							self.encode(lowerCAmelCase__						).latents
							__lowercase 			=							self.decode(lowerCAmelCase__						).sample

							if not return_dict:
											return (dec,)

							return DecoderOutput(sample=lowerCAmelCase__						)
from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a  :     str       =  logging.get_logger(__name__)

__a  :     Optional[int]       =  {
    """google/vivit-b-16x2-kinetics400""": (
        """https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json"""
    ),
    # See all Vivit models at https://huggingface.co/models?filter=vivit
}




class    _UpperCamelCase      (						_UpperCAmelCase ):


			"""simple docstring"""






			__a  : Tuple			 =						'''vivit'''





			def __init__(   self      ,   lowerCAmelCase__=2_24      ,   lowerCAmelCase__=32      ,   lowerCAmelCase__=[2, 16, 16]      ,   lowerCAmelCase__=3      ,   lowerCAmelCase__=7_68      ,   lowerCAmelCase__=12      ,   lowerCAmelCase__=12      ,   lowerCAmelCase__=30_72      ,   lowerCAmelCase__="gelu_fast"      ,   lowerCAmelCase__=0.0      ,   lowerCAmelCase__=0.0      ,   lowerCAmelCase__=0.02      ,   lowerCAmelCase__=1E-06      ,   lowerCAmelCase__=True      ,   **lowerCAmelCase__      ,   )     ->					int:

							'''simple docstring'''


							__lowercase 			=							hidden_size
							__lowercase 			=							num_hidden_layers
							__lowercase 			=							num_attention_heads
							__lowercase 			=							intermediate_size
							__lowercase 			=							hidden_act
							__lowercase 			=							hidden_dropout_prob
							__lowercase 			=							attention_probs_dropout_prob
							__lowercase 			=							initializer_range
							__lowercase 			=							layer_norm_eps

							__lowercase 			=							image_size
							__lowercase 			=							num_frames
							__lowercase 			=							tubelet_size
							__lowercase 			=							num_channels
							__lowercase 			=							qkv_bias

							super().__init__(**lowerCAmelCase__						)