





'''simple docstring'''




import functools
import operator

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


lowercase__       : str         =       logging.get_logger(__name__)

lowercase__       : Union[str, Any]         =       {
    '''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 					SCREAMING_SNAKE_CASE       (a__				):
     lowerCAmelCase						     =			'''sew-d'''


     def __init__(		self		,      _UpperCAmelCase=32		,      _UpperCAmelCase=768		,      _UpperCAmelCase=12		,      _UpperCAmelCase=12		,      _UpperCAmelCase=3072		,      _UpperCAmelCase=2		,      _UpperCAmelCase=512		,      _UpperCAmelCase=256		,      _UpperCAmelCase=True		,      _UpperCAmelCase=True		,      _UpperCAmelCase=("p2c", "c2p")		,      _UpperCAmelCase="layer_norm"		,      _UpperCAmelCase="gelu_python"		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.0		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.02		,      _UpperCAmelCase=1e-7		,      _UpperCAmelCase=1e-5		,      _UpperCAmelCase="group"		,      _UpperCAmelCase="gelu"		,      _UpperCAmelCase=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)		,      _UpperCAmelCase=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)		,      _UpperCAmelCase=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)		,      _UpperCAmelCase=False		,      _UpperCAmelCase=128		,      _UpperCAmelCase=16		,      _UpperCAmelCase=True		,      _UpperCAmelCase=0.05		,      _UpperCAmelCase=10		,      _UpperCAmelCase=2		,      _UpperCAmelCase=0.0		,      _UpperCAmelCase=10		,      _UpperCAmelCase=0		,      _UpperCAmelCase="mean"		,      _UpperCAmelCase=False		,      _UpperCAmelCase=False		,      _UpperCAmelCase=256		,      _UpperCAmelCase=0		,      _UpperCAmelCase=1		,      _UpperCAmelCase=2		,      **_UpperCAmelCase		,      ):

          '''simple docstring'''






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

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

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


     @property
     def 				SCREAMING_SNAKE_CASE    (		self):

          '''simple docstring'''






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


from __future__ import annotations







def 							_lowerCamelCase   (			SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE = None		,				SCREAMING_SNAKE_CASE = None   ):
      '''simple docstring'''







      if start is None:
            A_							       =		0

      if end is None:
            A_							       =		len(SCREAMING_SNAKE_CASE   ) - 1

      if start >= end:
            return

      A_							       =		(start + end) // 2

      slowsort(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE   )
      slowsort(SCREAMING_SNAKE_CASE		,				mid + 1		,				SCREAMING_SNAKE_CASE   )

      if sequence[end] < sequence[mid]:
            A_       ,A_							       =		sequence[mid], sequence[end]

      slowsort(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				end - 1   )


if __name__ == "__main__":
      from doctest import testmod

      testmod()





