





"""simple docstring"""





import functools
import operator

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


__A											=		logging.get_logger(__name__)

__A											=		{
    """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       ):
       """simple docstring"""




       __magic_name__     :List[Any]		  =					"""sew-d"""






       def __init__(    self    , __UpperCAmelCase=3_2    , __UpperCAmelCase=7_6_8    , __UpperCAmelCase=1_2    , __UpperCAmelCase=1_2    , __UpperCAmelCase=3_0_7_2    , __UpperCAmelCase=2    , __UpperCAmelCase=5_1_2    , __UpperCAmelCase=2_5_6    , __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=(6_4, 1_2_8, 1_2_8, 1_2_8, 1_2_8, 2_5_6, 2_5_6, 2_5_6, 2_5_6, 5_1_2, 5_1_2, 5_1_2, 5_1_2)    , __UpperCAmelCase=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)    , __UpperCAmelCase=(1_0, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)    , __UpperCAmelCase=False    , __UpperCAmelCase=1_2_8    , __UpperCAmelCase=1_6    , __UpperCAmelCase=True    , __UpperCAmelCase=0.05    , __UpperCAmelCase=1_0    , __UpperCAmelCase=2    , __UpperCAmelCase=0.0    , __UpperCAmelCase=1_0    , __UpperCAmelCase=0    , __UpperCAmelCase="mean"    , __UpperCAmelCase=False    , __UpperCAmelCase=False    , __UpperCAmelCase=2_5_6    , __UpperCAmelCase=0    , __UpperCAmelCase=1    , __UpperCAmelCase=2    , **__UpperCAmelCase    , ):



         '''simple docstring'''

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

         # ctc loss
         lowerCAmelCase__			:List[str]											=							ctc_loss_reduction
         lowerCAmelCase__			:Optional[int]											=							ctc_zero_infinity

         # sequence classification
         lowerCAmelCase__			:Union[str, Any]											=							use_weighted_layer_sum
         lowerCAmelCase__			:Tuple											=							classifier_proj_size






       @property
       def      snake_case						(    self      ):



         '''simple docstring'''

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







"""simple docstring"""





from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

__A											=		TypeVar("""KEY""")
__A											=		TypeVar("""VAL""")






@dataclass(frozen=a  ,   slots=a       )
class 					_lowerCAmelCase   (     Generic[KEY, VAL]       ):
       """simple docstring"""




       __magic_name__     :KEY
       __magic_name__     :VAL






class 					_lowerCAmelCase   (     _Item       ):
       """simple docstring"""




       def __init__(    self      ):



         '''simple docstring'''

         super().__init__(__UpperCAmelCase    , __UpperCAmelCase      )






       def __bool__(    self      ):



         '''simple docstring'''

         return False






__A											=		_DeletedItem()






class 					_lowerCAmelCase   (     MutableMapping[KEY, VAL]       ):
       """simple docstring"""




       def __init__(    self    , __UpperCAmelCase = 8    , __UpperCAmelCase = 0.75      ):



         '''simple docstring'''

         lowerCAmelCase__			:List[str]											=							initial_block_size
         lowerCAmelCase__			:list[_Item | None]											=							[None] * initial_block_size
         assert 0.0 < capacity_factor < 1.0
         lowerCAmelCase__			:Tuple											=							capacity_factor
         lowerCAmelCase__			:str											=							0






       def      snake_case						(    self    , __UpperCAmelCase      ):



         '''simple docstring'''

         return hash(__UpperCAmelCase      ) % len(self._buckets      )






       def      snake_case						(    self    , __UpperCAmelCase      ):



         '''simple docstring'''

         return (ind + 1) % len(self._buckets      )






       def      snake_case						(    self    , __UpperCAmelCase    , __UpperCAmelCase    , __UpperCAmelCase      ):



         '''simple docstring'''

         lowerCAmelCase__			:Any											=							self._buckets[ind]
         if not stored:
           lowerCAmelCase__			:Dict											=							_Item(__UpperCAmelCase    , __UpperCAmelCase      )
           self._len += 1
           return True
         elif stored.key == key:
           lowerCAmelCase__			:Optional[Any]											=							_Item(__UpperCAmelCase    , __UpperCAmelCase      )
           return True
         else:
           return False






       def      snake_case						(    self      ):



         '''simple docstring'''

         lowerCAmelCase__			:int											=							len(self._buckets      ) * self._capacity_factor
         return len(self      ) >= int(__UpperCAmelCase      )






       def      snake_case						(    self      ):



         '''simple docstring'''

         if len(self._buckets      ) <= self._initial_block_size:
           return False
         lowerCAmelCase__			:Optional[Any]											=							len(self._buckets      ) * self._capacity_factor / 2
         return len(self      ) < limit






       def      snake_case						(    self    , __UpperCAmelCase      ):



         '''simple docstring'''

         lowerCAmelCase__			:Optional[int]											=							self._buckets
         lowerCAmelCase__			:Tuple											=							[None] * new_size
         lowerCAmelCase__			:List[Any]											=							0
         for item in old_buckets:
           if item:
             self._add_item(item.key    , item.val      )






       def      snake_case						(    self      ):



         '''simple docstring'''

         self._resize(len(self._buckets      ) * 2      )






       def      snake_case						(    self      ):



         '''simple docstring'''

         self._resize(len(self._buckets      ) // 2      )






       def      snake_case						(    self    , __UpperCAmelCase      ):



         '''simple docstring'''

         lowerCAmelCase__			:Optional[Any]											=							self._get_bucket_index(__UpperCAmelCase      )
         for _ in range(len(self._buckets      )      ):
           yield ind
           lowerCAmelCase__			:Tuple											=							self._get_next_ind(__UpperCAmelCase      )






       def      snake_case						(    self    , __UpperCAmelCase    , __UpperCAmelCase      ):



         '''simple docstring'''

         for ind in self._iterate_buckets(__UpperCAmelCase      ):
           if self._try_set(__UpperCAmelCase    , __UpperCAmelCase    , __UpperCAmelCase      ):
             break






       def __setitem__(    self    , __UpperCAmelCase    , __UpperCAmelCase      ):



         '''simple docstring'''

         if self._is_full():
           self._size_up()

         self._add_item(__UpperCAmelCase    , __UpperCAmelCase      )






       def __delitem__(    self    , __UpperCAmelCase      ):



         '''simple docstring'''

         for ind in self._iterate_buckets(__UpperCAmelCase      ):
           lowerCAmelCase__			:int											=							self._buckets[ind]
           if item is None:
             raise KeyError(__UpperCAmelCase      )
           if item is _deleted:
             continue
           if item.key == key:
             lowerCAmelCase__			:List[str]											=							_deleted
             self._len -= 1
             break
         if self._is_sparse():
           self._size_down()






       def __getitem__(    self    , __UpperCAmelCase      ):



         '''simple docstring'''

         for ind in self._iterate_buckets(__UpperCAmelCase      ):
           lowerCAmelCase__			:str											=							self._buckets[ind]
           if item is None:
             break
           if item is _deleted:
             continue
           if item.key == key:
             return item.val
         raise KeyError(__UpperCAmelCase      )






       def __len__(    self      ):



         '''simple docstring'''

         return self._len






       def __iter__(    self      ):



         '''simple docstring'''

         yield from (item.key for item in self._buckets if item)






       def __repr__(    self      ):



         '''simple docstring'''

         lowerCAmelCase__			:Tuple											=							' ,'.join(
             F"{item.key}: {item.val}" for item in self._buckets if item      )
         return F"HashMap({val_string})"
