



import functools
import operator

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


_lowerCamelCase						    =  logging.get_logger(__name__)

_lowerCamelCase						    =  {
    """microsoft/unispeech-sat-base-100h-libri-ft""": (
        """https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json"""
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}

class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
     lowerCAmelCase					=			"""unispeech-sat"""





     def __init__(       self :							Any     ,  UpperCamelCase :							int=3_2     ,  UpperCamelCase :							List[Any]=7_6_8     ,  UpperCamelCase :							str=1_2     ,  UpperCamelCase :							Dict=1_2     ,  UpperCamelCase :							str=3_0_7_2     ,  UpperCamelCase :							int="gelu"     ,  UpperCamelCase :							Dict=0.1     ,  UpperCamelCase :							Tuple=0.1     ,  UpperCamelCase :							Union[str, Any]=0.1     ,  UpperCamelCase :							List[str]=0.0     ,  UpperCamelCase :							List[str]=0.0     ,  UpperCamelCase :							str=0.1     ,  UpperCamelCase :							str=0.1     ,  UpperCamelCase :							int=0.0_2     ,  UpperCamelCase :							List[Any]=1E-5     ,  UpperCamelCase :							Optional[int]="group"     ,  UpperCamelCase :							int="gelu"     ,  UpperCamelCase :							str=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)     ,  UpperCamelCase :							int=(5, 2, 2, 2, 2, 2, 2)     ,  UpperCamelCase :							Optional[Any]=(1_0, 3, 3, 3, 3, 2, 2)     ,  UpperCamelCase :							Optional[int]=False     ,  UpperCamelCase :							int=1_2_8     ,  UpperCamelCase :							Dict=1_6     ,  UpperCamelCase :							Tuple=False     ,  UpperCamelCase :							Optional[Any]=True     ,  UpperCamelCase :							List[Any]=0.0_5     ,  UpperCamelCase :							int=1_0     ,  UpperCamelCase :							Optional[Any]=2     ,  UpperCamelCase :							List[Any]=0.0     ,  UpperCamelCase :							Optional[int]=1_0     ,  UpperCamelCase :							Union[str, Any]=0     ,  UpperCamelCase :							Union[str, Any]=3_2_0     ,  UpperCamelCase :							str=2     ,  UpperCamelCase :							List[str]=0.1     ,  UpperCamelCase :							List[str]=1_0_0     ,  UpperCamelCase :							List[str]=2_5_6     ,  UpperCamelCase :							Optional[int]=2_5_6     ,  UpperCamelCase :							str=0.1     ,  UpperCamelCase :							Union[str, Any]="mean"     ,  UpperCamelCase :							Dict=False     ,  UpperCamelCase :							Optional[Any]=False     ,  UpperCamelCase :							int=2_5_6     ,  UpperCamelCase :							Tuple=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)     ,  UpperCamelCase :							Dict=(5, 3, 3, 1, 1)     ,  UpperCamelCase :							Union[str, Any]=(1, 2, 3, 1, 1)     ,  UpperCamelCase :							List[Any]=5_1_2     ,  UpperCamelCase :							str=0     ,  UpperCamelCase :							Any=1     ,  UpperCamelCase :							List[Any]=2     ,  UpperCamelCase :							Tuple=5_0_4     ,  **UpperCamelCase :							Dict     ,  )->Dict:
      super().__init__(**UpperCamelCase     ,  pad_token_id=UpperCamelCase     ,  bos_token_id=UpperCamelCase     ,  eos_token_id=UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Tuple       =	hidden_size
      __SCREAMING_SNAKE_CASE       :    Any       =	feat_extract_norm
      __SCREAMING_SNAKE_CASE       :    str       =	feat_extract_activation
      __SCREAMING_SNAKE_CASE       :    Tuple       =	list(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    int       =	list(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	list(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	conv_bias
      __SCREAMING_SNAKE_CASE       :    Dict       =	num_conv_pos_embeddings
      __SCREAMING_SNAKE_CASE       :    Any       =	num_conv_pos_embedding_groups
      __SCREAMING_SNAKE_CASE       :    Tuple       =	len(self.conv_dim				)
      __SCREAMING_SNAKE_CASE       :    Tuple       =	num_hidden_layers
      __SCREAMING_SNAKE_CASE       :    Tuple       =	intermediate_size
      __SCREAMING_SNAKE_CASE       :    List[str]       =	hidden_act
      __SCREAMING_SNAKE_CASE       :    Dict       =	num_attention_heads
      __SCREAMING_SNAKE_CASE       :    Any       =	hidden_dropout
      __SCREAMING_SNAKE_CASE       :    Dict       =	attention_dropout
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	activation_dropout
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	feat_proj_dropout
      __SCREAMING_SNAKE_CASE       :    Any       =	final_dropout
      __SCREAMING_SNAKE_CASE       :    Any       =	layerdrop
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	layer_norm_eps
      __SCREAMING_SNAKE_CASE       :    Dict       =	initializer_range
      __SCREAMING_SNAKE_CASE       :    str       =	vocab_size
      __SCREAMING_SNAKE_CASE       :    List[str]       =	num_clusters
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	do_stable_layer_norm
      __SCREAMING_SNAKE_CASE       :    Optional[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
      __SCREAMING_SNAKE_CASE       :    Tuple       =	apply_spec_augment
      __SCREAMING_SNAKE_CASE       :    str       =	mask_time_prob
      __SCREAMING_SNAKE_CASE       :    List[str]       =	mask_time_length
      __SCREAMING_SNAKE_CASE       :    str       =	mask_time_min_masks
      __SCREAMING_SNAKE_CASE       :    Dict       =	mask_feature_prob
      __SCREAMING_SNAKE_CASE       :    str       =	mask_feature_length
      __SCREAMING_SNAKE_CASE       :    int       =	mask_feature_min_masks

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

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

      # SequenceClassification-specific parameter. Feel free to ignore for other classes.
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	classifier_proj_size

      # XVector-specific parameters. Feel free to ignore for other classes.
      __SCREAMING_SNAKE_CASE       :    str       =	list(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    str       =	list(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	list(UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Tuple       =	xvector_output_dim






     @property
     def 	__snake_case    (       self :							Optional[int]				)->Tuple:
      return functools.reduce(operator.mul     ,  self.conv_stride     ,  1				)










import importlib
import shutil
import threading
import warnings
from typing import List

import fsspec
import fsspec.asyn

from . import compression
from .hffilesystem import HfFileSystem


_lowerCamelCase						    =  importlib.util.find_spec("""s3fs""") is not None

if _has_safs:
      from .safilesystem import SaFileSystem  # noqa: F401

_lowerCamelCase						    =  [
    compression.BzaFileSystem,
    compression.GzipFileSystem,
    compression.LzaFileSystem,
    compression.XzFileSystem,
    compression.ZstdFileSystem,
]

# Register custom filesystems
for fs_class in COMPRESSION_FILESYSTEMS + [HfFileSystem]:
      if fs_class.protocol in fsspec.registry and fsspec.registry[fs_class.protocol] is not fs_class:
            warnings.warn(f'''A filesystem protocol was already set for {fs_class.protocol} and will be overwritten.''')
      fsspec.register_implementation(fs_class.protocol, fs_class, clobber=True)






def 	_lowerCAmelCase						(				__lowerCamelCase   :     str     ):



 """simple docstring"""





 if "://" in dataset_path:
  __SCREAMING_SNAKE_CASE       :    Any       =	dataset_path.split("://"     )[1]
 return dataset_path






def 	_lowerCAmelCase						(				__lowerCamelCase   :     fsspec.AbstractFileSystem     ):



 """simple docstring"""





 if fs is not None and fs.protocol != "file":
  return True
 else:
  return False






def 	_lowerCAmelCase						(				__lowerCamelCase   :     fsspec.AbstractFileSystem		,	__lowerCamelCase   :     str		,	__lowerCamelCase   :     str     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    Optional[int]       =	not is_remote_filesystem(__lowerCamelCase     )
 if is_local:
  # LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
  shutil.move(fs._strip_protocol(__lowerCamelCase     )		,	fs._strip_protocol(__lowerCamelCase     )     )
 else:
  fs.mv(__lowerCamelCase		,	__lowerCamelCase		,	recursive=__lowerCamelCase     )






def 	_lowerCAmelCase						(				):



 """simple docstring"""





 if hasattr(fsspec.asyn		,	"reset_lock"     ):
  # for future fsspec>2022.05.0
  fsspec.asyn.reset_lock()
 else:
  __SCREAMING_SNAKE_CASE       :    Tuple       =	None
  __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	None
  __SCREAMING_SNAKE_CASE       :    Dict       =	threading.Lock()






