





"""simple docstring"""






import functools
import operator

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


A	     =					logging.get_logger(__name__)

A	     =					{
    '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json''',
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}




class 			__lowercase     (     _UpperCamelCase							):







     '''simple docstring'''




     __lowerCAmelCase					=					'''wav2vec2'''







     def __init__(  self		,     _UpperCAmelCase=32		,     _UpperCAmelCase=768		,     _UpperCAmelCase=12		,     _UpperCAmelCase=12		,     _UpperCAmelCase=3072		,     _UpperCAmelCase="gelu"		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase=0.0		,     _UpperCAmelCase=0.0		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase=0.0_2		,     _UpperCAmelCase=1e-5		,     _UpperCAmelCase="group"		,     _UpperCAmelCase="gelu"		,     _UpperCAmelCase=(512, 512, 512, 512, 512, 512, 512)		,     _UpperCAmelCase=(5, 2, 2, 2, 2, 2, 2)		,     _UpperCAmelCase=(10, 3, 3, 3, 3, 2, 2)		,     _UpperCAmelCase=False		,     _UpperCAmelCase=128		,     _UpperCAmelCase=16		,     _UpperCAmelCase=False		,     _UpperCAmelCase=True		,     _UpperCAmelCase=0.0_5		,     _UpperCAmelCase=10		,     _UpperCAmelCase=2		,     _UpperCAmelCase=0.0		,     _UpperCAmelCase=10		,     _UpperCAmelCase=0		,     _UpperCAmelCase=320		,     _UpperCAmelCase=2		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase=100		,     _UpperCAmelCase=256		,     _UpperCAmelCase=256		,     _UpperCAmelCase=0.1		,     _UpperCAmelCase="sum"		,     _UpperCAmelCase=False		,     _UpperCAmelCase=False		,     _UpperCAmelCase=256		,     _UpperCAmelCase=(512, 512, 512, 512, 1500)		,     _UpperCAmelCase=(5, 3, 3, 1, 1)		,     _UpperCAmelCase=(1, 2, 3, 1, 1)		,     _UpperCAmelCase=512		,     _UpperCAmelCase=0		,     _UpperCAmelCase=1		,     _UpperCAmelCase=2		,     _UpperCAmelCase=False		,     _UpperCAmelCase=3		,     _UpperCAmelCase=2		,     _UpperCAmelCase=3		,     _UpperCAmelCase=None		,     _UpperCAmelCase=None		,     **_UpperCAmelCase		,     ):
         super().__init__(**_UpperCAmelCase		,     pad_token_id=_UpperCAmelCase		,     bos_token_id=_UpperCAmelCase		,     eos_token_id=_UpperCAmelCase       )
         __a	:  Tuple         =					hidden_size
         __a	:  Dict         =					feat_extract_norm
         __a	:  Optional[Any]         =					feat_extract_activation
         __a	:  Optional[int]         =					list(_UpperCAmelCase       )
         __a	:  Union[str, Any]         =					list(_UpperCAmelCase       )
         __a	:  List[str]         =					list(_UpperCAmelCase       )
         __a	:  str         =					conv_bias
         __a	:  str         =					num_conv_pos_embeddings
         __a	:  Union[str, Any]         =					num_conv_pos_embedding_groups
         __a	:  Tuple         =					len(self.conv_dim       )
         __a	:  List[str]         =					num_hidden_layers
         __a	:  str         =					intermediate_size
         __a	:  Tuple         =					hidden_act
         __a	:  Optional[Any]         =					num_attention_heads
         __a	:  Optional[Any]         =					hidden_dropout
         __a	:  Dict         =					attention_dropout
         __a	:  int         =					activation_dropout
         __a	:  List[str]         =					feat_proj_dropout
         __a	:  List[str]         =					final_dropout
         __a	:  Optional[Any]         =					layerdrop
         __a	:  Dict         =					layer_norm_eps
         __a	:  Union[str, Any]         =					initializer_range
         __a	:  int         =					vocab_size
         __a	:  List[str]         =					do_stable_layer_norm
         __a	:  int         =					use_weighted_layer_sum

         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)`, but is `len(config.conv_dim) ='''
                 f""" {len(self.conv_dim       )}`, `len(config.conv_stride) = {len(self.conv_stride       )}`,"""
                 f""" `len(config.conv_kernel) = {len(self.conv_kernel       )}`."""       )

         # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
         __a	:  Optional[Any]         =					apply_spec_augment
         __a	:  Any         =					mask_time_prob
         __a	:  Union[str, Any]         =					mask_time_length
         __a	:  Optional[Any]         =					mask_time_min_masks
         __a	:  Tuple         =					mask_feature_prob
         __a	:  List[Any]         =					mask_feature_length
         __a	:  Dict         =					mask_feature_min_masks

         # parameters for pretraining with codevector quantized representations
         __a	:  Any         =					num_codevectors_per_group
         __a	:  Optional[Any]         =					num_codevector_groups
         __a	:  Optional[int]         =					contrastive_logits_temperature
         __a	:  Optional[int]         =					feat_quantizer_dropout
         __a	:  Optional[Any]         =					num_negatives
         __a	:  Union[str, Any]         =					codevector_dim
         __a	:  Any         =					proj_codevector_dim
         __a	:  Optional[Any]         =					diversity_loss_weight

         # ctc loss
         __a	:  Dict         =					ctc_loss_reduction
         __a	:  List[Any]         =					ctc_zero_infinity

         # adapter
         __a	:  Any         =					add_adapter
         __a	:  Optional[int]         =					adapter_kernel_size
         __a	:  Union[str, Any]         =					adapter_stride
         __a	:  str         =					num_adapter_layers
         __a	:  str         =					output_hidden_size or hidden_size
         __a	:  Optional[int]         =					adapter_attn_dim

         # SequenceClassification-specific parameter. Feel free to ignore for other classes.
         __a	:  int         =					classifier_proj_size

         # XVector-specific parameters. Feel free to ignore for other classes.
         __a	:  Union[str, Any]         =					list(_UpperCAmelCase       )
         __a	:  Optional[int]         =					list(_UpperCAmelCase       )
         __a	:  Any         =					list(_UpperCAmelCase       )
         __a	:  int         =					xvector_output_dim







     @property
     def 	_lowerCamelCase						(  self       ):
         return functools.reduce(operator.mul		,     self.conv_stride		,     1       )






"""simple docstring"""






from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

A	     =					TypeVar('''T''')




class 			__lowercase     (     Generic[T]							):







					'''simple docstring'''




					__lowerCAmelCase					=					42  # Cache store of keys
					__lowerCAmelCase					=					42  # References of the keys in cache
					__lowerCAmelCase					=					10  # Maximum capacity of cache







					def __init__(  self		,     _UpperCAmelCase       ):
									__a	:  Optional[int]         =					deque()
									__a	:  Dict         =					set()
									if not n:
													__a	:  List[Any]         =					sys.maxsize
									elif n < 0:
													raise ValueError('''n should be an integer greater than 0.'''       )
									else:
													__a	:  str         =					n







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									if x not in self.key_reference:
													if len(self.dq_store       ) == LRUCache._MAX_CAPACITY:
																	__a	:  int         =					self.dq_store.pop()
																	self.key_reference.remove(_UpperCAmelCase       )
									else:
													self.dq_store.remove(_UpperCAmelCase       )

									self.dq_store.appendleft(_UpperCAmelCase       )
									self.key_reference.add(_UpperCAmelCase       )







					def 	_lowerCamelCase						(  self       ):
									for k in self.dq_store:
													print(_UpperCAmelCase       )







					def __repr__(  self       ):
									return f"""LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store       )}"""


if __name__ == "__main__":
		import doctest

		doctest.testmod()

		A	     =					LRUCache(4)
		lru_cache.refer('''A''')
		lru_cache.refer(2)
		lru_cache.refer(3)
		lru_cache.refer('''A''')
		lru_cache.refer(4)
		lru_cache.refer(5)
		lru_cache.display()

		print(lru_cache)
		assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"