





"""simple docstring"""



import math

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


a_					=     logging.get_logger(__name__)

a_					=     {
    """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 						__snake_case   (						__lowerCAmelCase	):





 """simple docstring"""


 _lowerCamelCase								=	'''data2vec-audio'''

 def __init__(       self   ,		__lowerCamelCase=32   ,		__lowerCamelCase=768   ,		__lowerCamelCase=12   ,		__lowerCamelCase=12   ,		__lowerCamelCase=3072   ,		__lowerCamelCase="gelu"   ,		__lowerCamelCase=0.1   ,		__lowerCamelCase=0.1   ,		__lowerCamelCase=0.1   ,		__lowerCamelCase=0.0   ,		__lowerCamelCase=0.1   ,		__lowerCamelCase=0.1   ,		__lowerCamelCase=0.0_2   ,		__lowerCamelCase=1e-5   ,		__lowerCamelCase="gelu"   ,		__lowerCamelCase=(512, 512, 512, 512, 512, 512, 512)   ,		__lowerCamelCase=(5, 2, 2, 2, 2, 2, 2)   ,		__lowerCamelCase=(10, 3, 3, 3, 3, 2, 2)   ,		__lowerCamelCase=False   ,		__lowerCamelCase=16   ,		__lowerCamelCase=19   ,		__lowerCamelCase=5   ,		__lowerCamelCase=0.0_5   ,		__lowerCamelCase=10   ,		__lowerCamelCase=2   ,		__lowerCamelCase=0.0   ,		__lowerCamelCase=10   ,		__lowerCamelCase=0   ,		__lowerCamelCase="sum"   ,		__lowerCamelCase=False   ,		__lowerCamelCase=False   ,		__lowerCamelCase=256   ,		__lowerCamelCase=(512, 512, 512, 512, 1500)   ,		__lowerCamelCase=(5, 3, 3, 1, 1)   ,		__lowerCamelCase=(1, 2, 3, 1, 1)   ,		__lowerCamelCase=512   ,		__lowerCamelCase=0   ,		__lowerCamelCase=1   ,		__lowerCamelCase=2   ,		__lowerCamelCase=False   ,		__lowerCamelCase=3   ,		__lowerCamelCase=2   ,		__lowerCamelCase=3   ,		__lowerCamelCase=None   ,		**__lowerCamelCase   ,		):



     '''simple docstring'''




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

     # ctc loss
     __A       :		Any							=	ctc_loss_reduction
     __A       :		str							=	ctc_zero_infinity

     # adapter
     __A       :		Optional[Any]							=	add_adapter
     __A       :		Union[str, Any]							=	adapter_kernel_size
     __A       :		List[str]							=	adapter_stride
     __A       :		Union[str, Any]							=	num_adapter_layers
     __A       :		int							=	output_hidden_size or hidden_size

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

     # XVector-specific parameters. Feel free to ignore for other classes.
     __A       :		Any							=	list(_lowerCamelCase    )
     __A       :		Union[str, Any]							=	list(_lowerCamelCase    )
     __A       :		Optional[Any]							=	list(_lowerCamelCase    )
     __A       :		str							=	xvector_output_dim







 @property
 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     return math.prod(self.conv_stride    )





"""simple docstring"""


import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
	from .tokenization_albert import AlbertTokenizer
else:
	a				=None

a				=logging.get_logger(__name__)
a				={'vocab_file': 'spiece.model', 'tokenizer_file': 'tokenizer.json'}

a				={
    'vocab_file': {
        'albert-base-v1': 'https://huggingface.co/albert-base-v1/resolve/main/spiece.model',
        'albert-large-v1': 'https://huggingface.co/albert-large-v1/resolve/main/spiece.model',
        'albert-xlarge-v1': 'https://huggingface.co/albert-xlarge-v1/resolve/main/spiece.model',
        'albert-xxlarge-v1': 'https://huggingface.co/albert-xxlarge-v1/resolve/main/spiece.model',
        'albert-base-v2': 'https://huggingface.co/albert-base-v2/resolve/main/spiece.model',
        'albert-large-v2': 'https://huggingface.co/albert-large-v2/resolve/main/spiece.model',
        'albert-xlarge-v2': 'https://huggingface.co/albert-xlarge-v2/resolve/main/spiece.model',
        'albert-xxlarge-v2': 'https://huggingface.co/albert-xxlarge-v2/resolve/main/spiece.model',
    },
    'tokenizer_file': {
        'albert-base-v1': 'https://huggingface.co/albert-base-v1/resolve/main/tokenizer.json',
        'albert-large-v1': 'https://huggingface.co/albert-large-v1/resolve/main/tokenizer.json',
        'albert-xlarge-v1': 'https://huggingface.co/albert-xlarge-v1/resolve/main/tokenizer.json',
        'albert-xxlarge-v1': 'https://huggingface.co/albert-xxlarge-v1/resolve/main/tokenizer.json',
        'albert-base-v2': 'https://huggingface.co/albert-base-v2/resolve/main/tokenizer.json',
        'albert-large-v2': 'https://huggingface.co/albert-large-v2/resolve/main/tokenizer.json',
        'albert-xlarge-v2': 'https://huggingface.co/albert-xlarge-v2/resolve/main/tokenizer.json',
        'albert-xxlarge-v2': 'https://huggingface.co/albert-xxlarge-v2/resolve/main/tokenizer.json',
    },
}

a				={
    'albert-base-v1': 512,
    'albert-large-v1': 512,
    'albert-xlarge-v1': 512,
    'albert-xxlarge-v1': 512,
    'albert-base-v2': 512,
    'albert-large-v2': 512,
    'albert-xlarge-v2': 512,
    'albert-xxlarge-v2': 512,
}

a				='▁'






class   __UpperCAmelCase		(      __lowerCAmelCase      ):
				A__ :  Dict    				=			VOCAB_FILES_NAMES
				A__ :  List[Any]    				=			PRETRAINED_VOCAB_FILES_MAP
				A__ :  List[Any]    				=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				A__ :  Union[str, Any]    				=			AlbertTokenizer

				def __init__( self      ,					_lowerCamelCase=None      ,					_lowerCamelCase=None      ,					_lowerCamelCase=True      ,					_lowerCamelCase=True      ,					_lowerCamelCase=False      ,					_lowerCamelCase="[CLS]"      ,					_lowerCamelCase="[SEP]"      ,					_lowerCamelCase="<unk>"      ,					_lowerCamelCase="[SEP]"      ,					_lowerCamelCase="<pad>"      ,					_lowerCamelCase="[CLS]"      ,					_lowerCamelCase="[MASK]"      ,					**_lowerCamelCase      ,					):
										# Mask token behave like a normal word, i.e. include the space before it and
										# is included in the raw text, there should be a match in a non-normalized sentence.
										lowerCamelCase__   =(
										    AddedToken(_lowerCamelCase      ,					lstrip=_lowerCamelCase      ,					rstrip=_lowerCamelCase      ,					normalized=_lowerCamelCase )
										    if isinstance(_lowerCamelCase      ,					_lowerCamelCase )
										    else mask_token
										)

										super().__init__(
										    _lowerCamelCase      ,					tokenizer_file=_lowerCamelCase      ,					do_lower_case=_lowerCamelCase      ,					remove_space=_lowerCamelCase      ,					keep_accents=_lowerCamelCase      ,					bos_token=_lowerCamelCase      ,					eos_token=_lowerCamelCase      ,					unk_token=_lowerCamelCase      ,					sep_token=_lowerCamelCase      ,					pad_token=_lowerCamelCase      ,					cls_token=_lowerCamelCase      ,					mask_token=_lowerCamelCase      ,					**_lowerCamelCase      ,					)

										lowerCamelCase__   =do_lower_case
										lowerCamelCase__   =remove_space
										lowerCamelCase__   =keep_accents
										lowerCamelCase__   =vocab_file
										lowerCamelCase__   =False if not self.vocab_file else True

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase = None ):
										lowerCamelCase__   =[self.sep_token_id]
										lowerCamelCase__   =[self.cls_token_id]
										if token_ids_a is None:
																return cls + token_ids_a + sep
										return cls + token_ids_a + sep + token_ids_a + sep

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase = None ):
										lowerCamelCase__   =[self.sep_token_id]
										lowerCamelCase__   =[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 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase = None ):
										if not self.can_save_slow_tokenizer:
																raise ValueError(
																    "Your fast tokenizer does not have the necessary information to save the vocabulary for a slow "
																    "tokenizer." )

										if not os.path.isdir(_lowerCamelCase ):
																logger.error(F'''Vocabulary path ({save_directory}) should be a directory''' )
																return
										lowerCamelCase__   =os.path.join(
										    _lowerCamelCase      ,					(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"] )

										if os.path.abspath(self.vocab_file ) != os.path.abspath(_lowerCamelCase ):
																copyfile(self.vocab_file      ,					_lowerCamelCase )

										return (out_vocab_file,)


