




"""simple docstring"""




import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_electra import ElectraTokenizer


a_        =       {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

a_        =       {
    'vocab_file': {
        'google/electra-small-generator': (
            'https://huggingface.co/google/electra-small-generator/resolve/main/vocab.txt'
        ),
        'google/electra-base-generator': 'https://huggingface.co/google/electra-base-generator/resolve/main/vocab.txt',
        'google/electra-large-generator': (
            'https://huggingface.co/google/electra-large-generator/resolve/main/vocab.txt'
        ),
        'google/electra-small-discriminator': (
            'https://huggingface.co/google/electra-small-discriminator/resolve/main/vocab.txt'
        ),
        'google/electra-base-discriminator': (
            'https://huggingface.co/google/electra-base-discriminator/resolve/main/vocab.txt'
        ),
        'google/electra-large-discriminator': (
            'https://huggingface.co/google/electra-large-discriminator/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'google/electra-small-generator': (
            'https://huggingface.co/google/electra-small-generator/resolve/main/tokenizer.json'
        ),
        'google/electra-base-generator': (
            'https://huggingface.co/google/electra-base-generator/resolve/main/tokenizer.json'
        ),
        'google/electra-large-generator': (
            'https://huggingface.co/google/electra-large-generator/resolve/main/tokenizer.json'
        ),
        'google/electra-small-discriminator': (
            'https://huggingface.co/google/electra-small-discriminator/resolve/main/tokenizer.json'
        ),
        'google/electra-base-discriminator': (
            'https://huggingface.co/google/electra-base-discriminator/resolve/main/tokenizer.json'
        ),
        'google/electra-large-discriminator': (
            'https://huggingface.co/google/electra-large-discriminator/resolve/main/tokenizer.json'
        ),
    },
}

a_        =       {
    'google/electra-small-generator': 5_1_2,
    'google/electra-base-generator': 5_1_2,
    'google/electra-large-generator': 5_1_2,
    'google/electra-small-discriminator': 5_1_2,
    'google/electra-base-discriminator': 5_1_2,
    'google/electra-large-discriminator': 5_1_2,
}

a_        =       {
    'google/electra-small-generator': {'do_lower_case': True},
    'google/electra-base-generator': {'do_lower_case': True},
    'google/electra-large-generator': {'do_lower_case': True},
    'google/electra-small-discriminator': {'do_lower_case': True},
    'google/electra-base-discriminator': {'do_lower_case': True},
    'google/electra-large-discriminator': {'do_lower_case': True},
}

class   UpperCAmelCase_    (			_lowerCAmelCase		):
		UpperCamelCase							=VOCAB_FILES_NAMES
		UpperCamelCase							=PRETRAINED_VOCAB_FILES_MAP
		UpperCamelCase							=PRETRAINED_INIT_CONFIGURATION
		UpperCamelCase							=PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		UpperCamelCase							=ElectraTokenizer
		def __init__(						self				,						UpperCamelCase_=None				,						UpperCamelCase_=None				,						UpperCamelCase_=True				,						UpperCamelCase_="[UNK]"				,						UpperCamelCase_="[SEP]"				,						UpperCamelCase_="[PAD]"				,						UpperCamelCase_="[CLS]"				,						UpperCamelCase_="[MASK]"				,						UpperCamelCase_=True				,						UpperCamelCase_=None				,						**UpperCamelCase_				,						)						->       str:
					super().__init__(
					    SCREAMING_SNAKE_CASE__				,						tokenizer_file=SCREAMING_SNAKE_CASE__				,						do_lower_case=SCREAMING_SNAKE_CASE__				,						unk_token=SCREAMING_SNAKE_CASE__				,						sep_token=SCREAMING_SNAKE_CASE__				,						pad_token=SCREAMING_SNAKE_CASE__				,						cls_token=SCREAMING_SNAKE_CASE__				,						mask_token=SCREAMING_SNAKE_CASE__				,						tokenize_chinese_chars=SCREAMING_SNAKE_CASE__				,						strip_accents=SCREAMING_SNAKE_CASE__				,						**SCREAMING_SNAKE_CASE__				,						)

					__lowercase			:  List[Any]								=       json.loads(self.backend_tokenizer.normalizer.__getstate__()       )
					if (
					    normalizer_state.get('''lowercase'''				,						SCREAMING_SNAKE_CASE__       ) != do_lower_case
					    or normalizer_state.get('''strip_accents'''				,						SCREAMING_SNAKE_CASE__       ) != strip_accents
					    or normalizer_state.get('''handle_chinese_chars'''				,						SCREAMING_SNAKE_CASE__       ) != tokenize_chinese_chars
					):
								__lowercase			:  Dict								=       getattr(SCREAMING_SNAKE_CASE__				,						normalizer_state.pop('''type'''       )       )
								__lowercase			:  Dict								=       do_lower_case
								__lowercase			:  Union[str, Any]								=       strip_accents
								__lowercase			:  List[str]								=       tokenize_chinese_chars
								__lowercase			:  str								=       normalizer_class(**SCREAMING_SNAKE_CASE__       )

					__lowercase			:  Optional[Any]								=       do_lower_case
		def 	_lowerCamelCase							(						self				,						UpperCamelCase_				,						UpperCamelCase_=None       )						->       List[str]:
					__lowercase			:  Tuple								=       [self.cls_token_id] + token_ids_a + [self.sep_token_id]

					if token_ids_a:
								output += token_ids_a + [self.sep_token_id]

					return output
		def 	_lowerCamelCase							(						self				,						UpperCamelCase_				,						UpperCamelCase_ = None       )						->       List[int]:
					__lowercase			:  Dict								=       [self.sep_token_id]
					__lowercase			:  List[Any]								=       [self.cls_token_id]
					if token_ids_a is None:
								return len(cls + token_ids_a + sep       ) * [0]
					return len(cls + token_ids_a + sep       ) * [0] + len(token_ids_a + sep       ) * [1]
		def 	_lowerCamelCase							(						self				,						UpperCamelCase_				,						UpperCamelCase_ = None       )						->       Tuple[str]:
					__lowercase			:  str								=       self._tokenizer.model.save(SCREAMING_SNAKE_CASE__				,						name=SCREAMING_SNAKE_CASE__       )
					return tuple(SCREAMING_SNAKE_CASE__       )








"""simple docstring"""







import math

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


UpperCamelCase     =							logging.get_logger(__name__)

UpperCamelCase     =							{
    """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json""",
    # See all Data2VecAudio models at https://huggingface.co/models?filter=data2vec-audio
}






class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					List[str]							  =     "data2vec-audio"


			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.1						,	SCREAMING_SNAKE_CASE__=0.1						,	SCREAMING_SNAKE_CASE__=0.0_2						,	SCREAMING_SNAKE_CASE__=1e-5						,	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__=16						,	SCREAMING_SNAKE_CASE__=19						,	SCREAMING_SNAKE_CASE__=5						,	SCREAMING_SNAKE_CASE__=0.0_5						,	SCREAMING_SNAKE_CASE__=10						,	SCREAMING_SNAKE_CASE__=2						,	SCREAMING_SNAKE_CASE__=0.0						,	SCREAMING_SNAKE_CASE__=10						,	SCREAMING_SNAKE_CASE__=0						,	SCREAMING_SNAKE_CASE__="sum"						,	SCREAMING_SNAKE_CASE__=False						,	SCREAMING_SNAKE_CASE__=False						,	SCREAMING_SNAKE_CASE__=256						,	SCREAMING_SNAKE_CASE__=(512, 512, 512, 512, 1500)						,	SCREAMING_SNAKE_CASE__=(5, 3, 3, 1, 1)						,	SCREAMING_SNAKE_CASE__=(1, 2, 3, 1, 1)						,	SCREAMING_SNAKE_CASE__=512						,	SCREAMING_SNAKE_CASE__=0						,	SCREAMING_SNAKE_CASE__=1						,	SCREAMING_SNAKE_CASE__=2						,	SCREAMING_SNAKE_CASE__=False						,	SCREAMING_SNAKE_CASE__=3						,	SCREAMING_SNAKE_CASE__=2						,	SCREAMING_SNAKE_CASE__=3						,	SCREAMING_SNAKE_CASE__=None						,	**SCREAMING_SNAKE_CASE__						,	)      ->	Dict:
				super().__init__(**SCREAMING_SNAKE_CASE__						,	pad_token_id=SCREAMING_SNAKE_CASE__						,	bos_token_id=SCREAMING_SNAKE_CASE__						,	eos_token_id=SCREAMING_SNAKE_CASE__		)
				A__											=					hidden_size
				A__											=					feat_extract_activation
				A__											=					list(SCREAMING_SNAKE_CASE__		)
				A__											=					list(SCREAMING_SNAKE_CASE__		)
				A__											=					list(SCREAMING_SNAKE_CASE__		)
				A__											=					conv_bias
				A__											=					num_conv_pos_embeddings
				A__											=					num_conv_pos_embedding_groups
				A__											=					conv_pos_kernel_size
				A__											=					len(self.conv_dim		)
				A__											=					num_hidden_layers
				A__											=					intermediate_size
				A__											=					hidden_act
				A__											=					num_attention_heads
				A__											=					hidden_dropout
				A__											=					attention_dropout
				A__											=					activation_dropout
				A__											=					feat_proj_dropout
				A__											=					final_dropout
				A__											=					layerdrop
				A__											=					layer_norm_eps
				A__											=					initializer_range
				A__											=					vocab_size
				A__											=					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
				A__											=					mask_time_prob
				A__											=					mask_time_length
				A__											=					mask_time_min_masks
				A__											=					mask_feature_prob
				A__											=					mask_feature_length
				A__											=					mask_feature_min_masks

				# ctc loss
				A__											=					ctc_loss_reduction
				A__											=					ctc_zero_infinity

				# adapter
				A__											=					add_adapter
				A__											=					adapter_kernel_size
				A__											=					adapter_stride
				A__											=					num_adapter_layers
				A__											=					output_hidden_size or hidden_size

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

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







			@property
			def   snake_case__	(      self		)      ->	List[str]:
				return math.prod(self.conv_stride		)




