





from collections import OrderedDict
from typing import Mapping

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


lowerCAmelCase_        =			logging.get_logger(__name__)

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



class 				_lowerCAmelCase			(	UpperCAmelCase_							):


  '''simple docstring'''
  a_							:				Optional[int]					    ="""mega"""







  def __init__(					self					:    str					, UpperCamelCase					:    Optional[Any]=3_05_22					, UpperCamelCase					:    Union[str, Any]=1_28					, UpperCamelCase					:    Any=4					, UpperCamelCase					:    str=2_56					, UpperCamelCase					:    Union[str, Any]=16					, UpperCamelCase					:    Any=True					, UpperCamelCase					:    Union[str, Any]=64					, UpperCamelCase					:    Tuple=False					, UpperCamelCase					:    Dict=-1					, UpperCamelCase					:    Union[str, Any]=None					, UpperCamelCase					:    int=True					, UpperCamelCase					:    List[str]="scalenorm"					, UpperCamelCase					:    List[Any]=True					, UpperCamelCase					:    Any="silu"					, UpperCamelCase					:    str="softmax"					, UpperCamelCase					:    str=0.1					, UpperCamelCase					:    str=0.1					, UpperCamelCase					:    Any=0.1					, UpperCamelCase					:    List[str]=False					, UpperCamelCase					:    Union[str, Any]=True					, UpperCamelCase					:    Union[str, Any]=2_56					, UpperCamelCase					:    Optional[int]=True					, UpperCamelCase					:    Any=0.1					, UpperCamelCase					:    List[Any]=20_48					, UpperCamelCase					:    List[str]=False					, UpperCamelCase					:    Tuple=2					, UpperCamelCase					:    Optional[int]=0.02					, UpperCamelCase					:    Any=0.2					, UpperCamelCase					:    List[str]=0.02					, UpperCamelCase					:    List[Any]=1.0					, UpperCamelCase					:    str=1					, UpperCamelCase					:    Dict=0					, UpperCamelCase					:    str=2					, UpperCamelCase					:    int="rotary"					, UpperCamelCase					:    Dict=None					, UpperCamelCase					:    Optional[Any]=True					, UpperCamelCase					:    List[Any]=True					, **UpperCamelCase					:    Union[str, Any]					, ):


    '''simple docstring'''





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

    _snake_case      : Optional[int]														=		vocab_size
    _snake_case      : Optional[int]														=		hidden_size
    _snake_case      : Optional[Any]														=		num_hidden_layers
    _snake_case      : str														=		activation
    _snake_case      : Tuple														=		attention_activation
    _snake_case      : List[str]														=		intermediate_size
    _snake_case      : int														=		ema_projection_size
    _snake_case      : List[Any]														=		bidirectional
    _snake_case      : str														=		shared_representation_size
    _snake_case      : List[Any]														=		use_chunking
    _snake_case      : Union[str, Any]														=		chunk_size
    _snake_case      : int														=		truncation
    _snake_case      : Tuple														=		normalize_before_mega
    _snake_case      : List[Any]														=		normalization_type
    _snake_case      : str														=		norm_affine
    _snake_case      : List[Any]														=		dropout_prob
    _snake_case      : Optional[Any]														=		hidden_dropout_prob
    _snake_case      : List[Any]														=		attention_probs_dropout_prob
    _snake_case      : str														=		use_feature_dropout
    _snake_case      : int														=		use_normalized_ffn
    _snake_case      : str														=		nffn_hidden_size
    _snake_case      : List[str]														=		normalize_before_ffn
    _snake_case      : List[str]														=		nffn_activation_dropout_prob
    _snake_case      : Optional[int]														=		max_positions
    _snake_case      : Union[str, Any]														=		add_token_type_embeddings
    _snake_case      : Any														=		type_vocab_size
    _snake_case      : Any														=		initializer_range
    _snake_case      : List[Any]														=		ema_delta_alpha_range
    _snake_case      : Any														=		ema_beta_range
    _snake_case      : Tuple														=		ema_gamma_omega_range
    _snake_case      : List[Any]														=		relative_positional_bias
    _snake_case      : List[Any]														=		use_cache
    _snake_case      : Dict														=		classifier_dropout
    _snake_case      : int														=		add_lm_hidden_dense_layer
    _snake_case      : List[str]														=		1  # not used but required by Hugging Face




class 				_lowerCAmelCase			(	UpperCAmelCase_							):


  '''simple docstring'''







  @property
  def UpperCamelCase_       (					self					:    List[str]							):


    '''simple docstring'''





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










