


from ...configuration_utils import PretrainedConfig


UpperCAmelCase_      : Any  					=       {
    'google/tapas-base-finetuned-sqa': (
        'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-wtq': (
        'https://huggingface.co/google/tapas-base-finetuned-wtq/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-wikisql-supervised': (
        'https://huggingface.co/google/tapas-base-finetuned-wikisql-supervised/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-tabfact': (
        'https://huggingface.co/google/tapas-base-finetuned-tabfact/resolve/main/config.json'
    ),
}
class  SCREAMING_SNAKE_CASE__  (				lowercase__			):
      snake_case__				:     List[Any]        =						'''tapas'''
      def __init__(       self				:       Optional[int]     ,							SCREAMING_SNAKE_CASE__				:       int=3_0_5_2_2     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=7_6_8     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=1_2     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=1_2     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=3_0_7_2     ,							SCREAMING_SNAKE_CASE__				:       Optional[Any]="gelu"     ,							SCREAMING_SNAKE_CASE__				:       int=0.1     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=0.1     ,							SCREAMING_SNAKE_CASE__				:       Tuple=1_0_2_4     ,							SCREAMING_SNAKE_CASE__				:       List[str]=[3, 2_5_6, 2_5_6, 2, 2_5_6, 2_5_6, 1_0]     ,							SCREAMING_SNAKE_CASE__				:       str=0.02     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=1E-12     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=0     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=10.0     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=0     ,							SCREAMING_SNAKE_CASE__				:       Optional[int]=1.0     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=None     ,							SCREAMING_SNAKE_CASE__				:       List[str]=1.0     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=False     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=None     ,							SCREAMING_SNAKE_CASE__				:       int=1.0     ,							SCREAMING_SNAKE_CASE__				:       int=1.0     ,							SCREAMING_SNAKE_CASE__				:       Tuple=False     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=False     ,							SCREAMING_SNAKE_CASE__				:       List[Any]="ratio"     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=None     ,							SCREAMING_SNAKE_CASE__				:       Dict=None     ,							SCREAMING_SNAKE_CASE__				:       List[str]=6_4     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=3_2     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=False     ,							SCREAMING_SNAKE_CASE__				:       Any=True     ,							SCREAMING_SNAKE_CASE__				:       Tuple=False     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=False     ,							SCREAMING_SNAKE_CASE__				:       Union[str, Any]=True     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=False     ,							SCREAMING_SNAKE_CASE__				:       List[Any]=None     ,							SCREAMING_SNAKE_CASE__				:       Tuple=None     ,							**SCREAMING_SNAKE_CASE__				:       str     ,							)		->			str:
             super().__init__(pad_token_id=SCREAMING_SNAKE_CASE__     ,							**SCREAMING_SNAKE_CASE__     )

             # BERT hyperparameters (with updated max_position_embeddings and type_vocab_sizes)
             a_					:		Any							=  vocab_size
             a_					:		int							=  hidden_size
             a_					:		List[str]							=  num_hidden_layers
             a_					:		Optional[Any]							=  num_attention_heads
             a_					:		Optional[int]							=  hidden_act
             a_					:		List[Any]							=  intermediate_size
             a_					:		Union[str, Any]							=  hidden_dropout_prob
             a_					:		Union[str, Any]							=  attention_probs_dropout_prob
             a_					:		Optional[Any]							=  max_position_embeddings
             a_					:		int							=  type_vocab_sizes
             a_					:		str							=  initializer_range
             a_					:		Optional[Any]							=  layer_norm_eps

             # Fine-tuning task hyperparameters
             a_					:		List[Any]							=  positive_label_weight
             a_					:		int							=  num_aggregation_labels
             a_					:		Union[str, Any]							=  aggregation_loss_weight
             a_					:		Dict							=  use_answer_as_supervision
             a_					:		Optional[int]							=  answer_loss_importance
             a_					:		Any							=  use_normalized_answer_loss
             a_					:		Optional[int]							=  huber_loss_delta
             a_					:		Tuple							=  temperature
             a_					:		str							=  aggregation_temperature
             a_					:		Union[str, Any]							=  use_gumbel_for_cells
             a_					:		Tuple							=  use_gumbel_for_aggregation
             a_					:		Any							=  average_approximation_function
             a_					:		Dict							=  cell_selection_preference
             a_					:		Any							=  answer_loss_cutoff
             a_					:		Dict							=  max_num_rows
             a_					:		str							=  max_num_columns
             a_					:		Union[str, Any]							=  average_logits_per_cell
             a_					:		List[Any]							=  select_one_column
             a_					:		Any							=  allow_empty_column_selection
             a_					:		int							=  init_cell_selection_weights_to_zero
             a_					:		List[Any]							=  reset_position_index_per_cell
             a_					:		Tuple							=  disable_per_token_loss

             # Aggregation hyperparameters
             a_					:		Union[str, Any]							=  aggregation_labels
             a_					:		Optional[int]							=  no_aggregation_label_index

             if isinstance(self.aggregation_labels     ,							SCREAMING_SNAKE_CASE__     ):
                    a_					:		Optional[Any]							=  {int(SCREAMING_SNAKE_CASE__     ): v for k, v in aggregation_labels.items()}






import math

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







def        SCREAMING_SNAKE_CASE_						(			__A :			jnp.ndarray  ,    __A :			int  ,    __A :			float = 1  ,    __A :			float = 1  ,    __A :			float = 1.0e4  ,    __A :			bool = False  ,    __A :			float = 1.0  ,    )	->		jnp.ndarray:

       """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"""
       a_					:		int							=  float(embedding_dim // 2				)
       a_					:		str							=  math.log(max_timescale / min_timescale				) / (num_timescales - freq_shift)
       a_					:		Optional[int]							=  min_timescale * jnp.exp(jnp.arange(__A  ,    dtype=jnp.floataa				) * -log_timescale_increment				)
       a_					:		Optional[int]							=  jnp.expand_dims(__A  ,    1				) * jnp.expand_dims(__A  ,    0				)

       # scale embeddings
       a_					:		str							=  scale * emb

       if flip_sin_to_cos:
              a_					:		str							=  jnp.concatenate([jnp.cos(__A				), jnp.sin(__A				)]  ,    axis=1				)
       else:
              a_					:		Any							=  jnp.concatenate([jnp.sin(__A				), jnp.cos(__A				)]  ,    axis=1				)
       a_					:		Optional[int]							=  jnp.reshape(__A  ,    [jnp.shape(__A				)[0], embedding_dim]				)
       return signal
class  SCREAMING_SNAKE_CASE__  (				nn.Module			):
      snake_case__				:     int        =						32
      snake_case__				:     jnp.dtype        =						jnp.floataa
      @nn.compact
      def __call__(       self				:       Tuple     ,							SCREAMING_SNAKE_CASE__				:       str     )		->			List[str]:
             a_					:		Optional[Any]							=  nn.Dense(self.time_embed_dim     ,							dtype=self.dtype     ,							name='linear_1'     )(SCREAMING_SNAKE_CASE__     )
             a_					:		Tuple							=  nn.silu(SCREAMING_SNAKE_CASE__     )
             a_					:		str							=  nn.Dense(self.time_embed_dim     ,							dtype=self.dtype     ,							name='linear_2'     )(SCREAMING_SNAKE_CASE__     )
             return temb
class  SCREAMING_SNAKE_CASE__  (				nn.Module			):
      snake_case__				:     int        =						32
      snake_case__				:     bool        =						False
      snake_case__				:     float        =						1
      @nn.compact
      def __call__(       self				:       str     ,							SCREAMING_SNAKE_CASE__				:       int     )		->			Tuple:
             return get_sinusoidal_embeddings(
                 SCREAMING_SNAKE_CASE__     ,							embedding_dim=self.dim     ,							flip_sin_to_cos=self.flip_sin_to_cos     ,							freq_shift=self.freq_shift     )


