






from collections import OrderedDict
from typing import Mapping

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


_a   			=						logging.get_logger(__name__)

_a   			=						{
    '''mnaylor/mega-base-wikitext''': '''https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json''',
}





class __lowerCamelCase				(   snake_case__):





	"""simple docstring"""






	UpperCamelCase__			=   "mega"

	def __init__(							self ,					UpperCAmelCase=3_0522 ,					UpperCAmelCase=128 ,					UpperCAmelCase=4 ,					UpperCAmelCase=256 ,					UpperCAmelCase=16 ,					UpperCAmelCase=True ,					UpperCAmelCase=64 ,					UpperCAmelCase=False ,					UpperCAmelCase=-1 ,					UpperCAmelCase=None ,					UpperCAmelCase=True ,					UpperCAmelCase="scalenorm" ,					UpperCAmelCase=True ,					UpperCAmelCase="silu" ,					UpperCAmelCase="softmax" ,					UpperCAmelCase=0.1 ,					UpperCAmelCase=0.1 ,					UpperCAmelCase=0.1 ,					UpperCAmelCase=False ,					UpperCAmelCase=True ,					UpperCAmelCase=256 ,					UpperCAmelCase=True ,					UpperCAmelCase=0.1 ,					UpperCAmelCase=2048 ,					UpperCAmelCase=False ,					UpperCAmelCase=2 ,					UpperCAmelCase=0.02 ,					UpperCAmelCase=0.2 ,					UpperCAmelCase=0.02 ,					UpperCAmelCase=1.0 ,					UpperCAmelCase=1 ,					UpperCAmelCase=0 ,					UpperCAmelCase=2 ,					UpperCAmelCase="rotary" ,					UpperCAmelCase=None ,					UpperCAmelCase=True ,					UpperCAmelCase=True ,					**UpperCAmelCase ,					):
							"""simple docstring"""







							super().__init__(pad_token_id=UpperCAmelCase ,					bos_token_id=UpperCAmelCase ,					eos_token_id=UpperCAmelCase ,					**UpperCAmelCase					)

							_UpperCAmelCase             =    vocab_size
							_UpperCAmelCase             =    hidden_size
							_UpperCAmelCase             =    num_hidden_layers
							_UpperCAmelCase             =    activation
							_UpperCAmelCase             =    attention_activation
							_UpperCAmelCase             =    intermediate_size
							_UpperCAmelCase             =    ema_projection_size
							_UpperCAmelCase             =    bidirectional
							_UpperCAmelCase             =    shared_representation_size
							_UpperCAmelCase             =    use_chunking
							_UpperCAmelCase             =    chunk_size
							_UpperCAmelCase             =    truncation
							_UpperCAmelCase             =    normalize_before_mega
							_UpperCAmelCase             =    normalization_type
							_UpperCAmelCase             =    norm_affine
							_UpperCAmelCase             =    dropout_prob
							_UpperCAmelCase             =    hidden_dropout_prob
							_UpperCAmelCase             =    attention_probs_dropout_prob
							_UpperCAmelCase             =    use_feature_dropout
							_UpperCAmelCase             =    use_normalized_ffn
							_UpperCAmelCase             =    nffn_hidden_size
							_UpperCAmelCase             =    normalize_before_ffn
							_UpperCAmelCase             =    nffn_activation_dropout_prob
							_UpperCAmelCase             =    max_positions
							_UpperCAmelCase             =    add_token_type_embeddings
							_UpperCAmelCase             =    type_vocab_size
							_UpperCAmelCase             =    initializer_range
							_UpperCAmelCase             =    ema_delta_alpha_range
							_UpperCAmelCase             =    ema_beta_range
							_UpperCAmelCase             =    ema_gamma_omega_range
							_UpperCAmelCase             =    relative_positional_bias
							_UpperCAmelCase             =    use_cache
							_UpperCAmelCase             =    classifier_dropout
							_UpperCAmelCase             =    add_lm_hidden_dense_layer
							_UpperCAmelCase             =    1  # not used but required by Hugging Face





class __lowerCamelCase				(   snake_case__):





	"""simple docstring"""






	@property
	def  UpperCamelCase					(							self					):
							"""simple docstring"""







							if self.task == "multiple-choice":
													_UpperCAmelCase             =    {0: 'batch', 1: 'choice', 2: 'sequence'}
							else:
													_UpperCAmelCase             =    {0: 'batch', 1: 'sequence'}
							return OrderedDict(
							    [
							        ('input_ids', dynamic_axis),
							        ('attention_mask', dynamic_axis),
							    ]					)













import math
from timeit import timeit


def __A					(   __lowerCAmelCase			)->						int:





						"""simple docstring"""



						_UpperCAmelCase             =    0
						_UpperCAmelCase             =    abs(__lowerCAmelCase			)
						while True:
												_UpperCAmelCase             =    n // 10
												digits += 1
												if n == 0:
																		break
						return digits


def __A					(   __lowerCAmelCase			)->						int:





						"""simple docstring"""



						return 1 if n == 0 else math.floor(math.log(abs(__lowerCAmelCase			)				,	10			) + 1			)


def __A					(   __lowerCAmelCase			)->						int:





						"""simple docstring"""



						return len(str(abs(__lowerCAmelCase			)			)			)


def __A					(   )->						None:





						"""simple docstring"""



						from collections.abc import Callable

						def benchmark_a_function(__lowerCAmelCase				,	__lowerCAmelCase			) -> None:
												_UpperCAmelCase             =    F"""{func.__name__}({value})"""
												_UpperCAmelCase             =    timeit(F"""__main__.{call}"""				,	setup='import __main__'			)
												print(F"""{call}: {func(__lowerCAmelCase			)} -- {timing} seconds"""			)

						for value in (262_144, 1_125_899_906_842_624, 1_267_650_600_228_229_401_496_703_205_376):
												for func in (num_digits, num_digits_fast, num_digits_faster):
																		benchmark_a_function(__lowerCAmelCase				,	__lowerCAmelCase			)
												print()


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		benchmark()
