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


UpperCamelCase  							=						logging.get_logger(__name__)

UpperCamelCase  							=						{
    '''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   snake_case_       (		__A       ):
   __A	:		Optional[int]         =				"funnel"
   __A	:		Optional[int]         =				{
       "hidden_size": "d_model",
       "num_attention_heads": "n_head",
   }






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

       super().__init__(**lowercase_  )






   @property
   def       __UpperCamelCase     (      self				:     int  )					->						Optional[Any]:
       return sum(self.block_sizes  )






   @num_hidden_layers.setter
   def       __UpperCamelCase     (      self				:     Optional[Any]	,						lowercase_				:     List[Any]  )					->						int:
       raise NotImplementedError(
           "This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`."  )






   @property
   def       __UpperCamelCase     (      self				:     Any  )					->						Dict:
       return len(self.block_sizes  )







   @num_blocks.setter
   def       __UpperCamelCase     (      self				:     Union[str, Any]	,						lowercase_				:     Tuple  )					->						Optional[int]:
       raise NotImplementedError("This model does not support the setting of `num_blocks`. Please set `block_sizes`."  )









'''simple docstring'''







from __future__ import annotations





def 						snake_case_							(_a	:							Dict    ,   _a	:							str    ,   _a	:							Optional[Any]    ,   _a	:							List[str]     ):  # noqa: E741
    while r - l > 1:
        UpperCAmelCase			       =		(l + r) // 2
        if v[m] >= key:
            UpperCAmelCase			       =		m
        else:
            UpperCAmelCase			       =		m  # noqa: E741
    return r





def 						snake_case_							(_a	:							list[int]     ):
    if len(_a     ) == 0:
        return 0

    UpperCAmelCase			       =		[0] * len(_a     )
    UpperCAmelCase			       =		1

    UpperCAmelCase			       =		v[0]

    for i in range(1    ,   len(_a     )     ):
        if v[i] < tail[0]:
            UpperCAmelCase			       =		v[i]
        elif v[i] > tail[length - 1]:
            UpperCAmelCase			       =		v[i]
            length += 1
        else:
            UpperCAmelCase			       =		v[i]

    return length


if __name__ == "__main__":
   import doctest

   doctest.testmod()




