import functools
import operator

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


SCREAMING_SNAKE_CASE :	Optional[Any]							     =		logging.get_logger(__name__)

SCREAMING_SNAKE_CASE :	List[str]							     =		{
    """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    A_ (       __A			):
  _SCREAMING_SNAKE_CASE    				=			"""wav2vec2"""

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

   # parameters for pretraining with codevector quantized representations
   __a       =  num_codevectors_per_group
   __a       =  num_codevector_groups
   __a       =  contrastive_logits_temperature
   __a       =  feat_quantizer_dropout
   __a       =  num_negatives
   __a       =  codevector_dim
   __a       =  proj_codevector_dim
   __a       =  diversity_loss_weight

   # ctc loss
   __a       =  ctc_loss_reduction
   __a       =  ctc_zero_infinity

   # adapter
   __a       =  add_adapter
   __a       =  adapter_kernel_size
   __a       =  adapter_stride
   __a       =  num_adapter_layers
   __a       =  output_hidden_size or hidden_size
   __a       =  adapter_attn_dim

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

   # XVector-specific parameters. Feel free to ignore for other classes.
   __a       =  list(UpperCamelCase__       )
   __a       =  list(UpperCamelCase__       )
   __a       =  list(UpperCamelCase__       )
   __a       =  xvector_output_dim

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



import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
  import ctypes
  import msvcrt  # noqa
  class    A_ (       ctypes.Structure ):
    # _fields is a specific attr expected by ctypes
    _SCREAMING_SNAKE_CASE    				=			[("""size""", ctypes.c_int), ("""visible""", ctypes.c_byte)]



def   __A		(			):



 """simple docstring"""


 if os.name == "nt":
  __a       =  CursorInfo()
  __a       =  ctypes.windll.kernelaa.GetStdHandle(-11					)
  ctypes.windll.kernelaa.GetConsoleCursorInfo(_A							,				ctypes.byref(_A					)					)
  __a       =  False
  ctypes.windll.kernelaa.SetConsoleCursorInfo(_A							,				ctypes.byref(_A					)					)
 elif os.name == "posix":
  sys.stdout.write("\033[?25l"					)
  sys.stdout.flush()



def   __A		(			):



 """simple docstring"""


 if os.name == "nt":
  __a       =  CursorInfo()
  __a       =  ctypes.windll.kernelaa.GetStdHandle(-11					)
  ctypes.windll.kernelaa.GetConsoleCursorInfo(_A							,				ctypes.byref(_A					)					)
  __a       =  True
  ctypes.windll.kernelaa.SetConsoleCursorInfo(_A							,				ctypes.byref(_A					)					)
 elif os.name == "posix":
  sys.stdout.write("\033[?25h"					)
  sys.stdout.flush()






@contextmanager
def   __A		(			):



 """simple docstring"""


 try:
  hide_cursor()
  yield
 finally:
  show_cursor()


