





"""simple docstring"""


import os
import string
import sys


A_	: Any      				=1 << 8

A_	: Optional[int]      				={
    'tab': ord("""\t"""),
    'newline': ord("""\r"""),
    'esc': 2_7,
    'up': 6_5 + ARROW_KEY_FLAG,
    'down': 6_6 + ARROW_KEY_FLAG,
    'right': 6_7 + ARROW_KEY_FLAG,
    'left': 6_8 + ARROW_KEY_FLAG,
    'mod_int': 9_1,
    'undefined': sys.maxsize,
    'interrupt': 3,
    'insert': 5_0,
    'delete': 5_1,
    'pg_up': 5_3,
    'pg_down': 5_4,
}

A_	: Dict      				=KEYMAP['up']
A_	: int      				=KEYMAP['left']

if sys.platform == "win32":
      A_	: Any      				=[]
      A_	: List[str]      				={
          b'\xe0H': KEYMAP['up'] - ARROW_KEY_FLAG,
          b'\x00H': KEYMAP['up'] - ARROW_KEY_FLAG,
          b'\xe0P': KEYMAP['down'] - ARROW_KEY_FLAG,
          b'\x00P': KEYMAP['down'] - ARROW_KEY_FLAG,
          b'\xe0M': KEYMAP['right'] - ARROW_KEY_FLAG,
          b'\x00M': KEYMAP['right'] - ARROW_KEY_FLAG,
          b'\xe0K': KEYMAP['left'] - ARROW_KEY_FLAG,
          b'\x00K': KEYMAP['left'] - ARROW_KEY_FLAG,
      }

for i in range(1_0):
      A_	: Union[str, Any]      				=ord(str(i))





def SCREAMING_SNAKE_CASE_  (			)->						Dict:
       if os.name == "nt":
              import msvcrt

              _lowerCamelCase             =   'mbcs'
              # Flush the keyboard buffer
              while msvcrt.kbhit():
                     msvcrt.getch()
              if len(__UpperCAmelCase						) == 0:
                     # Read the keystroke
                     _lowerCamelCase             =   msvcrt.getch()

                     # If it is a prefix char, get second part
                     if ch in (b"\x00", b"\xe0"):
                            _lowerCamelCase             =   ch + msvcrt.getch()
                            # Translate actual Win chars to bullet char types
                            try:
                                   _lowerCamelCase             =   chr(WIN_KEYMAP[cha]						)
                                   WIN_CH_BUFFER.append(chr(KEYMAP['mod_int']						)						)
                                   WIN_CH_BUFFER.append(__UpperCAmelCase						)
                                   if ord(__UpperCAmelCase						) in (
                                       KEYMAP["insert"] - 1 << 9,
                                       KEYMAP["delete"] - 1 << 9,
                                       KEYMAP["pg_up"] - 1 << 9,
                                       KEYMAP["pg_down"] - 1 << 9,
                                   ):
                                          WIN_CH_BUFFER.append(chr(126						)						)
                                   _lowerCamelCase             =   chr(KEYMAP['esc']						)
                            except KeyError:
                                   _lowerCamelCase             =   cha[1]
                     else:
                            _lowerCamelCase             =   ch.decode(__UpperCAmelCase						)
              else:
                     _lowerCamelCase             =   WIN_CH_BUFFER.pop(0						)
       elif os.name == "posix":
              import termios
              import tty

              _lowerCamelCase             =   sys.stdin.fileno()
              _lowerCamelCase             =   termios.tcgetattr(__UpperCAmelCase						)
              try:
                     tty.setraw(__UpperCAmelCase						)
                     _lowerCamelCase             =   sys.stdin.read(1						)
              finally:
                     termios.tcsetattr(__UpperCAmelCase		,    termios.TCSADRAIN		,    __UpperCAmelCase						)
       return ch





def SCREAMING_SNAKE_CASE_  (			)->						List[str]:
       _lowerCamelCase             =   get_raw_chars()
       if ord(__UpperCAmelCase						) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
              return char

       elif ord(__UpperCAmelCase						) == KEYMAP["esc"]:
              _lowerCamelCase             =   get_raw_chars()
              if ord(__UpperCAmelCase						) == KEYMAP["mod_int"]:
                     _lowerCamelCase             =   get_raw_chars()
                     if ord(__UpperCAmelCase						) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(__UpperCAmelCase						) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
                            return chr(ord(__UpperCAmelCase						) + ARROW_KEY_FLAG						)
                     else:
                            return KEYMAP["undefined"]
              else:
                     return get_raw_chars()

       else:
              if char in string.printable:
                     return char
              else:
                     return KEYMAP["undefined"]












from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase__					:  str      							=				logging.get_logger(__name__)

