
'''simple docstring'''
import functools
import operator

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


A__   :		List[str] 		=logging.get_logger(__name__)

A__   :		List[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  __A				( _SCREAMING_SNAKE_CASE			):
 lowerCamelCase				       ='''sew'''
 def __init__(   self			:    Any				,   lowerCamelCase			:    Union[str, Any]=32				,   lowerCamelCase			:    Union[str, Any]=7_68				,   lowerCamelCase			:    List[str]=12				,   lowerCamelCase			:    List[Any]=12				,   lowerCamelCase			:    Union[str, Any]=30_72				,   lowerCamelCase			:    int=2				,   lowerCamelCase			:    Tuple="gelu"				,   lowerCamelCase			:    Tuple=0.1				,   lowerCamelCase			:    Union[str, Any]=0.1				,   lowerCamelCase			:    Optional[int]=0.1				,   lowerCamelCase			:    Any=0.0				,   lowerCamelCase			:    Tuple=0.1				,   lowerCamelCase			:    List[str]=0.1				,   lowerCamelCase			:    List[str]=0.02				,   lowerCamelCase			:    Union[str, Any]=1e-5				,   lowerCamelCase			:    Any="group"				,   lowerCamelCase			:    Optional[Any]="gelu"				,   lowerCamelCase			:    Optional[Any]=(64, 1_28, 1_28, 1_28, 1_28, 2_56, 2_56, 2_56, 2_56, 5_12, 5_12, 5_12, 5_12)				,   lowerCamelCase			:    str=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)				,   lowerCamelCase			:    int=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)				,   lowerCamelCase			:    str=False				,   lowerCamelCase			:    Dict=1_28				,   lowerCamelCase			:    str=16				,   lowerCamelCase			:    Optional[int]=True				,   lowerCamelCase			:    Tuple=0.05				,   lowerCamelCase			:    Optional[Any]=10				,   lowerCamelCase			:    Union[str, Any]=2				,   lowerCamelCase			:    int=0.0				,   lowerCamelCase			:    str=10				,   lowerCamelCase			:    int=0				,   lowerCamelCase			:    List[Any]="mean"				,   lowerCamelCase			:    Optional[Any]=False				,   lowerCamelCase			:    Any=False				,   lowerCamelCase			:    int=2_56				,   lowerCamelCase			:    Optional[int]=0				,   lowerCamelCase			:    List[str]=1				,   lowerCamelCase			:    List[Any]=2				,   **lowerCamelCase			:    int				,   ):



   """simple docstring"""





   super().__init__(**lowerCamelCase				,   pad_token_id=lowerCamelCase				,   bos_token_id=lowerCamelCase				,   eos_token_id=lowerCamelCase       )
   __A		:     Dict												=		hidden_size
   __A		:     List[Any]												=		feat_extract_norm
   __A		:     List[str]												=		feat_extract_activation
   __A		:     Optional[Any]												=		list(lowerCamelCase       )
   __A		:     List[str]												=		list(lowerCamelCase       )
   __A		:     str												=		list(lowerCamelCase       )
   __A		:     Optional[Any]												=		conv_bias
   __A		:     Union[str, Any]												=		num_conv_pos_embeddings
   __A		:     Union[str, Any]												=		num_conv_pos_embedding_groups
   __A		:     Tuple												=		len(self.conv_dim       )
   __A		:     Optional[int]												=		num_hidden_layers
   __A		:     Dict												=		intermediate_size
   __A		:     str												=		squeeze_factor
   __A		:     str												=		hidden_act
   __A		:     Dict												=		num_attention_heads
   __A		:     Tuple												=		hidden_dropout
   __A		:     str												=		attention_dropout
   __A		:     Tuple												=		activation_dropout
   __A		:     Any												=		feat_proj_dropout
   __A		:     Union[str, Any]												=		final_dropout
   __A		:     Any												=		layerdrop
   __A		:     Any												=		layer_norm_eps
   __A		:     Any												=		initializer_range
   __A		:     Union[str, Any]												=		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		:     Tuple												=		apply_spec_augment
   __A		:     List[str]												=		mask_time_prob
   __A		:     List[str]												=		mask_time_length
   __A		:     Tuple												=		mask_time_min_masks
   __A		:     Optional[int]												=		mask_feature_prob
   __A		:     Any												=		mask_feature_length
   __A		:     Any												=		mask_feature_min_masks

   # ctc loss
   __A		:     str												=		ctc_loss_reduction
   __A		:     Tuple												=		ctc_zero_infinity

   # sequence classification
   __A		:     List[str]												=		use_weighted_layer_sum
   __A		:     Union[str, Any]												=		classifier_proj_size






 @property
 def 		lowercase_(   self			:    Optional[Any]       ):



   """simple docstring"""





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





'''simple docstring'''
from packaging import version

from .import_utils import is_accelerate_available


if is_accelerate_available():
     import accelerate







def        A_     (						__SCREAMING_SNAKE_CASE						:  Dict )				->       Optional[int]:





  """simple docstring"""

  if not is_accelerate_available():
    return method
  __A		:     int												=		version.parse(accelerate.__version__ ).base_version
  if version.parse(__SCREAMING_SNAKE_CASE ) < version.parse("""0.17.0""" ):
    return method

  def wrapper(self						:  str			,     *__SCREAMING_SNAKE_CASE						:  Tuple			,     **__SCREAMING_SNAKE_CASE						:  Tuple ):
    if hasattr(self			,     """_hf_hook""" ) and hasattr(self._hf_hook			,     """pre_forward""" ):
      self._hf_hook.pre_forward(self )
    return method(self			,     *__SCREAMING_SNAKE_CASE			,     **__SCREAMING_SNAKE_CASE )

  return wrapper



