





import functools
import operator

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


__UpperCAmelCase					:     str	      =	logging.get_logger(__name__)

__UpperCAmelCase					:     Any	      =	{
    'asapp/sew-tiny-100k': 'https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.json',
    # See all SEW models at https://huggingface.co/models?filter=sew
}


class 			lowerCamelCase						(		SCREAMING_SNAKE_CASE  ):
  UpperCAmelCase		:       List[str]										=     'sew'







  def __init__(     self						:   Dict  ,					__snake_case						:   Dict=32  ,					__snake_case						:   int=768  ,					__snake_case						:   Optional[Any]=12  ,					__snake_case						:   Dict=12  ,					__snake_case						:   int=3072  ,					__snake_case						:   int=2  ,					__snake_case						:   Dict="gelu"  ,					__snake_case						:   Union[str, Any]=0.1  ,					__snake_case						:   Dict=0.1  ,					__snake_case						:   List[Any]=0.1  ,					__snake_case						:   str=0.0  ,					__snake_case						:   str=0.1  ,					__snake_case						:   Dict=0.1  ,					__snake_case						:   Any=0.02  ,					__snake_case						:   Optional[int]=1E-5  ,					__snake_case						:   Optional[int]="group"  ,					__snake_case						:   List[str]="gelu"  ,					__snake_case						:   List[Any]=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)  ,					__snake_case						:   List[str]=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)  ,					__snake_case						:   Dict=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)  ,					__snake_case						:   Union[str, Any]=False  ,					__snake_case						:   Union[str, Any]=128  ,					__snake_case						:   str=16  ,					__snake_case						:   Tuple=True  ,					__snake_case						:   Tuple=0.05  ,					__snake_case						:   int=10  ,					__snake_case						:   str=2  ,					__snake_case						:   Dict=0.0  ,					__snake_case						:   Optional[int]=10  ,					__snake_case						:   Tuple=0  ,					__snake_case						:   Any="mean"  ,					__snake_case						:   List[Any]=False  ,					__snake_case						:   Tuple=False  ,					__snake_case						:   Tuple=256  ,					__snake_case						:   Dict=0  ,					__snake_case						:   Tuple=1  ,					__snake_case						:   List[Any]=2  ,					**__snake_case						:   Any  ,					)    ->		Tuple:
        super().__init__(**_UpperCamelCase  ,					pad_token_id=_UpperCamelCase  ,					bos_token_id=_UpperCamelCase  ,					eos_token_id=_UpperCamelCase       )
        _a							:  List[str]				= hidden_size
        _a							:  Optional[int]				= feat_extract_norm
        _a							:  Optional[int]				= feat_extract_activation
        _a							:  Any				= list(_UpperCamelCase       )
        _a							:  str				= list(_UpperCamelCase       )
        _a							:  str				= list(_UpperCamelCase       )
        _a							:  int				= conv_bias
        _a							:  int				= num_conv_pos_embeddings
        _a							:  int				= num_conv_pos_embedding_groups
        _a							:  Union[str, Any]				= len(self.conv_dim       )
        _a							:  Optional[int]				= num_hidden_layers
        _a							:  str				= intermediate_size
        _a							:  List[str]				= squeeze_factor
        _a							:  Optional[int]				= hidden_act
        _a							:  Optional[Any]				= num_attention_heads
        _a							:  List[str]				= hidden_dropout
        _a							:  Union[str, Any]				= attention_dropout
        _a							:  Tuple				= activation_dropout
        _a							:  int				= feat_proj_dropout
        _a							:  Optional[Any]				= final_dropout
        _a							:  int				= layerdrop
        _a							:  Any				= layer_norm_eps
        _a							:  Tuple				= initializer_range
        _a							:  Tuple				= vocab_size

        if (
            (len(self.conv_stride       ) != self.num_feat_extract_layers)
            or (len(self.conv_kernel       ) != self.num_feat_extract_layers)
            or (len(self.conv_dim       ) != self.num_feat_extract_layers)
        ):
              raise ValueError(
                  '''Configuration for convolutional layers is incorrect.'''
                  '''It is required that `len(config.conv_dim)` == `len(config.conv_stride)` == `len(config.conv_kernel)`,'''
                  f"""but is `len(config.conv_dim) = {len(self.conv_dim       )}`, `len(config.conv_stride)"""
                  f"""= {len(self.conv_stride       )}`, `len(config.conv_kernel) = {len(self.conv_kernel       )}`."""       )

        # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
        _a							:  str				= apply_spec_augment
        _a							:  Any				= mask_time_prob
        _a							:  List[str]				= mask_time_length
        _a							:  Optional[Any]				= mask_time_min_masks
        _a							:  List[str]				= mask_feature_prob
        _a							:  Dict				= mask_feature_length
        _a							:  Tuple				= mask_feature_min_masks

        # ctc loss
        _a							:  Optional[Any]				= ctc_loss_reduction
        _a							:  Tuple				= ctc_zero_infinity

        # sequence classification
        _a							:  List[Any]				= use_weighted_layer_sum
        _a							:  int				= classifier_proj_size







  @property
  def      snake_case_							(     self						:   Optional[Any]       )    ->		Tuple:
        return functools.reduce(operator.mul  ,					self.conv_stride  ,					1       )









'''simple docstring'''
def 					lowerCamelCase_ ( __UpperCamelCase					:       list							,    __UpperCamelCase					:       int							,    __UpperCamelCase					:       int = 0							,    __UpperCamelCase					:       int = 0		)					->	int:







     """simple docstring"""
     _A				=							right or len(__UpperCamelCase		) - 1
     if left > right:
          return -1
     elif list_data[left] == key:
          return left
     elif list_data[right] == key:
          return right
     else:
          return search(__UpperCamelCase							,    __UpperCamelCase							,    left + 1							,    right - 1		)


if __name__ == "__main__":
    import doctest

    doctest.testmod()





