



import functools
import operator

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


__UpperCAmelCase			  =			logging.get_logger(__name__)

__UpperCAmelCase			  =			{
    '''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__				):
       UpperCAmelCase__							:   List[str]  	=    "unispeech"
       def __init__(     self,     SCREAMING_SNAKE_CASE_=32,     SCREAMING_SNAKE_CASE_=768,     SCREAMING_SNAKE_CASE_=12,     SCREAMING_SNAKE_CASE_=12,     SCREAMING_SNAKE_CASE_=3072,     SCREAMING_SNAKE_CASE_="gelu",     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_=0.0,     SCREAMING_SNAKE_CASE_=0.0,     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_=0.02,     SCREAMING_SNAKE_CASE_=1e-5,     SCREAMING_SNAKE_CASE_="group",     SCREAMING_SNAKE_CASE_="gelu",     SCREAMING_SNAKE_CASE_=(512, 512, 512, 512, 512, 512, 512),     SCREAMING_SNAKE_CASE_=(5, 2, 2, 2, 2, 2, 2),     SCREAMING_SNAKE_CASE_=(10, 3, 3, 3, 3, 2, 2),     SCREAMING_SNAKE_CASE_=False,     SCREAMING_SNAKE_CASE_=128,     SCREAMING_SNAKE_CASE_=16,     SCREAMING_SNAKE_CASE_=False,     SCREAMING_SNAKE_CASE_=True,     SCREAMING_SNAKE_CASE_=0.05,     SCREAMING_SNAKE_CASE_=10,     SCREAMING_SNAKE_CASE_=2,     SCREAMING_SNAKE_CASE_=0.0,     SCREAMING_SNAKE_CASE_=10,     SCREAMING_SNAKE_CASE_=0,     SCREAMING_SNAKE_CASE_=320,     SCREAMING_SNAKE_CASE_=2,     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_=100,     SCREAMING_SNAKE_CASE_=256,     SCREAMING_SNAKE_CASE_=256,     SCREAMING_SNAKE_CASE_=0.1,     SCREAMING_SNAKE_CASE_="mean",     SCREAMING_SNAKE_CASE_=False,     SCREAMING_SNAKE_CASE_=False,     SCREAMING_SNAKE_CASE_=256,     SCREAMING_SNAKE_CASE_=80,     SCREAMING_SNAKE_CASE_=0,     SCREAMING_SNAKE_CASE_=1,     SCREAMING_SNAKE_CASE_=2,     SCREAMING_SNAKE_CASE_=0.5,     **SCREAMING_SNAKE_CASE_,     )	->						List[str]:
          super().__init__(**SCREAMING_SNAKE_CASE_,     pad_token_id=SCREAMING_SNAKE_CASE_,     bos_token_id=SCREAMING_SNAKE_CASE_,     eos_token_id=SCREAMING_SNAKE_CASE_			)
          UpperCamelCase       :    int		      =      hidden_size
          UpperCamelCase       :    Dict		      =      feat_extract_norm
          UpperCamelCase       :    Any		      =      feat_extract_activation
          UpperCamelCase       :    str		      =      list(SCREAMING_SNAKE_CASE_			)
          UpperCamelCase       :    Any		      =      list(SCREAMING_SNAKE_CASE_			)
          UpperCamelCase       :    int		      =      list(SCREAMING_SNAKE_CASE_			)
          UpperCamelCase       :    Tuple		      =      conv_bias
          UpperCamelCase       :    Union[str, Any]		      =      num_conv_pos_embeddings
          UpperCamelCase       :    Union[str, Any]		      =      num_conv_pos_embedding_groups
          UpperCamelCase       :    int		      =      len(self.conv_dim			)
          UpperCamelCase       :    str		      =      num_hidden_layers
          UpperCamelCase       :    List[Any]		      =      intermediate_size
          UpperCamelCase       :    List[str]		      =      hidden_act
          UpperCamelCase       :    str		      =      num_attention_heads
          UpperCamelCase       :    Dict		      =      hidden_dropout
          UpperCamelCase       :    Any		      =      attention_dropout
          UpperCamelCase       :    List[Any]		      =      activation_dropout
          UpperCamelCase       :    Any		      =      feat_proj_dropout
          UpperCamelCase       :    Tuple		      =      final_dropout
          UpperCamelCase       :    Optional[Any]		      =      layerdrop
          UpperCamelCase       :    Tuple		      =      layer_norm_eps
          UpperCamelCase       :    Tuple		      =      initializer_range
          UpperCamelCase       :    Optional[Any]		      =      num_ctc_classes
          UpperCamelCase       :    Any		      =      vocab_size
          UpperCamelCase       :    int		      =      do_stable_layer_norm
          UpperCamelCase       :    int		      =      use_weighted_layer_sum
          UpperCamelCase       :    Tuple		      =      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
          UpperCamelCase       :    str		      =      apply_spec_augment
          UpperCamelCase       :    Optional[int]		      =      mask_time_prob
          UpperCamelCase       :    Any		      =      mask_time_length
          UpperCamelCase       :    Optional[Any]		      =      mask_time_min_masks
          UpperCamelCase       :    int		      =      mask_feature_prob
          UpperCamelCase       :    Union[str, Any]		      =      mask_feature_length
          UpperCamelCase       :    Optional[Any]		      =      mask_feature_min_masks

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

          # ctc loss
          UpperCamelCase       :    int		      =      ctc_loss_reduction
          UpperCamelCase       :    str		      =      ctc_zero_infinity

          # pretraining loss
          UpperCamelCase       :    Dict		      =      replace_prob






       @property
       def    snake_case_			(     self			)	->						List[str]:
          return functools.reduce(operator.mul,     self.conv_stride,     1			)




import enum
import os
from hashlib import shaaaa
from typing import Optional

from .. import config
from .logging import get_logger


SCREAMING_SNAKE_CASE			:						List[Any]				  =		get_logger(__name__)
class  A_			(							enum.Enum			):
  _SCREAMING_SNAKE_CASE     					=      """all_checks"""
  _SCREAMING_SNAKE_CASE     					=      """basic_checks"""
  _SCREAMING_SNAKE_CASE     					=      """no_checks"""
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass



def 	__A		(      _A				,					_A				,					_A=None       ):



 """simple docstring"""


 if expected_checksums is None:
  logger.info("Unable to verify checksums."       )
  return
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise ExpectedMoreDownloadedFiles(str(set(_A       ) - set(_A       )       )       )
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise UnexpectedDownloadedFile(str(set(_A       ) - set(_A       )       )       )
 __a							=	[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
 __a							=	" for " + verification_name if verification_name is not None else ""
 if len(_A       ) > 0:
  raise NonMatchingChecksumError(
      f"""Checksums didn't match{for_verification_name}:\n"""
      f"""{bad_urls}\n"""
      "Set `verification_mode='no_checks'` to skip checksums verification and ignore this error"       )
 logger.info("All the checksums matched successfully" + for_verification_name       )
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass



def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 if expected_splits is None:
  logger.info("Unable to verify splits sizes."       )
  return
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise ExpectedMoreSplits(str(set(_A       ) - set(_A       )       )       )
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise UnexpectedSplits(str(set(_A       ) - set(_A       )       )       )
 __a							=	[
     {"expected": expected_splits[name], "recorded": recorded_splits[name]}
     for name in expected_splits
     if expected_splits[name].num_examples != recorded_splits[name].num_examples
 ]
 if len(_A       ) > 0:
  raise NonMatchingSplitsSizesError(str(_A       )       )
 logger.info("All the splits matched successfully."       )



def 	__A		(      _A				,					_A = True       ):



 """simple docstring"""


 if record_checksum:
  __a							=	shaaaa()
  with open(_A				,					"rb"       ) as f:
   for chunk in iter(lambda: f.read(1 << 20       )				,					B""       ):
    m.update(_A       )
   __a							=	m.hexdigest()
 else:
  __a							=	None
 return {"num_bytes": os.path.getsize(_A       ), "checksum": checksum}






def 	__A		(      _A       ):



 """simple docstring"""


 if dataset_size and config.IN_MEMORY_MAX_SIZE:
  return dataset_size < config.IN_MEMORY_MAX_SIZE
 else:
  return False


