

"""simple docstring"""




import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text

def 	A       (     snake_case__    ):




			'''simple docstring'''


			SCREAMING_SNAKE_CASE__								=      []
			for line in lines:
						SCREAMING_SNAKE_CASE__								=      re.sub(R"""#.*"""		,				""""""		,				snake_case__    )  # remove comments
						if line:
									filtered_lines.append(snake_case__    )
			SCREAMING_SNAKE_CASE__								=      """\n""".join(snake_case__    )

			# Make a hash from all this code
			SCREAMING_SNAKE_CASE__								=      full_str.encode("""utf-8"""    )
			return shaaaa(snake_case__    ).hexdigest()


# get importable module names and hash for caching
A_							:			Optional[int]											= {
    "csv": (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    "json": (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    "pandas": (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    "parquet": (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    "arrow": (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    "text": (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    "imagefolder": (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    "audiofolder": (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
A_							:			Tuple											= {
    ".csv": ("csv", {}),
    ".tsv": ("csv", {"sep": "\t"}),
    ".json": ("json", {}),
    ".jsonl": ("json", {}),
    ".parquet": ("parquet", {}),
    ".arrow": ("arrow", {}),
    ".txt": ("text", {}),
}
_EXTENSION_TO_MODULE.update({ext: ("imagefolder", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("imagefolder", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ("audiofolder", {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("audiofolder", {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
A_							:			str											= {"imagefolder", "audiofolder"}

# Used to filter data files based on extensions given a module name
A_							:			Dict[str, List[str]]											= {}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
						_MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append(".zip")




_MODULE_TO_EXTENSIONS["audiofolder"].append(".zip")





"""simple docstring"""




import functools
import operator

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


A_							:			List[Any]											= logging.get_logger(__name__)

A_							:			Dict											= {
    "microsoft/unispeech-large-1500h-cv": (
        "https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json"
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}





class    lowerCamelCase						(A__			):
			lowerCamelCase__   :		int							=							'unispeech'

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

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

						# ctc loss
						SCREAMING_SNAKE_CASE__								=      ctc_loss_reduction
						SCREAMING_SNAKE_CASE__								=      ctc_zero_infinity

						# pretraining loss
						SCREAMING_SNAKE_CASE__								=      replace_prob





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


