


import functools
import operator

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


__snake_case									=		logging.get_logger(__name__)

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



class      __lowerCamelCase       (_a		):
       _lowercase											=			'''sew-d'''







       def __init__(       self:      List[str],A_:      Tuple=32,A_:      Dict=768,A_:      str=12,A_:      Optional[int]=12,A_:      Optional[int]=3072,A_:      str=2,A_:      Tuple=512,A_:      Optional[Any]=256,A_:      Tuple=True,A_:      Dict=True,A_:      Optional[Any]=("p2c", "c2p"),A_:      int="layer_norm",A_:      Any="gelu_python",A_:      Any=0.1,A_:      Any=0.1,A_:      List[str]=0.1,A_:      List[str]=0.0,A_:      Optional[int]=0.1,A_:      int=0.0_2,A_:      Dict=1E-7,A_:      str=1E-5,A_:      Optional[Any]="group",A_:      List[str]="gelu",A_:      Union[str, Any]=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512),A_:      int=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1),A_:      Dict=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1),A_:      int=False,A_:      List[str]=128,A_:      Optional[int]=16,A_:      int=True,A_:      List[Any]=0.0_5,A_:      str=10,A_:      Any=2,A_:      Tuple=0.0,A_:      Tuple=10,A_:      str=0,A_:      List[Any]="mean",A_:      str=False,A_:      List[Any]=False,A_:      Dict=256,A_:      Union[str, Any]=0,A_:      Union[str, Any]=1,A_:      Optional[Any]=2,**A_:      Dict,):






            '''simple docstring'''




            super().__init__(**_snake_case,pad_token_id=_snake_case,bos_token_id=_snake_case,eos_token_id=_snake_case )
            __UpperCamelCase      =       hidden_size
            __UpperCamelCase      =       feat_extract_norm
            __UpperCamelCase      =       feat_extract_activation
            __UpperCamelCase      =       list(_snake_case )
            __UpperCamelCase      =       list(_snake_case )
            __UpperCamelCase      =       list(_snake_case )
            __UpperCamelCase      =       conv_bias
            __UpperCamelCase      =       num_conv_pos_embeddings
            __UpperCamelCase      =       num_conv_pos_embedding_groups
            __UpperCamelCase      =       len(self.conv_dim )
            __UpperCamelCase      =       num_hidden_layers
            __UpperCamelCase      =       intermediate_size
            __UpperCamelCase      =       squeeze_factor
            __UpperCamelCase      =       max_position_embeddings
            __UpperCamelCase      =       position_buckets
            __UpperCamelCase      =       share_att_key
            __UpperCamelCase      =       relative_attention
            __UpperCamelCase      =       norm_rel_ebd
            __UpperCamelCase      =       list(_snake_case )
            __UpperCamelCase      =       hidden_act
            __UpperCamelCase      =       num_attention_heads
            __UpperCamelCase      =       hidden_dropout
            __UpperCamelCase      =       attention_dropout
            __UpperCamelCase      =       activation_dropout
            __UpperCamelCase      =       feat_proj_dropout
            __UpperCamelCase      =       final_dropout
            __UpperCamelCase      =       layer_norm_eps
            __UpperCamelCase      =       feature_layer_norm_eps
            __UpperCamelCase      =       initializer_range
            __UpperCamelCase      =       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
            __UpperCamelCase      =       apply_spec_augment
            __UpperCamelCase      =       mask_time_prob
            __UpperCamelCase      =       mask_time_length
            __UpperCamelCase      =       mask_time_min_masks
            __UpperCamelCase      =       mask_feature_prob
            __UpperCamelCase      =       mask_feature_length
            __UpperCamelCase      =       mask_feature_min_masks

            # ctc loss
            __UpperCamelCase      =       ctc_loss_reduction
            __UpperCamelCase      =       ctc_zero_infinity

            # sequence classification
            __UpperCamelCase      =       use_weighted_layer_sum
            __UpperCamelCase      =       classifier_proj_size







       @property
       def 						snake_case_     (       self:      Optional[int] ):






            '''simple docstring'''




            return functools.reduce(operator.mul,self.conv_stride,1 )








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


snake_case_ : int    		=       logging.get_logger(__name__)

snake_case_ : str    		=       {}







class __snake_case			(			a		):
   UpperCAmelCase__  :    str          =  '''llama'''
   UpperCAmelCase__  :    Dict          =  ['''past_key_values''']







   def __init__(      self		:						str					,						_snake_case		:						List[str]=32000					,						_snake_case		:						int=4096					,						_snake_case		:						List[str]=11008					,						_snake_case		:						Optional[int]=32					,						_snake_case		:						List[Any]=32					,						_snake_case		:						Tuple=None					,						_snake_case		:						int="silu"					,						_snake_case		:						List[Any]=2048					,						_snake_case		:						List[str]=0.0_2					,						_snake_case		:						Any=1e-6					,						_snake_case		:						List[str]=True					,						_snake_case		:						Optional[Any]=0					,						_snake_case		:						Dict=1					,						_snake_case		:						List[Any]=2					,						_snake_case		:						str=1					,						_snake_case		:						Union[str, Any]=False					,						_snake_case		:						str=None					,						**_snake_case		:						List[Any]					,						):

        """simple docstring"""


        UpperCAmelCase_          =							vocab_size
        UpperCAmelCase_          =							max_position_embeddings
        UpperCAmelCase_          =							hidden_size
        UpperCAmelCase_          =							intermediate_size
        UpperCAmelCase_          =							num_hidden_layers
        UpperCAmelCase_          =							num_attention_heads

        # for backward compatibility
        if num_key_value_heads is None:
             UpperCAmelCase_          =							num_attention_heads

        UpperCAmelCase_          =							num_key_value_heads
        UpperCAmelCase_          =							hidden_act
        UpperCAmelCase_          =							initializer_range
        UpperCAmelCase_          =							rms_norm_eps
        UpperCAmelCase_          =							pretraining_tp
        UpperCAmelCase_          =							use_cache
        UpperCAmelCase_          =							rope_scaling
        self._rope_scaling_validation()

        super().__init__(
            pad_token_id=_snake_case					,						bos_token_id=_snake_case					,						eos_token_id=_snake_case					,						tie_word_embeddings=_snake_case					,						**_snake_case					,						)







   def lowerCamelCase						(      self		:						Optional[int]):

        """simple docstring"""


        if self.rope_scaling is None:
             return

        if not isinstance(self.rope_scaling					,						_snake_case) or len(self.rope_scaling) != 2:
             raise ValueError(
                 '''`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, '''
                 F"""got {self.rope_scaling}""")
        UpperCAmelCase_          =							self.rope_scaling.get('''type'''					,						_snake_case)
        UpperCAmelCase_          =							self.rope_scaling.get('''factor'''					,						_snake_case)
        if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
             raise ValueError(
                 F"""`rope_scaling`'s name field must be one of ['linear', 'dynamic'], got {rope_scaling_type}""")
        if rope_scaling_factor is None or not isinstance(_snake_case					,						_snake_case) or rope_scaling_factor <= 1.0:
             raise ValueError(F"""`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}""")






