



'''simple docstring'''






import functools
import operator

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


A			      =      logging.get_logger(__name__)

A			      =      {
    '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__):
					_lowerCAmelCase			     =	'''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,    ):

									"""simple docstring"""


									super().__init__(**__UpperCamelCase,    pad_token_id=__UpperCamelCase,    bos_token_id=__UpperCamelCase,    eos_token_id=__UpperCamelCase      )
									lowerCamelCase					:			Tuple									= hidden_size
									lowerCamelCase					:			int									= feat_extract_norm
									lowerCamelCase					:			List[Any]									= feat_extract_activation
									lowerCamelCase					:			Any									= list(__UpperCamelCase      )
									lowerCamelCase					:			Union[str, Any]									= list(__UpperCamelCase      )
									lowerCamelCase					:			Tuple									= list(__UpperCamelCase      )
									lowerCamelCase					:			Dict									= conv_bias
									lowerCamelCase					:			str									= num_conv_pos_embeddings
									lowerCamelCase					:			int									= num_conv_pos_embedding_groups
									lowerCamelCase					:			str									= len(self.conv_dim      )
									lowerCamelCase					:			Optional[Any]									= num_hidden_layers
									lowerCamelCase					:			List[Any]									= intermediate_size
									lowerCamelCase					:			Dict									= hidden_act
									lowerCamelCase					:			str									= num_attention_heads
									lowerCamelCase					:			List[str]									= hidden_dropout
									lowerCamelCase					:			Union[str, Any]									= attention_dropout
									lowerCamelCase					:			Optional[Any]									= activation_dropout
									lowerCamelCase					:			Dict									= feat_proj_dropout
									lowerCamelCase					:			Optional[int]									= final_dropout
									lowerCamelCase					:			List[str]									= layerdrop
									lowerCamelCase					:			Any									= layer_norm_eps
									lowerCamelCase					:			Optional[Any]									= initializer_range
									lowerCamelCase					:			Optional[Any]									= vocab_size
									lowerCamelCase					:			Dict									= do_stable_layer_norm
									lowerCamelCase					:			Tuple									= 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
									lowerCamelCase					:			str									= apply_spec_augment
									lowerCamelCase					:			Dict									= mask_time_prob
									lowerCamelCase					:			Any									= mask_time_length
									lowerCamelCase					:			Dict									= mask_time_min_masks
									lowerCamelCase					:			Optional[Any]									= mask_feature_prob
									lowerCamelCase					:			Union[str, Any]									= mask_feature_length
									lowerCamelCase					:			List[str]									= mask_feature_min_masks

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

									# ctc loss
									lowerCamelCase					:			Optional[int]									= ctc_loss_reduction
									lowerCamelCase					:			int									= ctc_zero_infinity

									# adapter
									lowerCamelCase					:			str									= add_adapter
									lowerCamelCase					:			int									= adapter_kernel_size
									lowerCamelCase					:			Optional[Any]									= adapter_stride
									lowerCamelCase					:			Optional[Any]									= num_adapter_layers
									lowerCamelCase					:			Optional[int]									= output_hidden_size or hidden_size
									lowerCamelCase					:			List[Any]									= adapter_attn_dim

									# SequenceClassification-specific parameter. Feel free to ignore for other classes.
									lowerCamelCase					:			Any									= classifier_proj_size

									# XVector-specific parameters. Feel free to ignore for other classes.
									lowerCamelCase					:			Any									= list(__UpperCamelCase      )
									lowerCamelCase					:			List[Any]									= list(__UpperCamelCase      )
									lowerCamelCase					:			str									= list(__UpperCamelCase      )
									lowerCamelCase					:			Any									= xvector_output_dim




					@property
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									return functools.reduce(operator.mul,    self.conv_stride,    1      )


'''simple docstring'''






import string

# frequency taken from https://en.wikipedia.org/wiki/Letter_frequency
A			      =      {
    'E': 12.70,
    'T': 9.06,
    'A': 8.17,
    'O': 7.51,
    'I': 6.97,
    'N': 6.75,
    'S': 6.33,
    'H': 6.09,
    'R': 5.99,
    'D': 4.25,
    'L': 4.03,
    'C': 2.78,
    'U': 2.76,
    'M': 2.41,
    'W': 2.36,
    'F': 2.23,
    'G': 2.02,
    'Y': 1.97,
    'P': 1.93,
    'B': 1.29,
    'V': 0.98,
    'K': 0.77,
    'J': 0.15,
    'X': 0.15,
    'Q': 0.10,
    'Z': 0.07,
}
A			      =      'ETAOINSHRDLCUMWFGYPBVKJXQZ'
A			      =      'ABCDEFGHIJKLMNOPQRSTUVWXYZ'





def    UpperCAmelCase							(  UpperCAmelCase__							:							str):
				lowerCamelCase					:			Optional[Any]									= {letter: 0 for letter in string.ascii_uppercase}
				for letter in message.upper():
								if letter in LETTERS:
												letter_count[letter] += 1

				return letter_count





def    UpperCAmelCase							(  UpperCAmelCase__							:							tuple):
				return x[0]





def    UpperCAmelCase							(  UpperCAmelCase__							:							str):
				lowerCamelCase					:			Optional[Any]									= get_letter_count(UpperCAmelCase__)
				lowerCamelCase					:			dict[int, list[str]]									= {
				    freq: [] for letter, freq in letter_to_freq.items()
				}
				for letter in LETTERS:
								freq_to_letter[letter_to_freq[letter]].append(UpperCAmelCase__)

				lowerCamelCase					:			dict[int, str]									= {}

				for freq in freq_to_letter:
								freq_to_letter[freq].sort(key=ETAOIN.find       ,							reverse=UpperCAmelCase__)
								lowerCamelCase					:			int									= ''.join(freq_to_letter[freq])

				lowerCamelCase					:			Any									= list(freq_to_letter_str.items())
				freq_pairs.sort(key=UpperCAmelCase__       ,							reverse=UpperCAmelCase__)

				lowerCamelCase					:			list[str]									= [freq_pair[1] for freq_pair in freq_pairs]

				return "".join(UpperCAmelCase__)





def    UpperCAmelCase							(  UpperCAmelCase__							:							str):
				lowerCamelCase					:			Optional[Any]									= get_frequency_order(UpperCAmelCase__)
				lowerCamelCase					:			Optional[Any]									= 0
				for common_letter in ETAOIN[:6]:
								if common_letter in freq_order[:6]:
												match_score += 1

				for uncommon_letter in ETAOIN[-6:]:
								if uncommon_letter in freq_order[-6:]:
												match_score += 1

				return match_score


if __name__ == "__main__":
					import doctest

					doctest.testmod()