from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any
class       __a					:


     """simple docstring"""


     _A				:    List[Any]									=  ("_front", "_back", "_len")
     @dataclass
     class       __a					:


          """simple docstring"""


          _A				:    Any									=  None
          _A				:    Deque._Node | None									=  None
          _A				:    Deque._Node | None									=  None






     class       __a					:


          """simple docstring"""


          _A				:    List[str]									=  ("_cur",)




          def __init__(	self			: int				,_UpperCamelCase			: Deque._Node | None						)		->   None:


              '''simple docstring'''





              SCREAMING_SNAKE_CASE__								=cur




          def __iter__(	self			: Optional[Any]						)		->   Deque._Iterator:


              '''simple docstring'''





              return self




          def   __A				(	self			: Union[str, Any]						)		->   Any:


              '''simple docstring'''





              if self._cur is None:
                  # finished iterating
                  raise StopIteration
              SCREAMING_SNAKE_CASE__								=self._cur.val
              SCREAMING_SNAKE_CASE__								=self._cur.next_node

              return val






     def __init__(	self			: Union[str, Any]				,_UpperCamelCase			: Iterable[Any] | None = None						)		->   None:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=None
         SCREAMING_SNAKE_CASE__								=None
         SCREAMING_SNAKE_CASE__								=0

         if iterable is not None:
             # append every value to the deque
             for val in iterable:
                 self.append(_UpperCamelCase						)




     def   __A				(	self			: Optional[Any]				,_UpperCamelCase			: Any						)		->   None:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=self._Node(_UpperCamelCase				,_UpperCamelCase				,_UpperCamelCase						)
         if self.is_empty():
             # front = back
             SCREAMING_SNAKE_CASE__								=SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=1
         else:
             # connect nodes
             SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=self._back
             SCREAMING_SNAKE_CASE__								=node  # assign new back to the new node

             self._len += 1

             # make sure there were no errors
             assert not self.is_empty(), "Error on appending value."




     def   __A				(	self			: Any				,_UpperCamelCase			: Any						)		->   None:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=self._Node(_UpperCamelCase				,_UpperCamelCase				,_UpperCamelCase						)
         if self.is_empty():
             # front = back
             SCREAMING_SNAKE_CASE__								=SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=1
         else:
             # connect nodes
             SCREAMING_SNAKE_CASE__								=self._front
             SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=node  # assign new front to the new node

             self._len += 1

             # make sure there were no errors
             assert not self.is_empty(), "Error on appending value."




     def   __A				(	self			: List[Any]				,_UpperCamelCase			: Iterable[Any]						)		->   None:


         '''simple docstring'''





         for val in iterable:
             self.append(_UpperCamelCase						)




     def   __A				(	self			: str				,_UpperCamelCase			: Iterable[Any]						)		->   None:


         '''simple docstring'''





         for val in iterable:
             self.appendleft(_UpperCamelCase						)




     def   __A				(	self			: str						)		->   Any:


         '''simple docstring'''





         assert not self.is_empty(), "Deque is empty."

         SCREAMING_SNAKE_CASE__								=self._back
         SCREAMING_SNAKE_CASE__								=self._back.prev_node  # set new back
         # drop the last node - python will deallocate memory automatically
         SCREAMING_SNAKE_CASE__								=None

         self._len -= 1

         return topop.val




     def   __A				(	self			: Union[str, Any]						)		->   Any:


         '''simple docstring'''





         assert not self.is_empty(), "Deque is empty."

         SCREAMING_SNAKE_CASE__								=self._front
         SCREAMING_SNAKE_CASE__								=self._front.next_node  # set new front and drop the first node
         SCREAMING_SNAKE_CASE__								=None

         self._len -= 1

         return topop.val




     def   __A				(	self			: Tuple						)		->   bool:


         '''simple docstring'''





         return self._front is None




     def __len__(	self			: Optional[int]						)		->   int:


         '''simple docstring'''





         return self._len




     def __eq__(	self			: Union[str, Any]				,_UpperCamelCase			: object						)		->   bool:


         '''simple docstring'''





         if not isinstance(_UpperCamelCase				,_UpperCamelCase						):
             return NotImplemented

         SCREAMING_SNAKE_CASE__								=self._front
         SCREAMING_SNAKE_CASE__								=other._front

         # if the length of the dequeues are not the same, they are not equal
         if len(self						) != len(_UpperCamelCase						):
             return False

         while me is not None and oth is not None:
             # compare every value
             if me.val != oth.val:
                 return False
             SCREAMING_SNAKE_CASE__								=me.next_node
             SCREAMING_SNAKE_CASE__								=oth.next_node

         return True




     def __iter__(	self			: Optional[Any]						)		->   Deque._Iterator:


         '''simple docstring'''





         return Deque._Iterator(self._front						)




     def __repr__(	self			: Optional[Any]						)		->   str:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=[]
         SCREAMING_SNAKE_CASE__								=self._front
         while aux is not None:
             # append the values in a list to display
             values_list.append(aux.val						)
             SCREAMING_SNAKE_CASE__								=aux.next_node

         return f"""[{", ".join(repr(_UpperCamelCase						) for val in values_list						)}]"""


if __name__ == "__main__":
    import doctest

    doctest.testmod()






