



'''simple docstring'''






import functools
import operator

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


lowerCAmelCase:   Tuple					=		logging.get_logger(__name__)

lowerCAmelCase:   List[str]					=		{
    '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__(   lowerCamelCase__      ):
    lowercase__					=       """sew"""







    def __init__( self					:    int		,     __snake_case					:    Optional[Any]=32		,     __snake_case					:    List[Any]=7_68		,     __snake_case					:    int=12		,     __snake_case					:    Union[str, Any]=12		,     __snake_case					:    str=30_72		,     __snake_case					:    List[Any]=2		,     __snake_case					:    Any="gelu"		,     __snake_case					:    List[str]=0.1		,     __snake_case					:    List[str]=0.1		,     __snake_case					:    str=0.1		,     __snake_case					:    Union[str, Any]=0.0		,     __snake_case					:    Optional[int]=0.1		,     __snake_case					:    Optional[int]=0.1		,     __snake_case					:    int=0.02		,     __snake_case					:    Optional[int]=1e-5		,     __snake_case					:    Tuple="group"		,     __snake_case					:    Dict="gelu"		,     __snake_case					:    List[str]=(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)		,     __snake_case					:    Any=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)		,     __snake_case					:    Any=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)		,     __snake_case					:    List[str]=False		,     __snake_case					:    int=1_28		,     __snake_case					:    Tuple=16		,     __snake_case					:    Optional[int]=True		,     __snake_case					:    List[str]=0.05		,     __snake_case					:    List[Any]=10		,     __snake_case					:    List[str]=2		,     __snake_case					:    List[str]=0.0		,     __snake_case					:    List[Any]=10		,     __snake_case					:    int=0		,     __snake_case					:    int="mean"		,     __snake_case					:    int=False		,     __snake_case					:    Any=False		,     __snake_case					:    int=2_56		,     __snake_case					:    List[Any]=0		,     __snake_case					:    List[Any]=1		,     __snake_case					:    Any=2		,     **__snake_case					:    Dict		,     ):
      super().__init__(**__snake_case		,     pad_token_id=__snake_case		,     bos_token_id=__snake_case		,     eos_token_id=__snake_case      )
      a		:   Any	  =	hidden_size
      a		:   Optional[Any]	  =	feat_extract_norm
      a		:   int	  =	feat_extract_activation
      a		:   List[str]	  =	list(__snake_case      )
      a		:   Dict	  =	list(__snake_case      )
      a		:   str	  =	list(__snake_case      )
      a		:   Tuple	  =	conv_bias
      a		:   int	  =	num_conv_pos_embeddings
      a		:   int	  =	num_conv_pos_embedding_groups
      a		:   str	  =	len(self.conv_dim      )
      a		:   Tuple	  =	num_hidden_layers
      a		:   Tuple	  =	intermediate_size
      a		:   Dict	  =	squeeze_factor
      a		:   Optional[int]	  =	hidden_act
      a		:   Optional[Any]	  =	num_attention_heads
      a		:   List[Any]	  =	hidden_dropout
      a		:   Union[str, Any]	  =	attention_dropout
      a		:   str	  =	activation_dropout
      a		:   Dict	  =	feat_proj_dropout
      a		:   str	  =	final_dropout
      a		:   List[str]	  =	layerdrop
      a		:   List[str]	  =	layer_norm_eps
      a		:   List[Any]	  =	initializer_range
      a		:   Optional[int]	  =	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		:   List[Any]	  =	apply_spec_augment
      a		:   int	  =	mask_time_prob
      a		:   str	  =	mask_time_length
      a		:   str	  =	mask_time_min_masks
      a		:   Union[str, Any]	  =	mask_feature_prob
      a		:   int	  =	mask_feature_length
      a		:   Any	  =	mask_feature_min_masks

      # ctc loss
      a		:   Union[str, Any]	  =	ctc_loss_reduction
      a		:   List[Any]	  =	ctc_zero_infinity

      # sequence classification
      a		:   Dict	  =	use_weighted_layer_sum
      a		:   Optional[Any]	  =	classifier_proj_size







    @property
    def      lowercase_			( self					:    Union[str, Any]      ):
      return functools.reduce(operator.mul		,     self.conv_stride		,     1      )




'''simple docstring'''






from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream

class 				a__(   lowerCamelCase__      ):







    def __init__( self					:    int		,     __snake_case					:    Callable		,     __snake_case					:    Optional[Features] = None		,     __snake_case					:    str = None		,     __snake_case					:    bool = False		,     __snake_case					:    bool = False		,     __snake_case					:    Optional[dict] = None		,     __snake_case					:    Optional[int] = None		,     **__snake_case					:    Optional[int]		,     ):
      super().__init__(
          features=__snake_case		,     cache_dir=__snake_case		,     keep_in_memory=__snake_case		,     streaming=__snake_case		,     num_proc=__snake_case		,     **__snake_case		,     )
      a		:   List[Any]	  =	Generator(
          cache_dir=__snake_case		,     features=__snake_case		,     generator=__snake_case		,     gen_kwargs=__snake_case		,     **__snake_case		,     )







    def      lowercase_			( self					:    Any      ):
      # Build iterable dataset
      if self.streaming:
        a		:   Optional[int]	  =	self.builder.as_streaming_dataset(split='train'      )
      # Build regular (map-style) dataset
      else:
        a		:   List[Any]	  =	None
        a		:   Any	  =	None
        a		:   Optional[int]	  =	None
        a		:   List[str]	  =	None

        self.builder.download_and_prepare(
            download_config=__snake_case		,     download_mode=__snake_case		,     verification_mode=__snake_case		,     base_path=__snake_case		,     num_proc=self.num_proc		,     )
        a		:   Dict	  =	self.builder.as_dataset(
            split='train'		,     verification_mode=__snake_case		,     in_memory=self.keep_in_memory      )
      return dataset