lowerCamelCase__					:  Tuple      							=				{
    'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/config.json',
    'funnel-transformer/small-base': 'https://huggingface.co/funnel-transformer/small-base/resolve/main/config.json',
    'funnel-transformer/medium': 'https://huggingface.co/funnel-transformer/medium/resolve/main/config.json',
    'funnel-transformer/medium-base': 'https://huggingface.co/funnel-transformer/medium-base/resolve/main/config.json',
    'funnel-transformer/intermediate': (
        'https://huggingface.co/funnel-transformer/intermediate/resolve/main/config.json'
    ),
    'funnel-transformer/intermediate-base': (
        'https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/config.json'
    ),
    'funnel-transformer/large': 'https://huggingface.co/funnel-transformer/large/resolve/main/config.json',
    'funnel-transformer/large-base': 'https://huggingface.co/funnel-transformer/large-base/resolve/main/config.json',
    'funnel-transformer/xlarge': 'https://huggingface.co/funnel-transformer/xlarge/resolve/main/config.json',
    'funnel-transformer/xlarge-base': 'https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/config.json',
}





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 lowercase_							       =       "funnel"
 lowercase_							       =       {
     "hidden_size": "d_model",
     "num_attention_heads": "n_head",
 }



 def __init__(				self    :						int							,							_lowerCAmelCase    :						Optional[int]=30_522							,							_lowerCAmelCase    :						List[str]=[4, 4, 4]							,							_lowerCAmelCase    :						Tuple=None							,							_lowerCAmelCase    :						Optional[int]=2							,							_lowerCAmelCase    :						int=768							,							_lowerCAmelCase    :						Optional[Any]=12							,							_lowerCAmelCase    :						Optional[Any]=64							,							_lowerCAmelCase    :						Optional[Any]=3_072							,							_lowerCAmelCase    :						List[str]="gelu_new"							,							_lowerCAmelCase    :						Any=0.1							,							_lowerCAmelCase    :						int=0.1							,							_lowerCAmelCase    :						Tuple=0.0							,							_lowerCAmelCase    :						List[Any]=0.1							,							_lowerCAmelCase    :						Dict=None							,							_lowerCAmelCase    :						str=1E-9							,							_lowerCAmelCase    :						Any="mean"							,							_lowerCAmelCase    :						Union[str, Any]="relative_shift"							,							_lowerCAmelCase    :						Optional[Any]=True							,							_lowerCAmelCase    :						Dict=True							,							_lowerCAmelCase    :						Tuple=True							,							**_lowerCAmelCase    :						Optional[Any]							,							):
       SCREAMING_SNAKE_CASE_      		=     vocab_size
       SCREAMING_SNAKE_CASE_      		=     block_sizes
       SCREAMING_SNAKE_CASE_      		=     [1] * len(_lowerCAmelCase		) if block_repeats is None else block_repeats
       assert len(_lowerCAmelCase		) == len(
           self.block_repeats		), "`block_sizes` and `block_repeats` should have the same length."
       SCREAMING_SNAKE_CASE_      		=     num_decoder_layers
       SCREAMING_SNAKE_CASE_      		=     d_model
       SCREAMING_SNAKE_CASE_      		=     n_head
       SCREAMING_SNAKE_CASE_      		=     d_head
       SCREAMING_SNAKE_CASE_      		=     d_inner
       SCREAMING_SNAKE_CASE_      		=     hidden_act
       SCREAMING_SNAKE_CASE_      		=     hidden_dropout
       SCREAMING_SNAKE_CASE_      		=     attention_dropout
       SCREAMING_SNAKE_CASE_      		=     activation_dropout
       SCREAMING_SNAKE_CASE_      		=     initializer_range
       SCREAMING_SNAKE_CASE_      		=     initializer_std
       SCREAMING_SNAKE_CASE_      		=     layer_norm_eps
       assert pooling_type in [
           "mean",
           "max",
       ], F"Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."
       SCREAMING_SNAKE_CASE_      		=     pooling_type
       assert attention_type in [
           "relative_shift",
           "factorized",
       ], F"Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."
       SCREAMING_SNAKE_CASE_      		=     attention_type
       SCREAMING_SNAKE_CASE_      		=     separate_cls
       SCREAMING_SNAKE_CASE_      		=     truncate_seq
       SCREAMING_SNAKE_CASE_      		=     pool_q_only

       super().__init__(**_lowerCAmelCase		)



 @property
 def  lowerCAmelCase_    (				self    :						Optional[int]		):
       return sum(self.block_sizes		)



 @num_hidden_layers.setter
 def  lowerCAmelCase_    (				self    :						int							,							_lowerCAmelCase    :						List[Any]		):
       raise NotImplementedError(
           'This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.'		)



 @property
 def  lowerCAmelCase_    (				self    :						List[Any]		):
       return len(self.block_sizes		)




 @num_blocks.setter
 def  lowerCAmelCase_    (				self    :						Dict							,							_lowerCAmelCase    :						Union[str, Any]		):
       raise NotImplementedError('This model does not support the setting of `num_blocks`. Please set `block_sizes`.'		)