import math

import flax.linen as nn
import jax.numpy as jnp





def 				UpperCAmelCase						(    lowercase							,			lowercase							,			lowercase = 1							,			lowercase = 1							,			lowercase = 1.0E4							,			lowercase = False							,			lowercase = 1.0							,			):







				"""simple docstring"""



				assert timesteps.ndim == 1, "Timesteps should be a 1d-array"
				assert embedding_dim % 2 == 0, F"Embedding dimension {embedding_dim} should be even"
				__lowercase 			=							float(embedding_dim // 2							)
				__lowercase 			=							math.log(max_timescale / min_timescale							) / (num_timescales - freq_shift)
				__lowercase 			=							min_timescale * jnp.exp(jnp.arange(lowercase							,			dtype=jnp.floataa							) * -log_timescale_increment							)
				__lowercase 			=							jnp.expand_dims(lowercase							,			1							) * jnp.expand_dims(lowercase							,			0							)

				# scale embeddings
				__lowercase 			=							scale * emb

				if flip_sin_to_cos:
								__lowercase 			=							jnp.concatenate([jnp.cos(lowercase							), jnp.sin(lowercase							)]							,			axis=1							)
				else:
								__lowercase 			=							jnp.concatenate([jnp.sin(lowercase							), jnp.cos(lowercase							)]							,			axis=1							)
				__lowercase 			=							jnp.reshape(lowercase							,			[jnp.shape(lowercase							)[0], embedding_dim]							)
				return signal




class    _UpperCamelCase      (						nn.Module ):


			"""simple docstring"""






			__a  : int			 =						32
			__a  : jnp.dtype			 =						jnp.floataa





			@nn.compact
			def __call__(   self      ,   lowerCAmelCase__						)     ->					Dict:

							'''simple docstring'''


							__lowercase 			=							nn.Dense(self.time_embed_dim      ,   dtype=self.dtype      ,   name='''linear_1'''						)(lowerCAmelCase__						)
							__lowercase 			=							nn.silu(lowerCAmelCase__						)
							__lowercase 			=							nn.Dense(self.time_embed_dim      ,   dtype=self.dtype      ,   name='''linear_2'''						)(lowerCAmelCase__						)
							return temb




class    _UpperCamelCase      (						nn.Module ):


			"""simple docstring"""






			__a  : int			 =						32
			__a  : bool			 =						False
			__a  : float			 =						1





			@nn.compact
			def __call__(   self      ,   lowerCAmelCase__						)     ->					Optional[int]:

							'''simple docstring'''


							return get_sinusoidal_embeddings(
							    lowerCAmelCase__      ,   embedding_dim=self.dim      ,   flip_sin_to_cos=self.flip_sin_to_cos      ,   freq_shift=self.freq_shift						)
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__						)