






import functools
import operator

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


a_		:    Tuple   							=     logging.get_logger(__name__)

a_		:    Optional[int]   							=     {
    '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 		_snake_case	(	A__       ):
			_lowercase		:     Union[str, Any]        =				'''wav2vec2'''






			def __init__(							self		,       a=32		,       a=768		,       a=12		,       a=12		,       a=3072		,       a="gelu"		,       a=0.1		,       a=0.1		,       a=0.1		,       a=0.0		,       a=0.0		,       a=0.1		,       a=0.1		,       a=0.02		,       a=1E-5		,       a="group"		,       a="gelu"		,       a=(512, 512, 512, 512, 512, 512, 512)		,       a=(5, 2, 2, 2, 2, 2, 2)		,       a=(10, 3, 3, 3, 3, 2, 2)		,       a=False		,       a=128		,       a=16		,       a=False		,       a=True		,       a=0.05		,       a=10		,       a=2		,       a=0.0		,       a=10		,       a=0		,       a=320		,       a=2		,       a=0.1		,       a=100		,       a=256		,       a=256		,       a=0.1		,       a="sum"		,       a=False		,       a=False		,       a=256		,       a=(512, 512, 512, 512, 1500)		,       a=(5, 3, 3, 1, 1)		,       a=(1, 2, 3, 1, 1)		,       a=512		,       a=0		,       a=1		,       a=2		,       a=False		,       a=3		,       a=2		,       a=3		,       a=None		,       a=None		,       **a		,       )   ->							Tuple:
						super().__init__(**a		,       pad_token_id=a		,       bos_token_id=a		,       eos_token_id=a)
						SCREAMING_SNAKE_CASE							=			hidden_size
						SCREAMING_SNAKE_CASE							=			feat_extract_norm
						SCREAMING_SNAKE_CASE							=			feat_extract_activation
						SCREAMING_SNAKE_CASE							=			list(a)
						SCREAMING_SNAKE_CASE							=			list(a)
						SCREAMING_SNAKE_CASE							=			list(a)
						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							=			vocab_size
						SCREAMING_SNAKE_CASE							=			do_stable_layer_norm
						SCREAMING_SNAKE_CASE							=			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							=			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

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

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

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







			@property
			def  SCREAMING_SNAKE_CASE__     (							self)   ->							Union[str, Any]:
						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


UpperCamelCase__		 =     get_logger(__name__)

class     __snake_case    (				enum.Enum  ):
       """simple docstring"""







       __SCREAMING_SNAKE_CASE				    =							"all_checks"
       __SCREAMING_SNAKE_CASE				    =							"basic_checks"
       __SCREAMING_SNAKE_CASE				    =							"no_checks"






class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""














def 						lowerCamelCase__      ( __A    :Optional[dict]	,__A    :dict	,__A    :Any=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		)		)		)
       __snake_case       	=							[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
       __snake_case       	=							""" 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     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""














def 						lowerCamelCase__      ( __A    :Optional[dict]	,__A    :dict		):


       """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		)		)		)
       __snake_case       	=							[
           {"""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 						lowerCamelCase__      ( __A    :str	,__A    :bool = True		):


       """simple docstring"""




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







def 						lowerCamelCase__      ( __A    :Optional[int]		):


       """simple docstring"""




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

