'''simple docstring'''

import functools
import operator

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


_lowerCamelCase :				Optional[int]														= logging.get_logger(__name__)

_lowerCamelCase :				int														= {
    """facebook/hubert-base-ls960""": """https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json""",
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}




class    lowerCamelCase__  (   __snake_case     ):
   __UpperCAmelCase           =						"""hubert"""



   def __init__(    self					,      lowerCAmelCase__=32					,      lowerCAmelCase__=768					,      lowerCAmelCase__=12					,      lowerCAmelCase__=12					,      lowerCAmelCase__=3_072					,      lowerCAmelCase__="gelu"					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=True					,      lowerCAmelCase__=0.0					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=0.02					,      lowerCAmelCase__=1e-5					,      lowerCAmelCase__="group"					,      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__=128					,      lowerCAmelCase__=16					,      lowerCAmelCase__=False					,      lowerCAmelCase__=True					,      lowerCAmelCase__=0.05					,      lowerCAmelCase__=10					,      lowerCAmelCase__=2					,      lowerCAmelCase__=0.0					,      lowerCAmelCase__=10					,      lowerCAmelCase__=0					,      lowerCAmelCase__="sum"					,      lowerCAmelCase__=False					,      lowerCAmelCase__=False					,      lowerCAmelCase__=256					,      lowerCAmelCase__=0					,      lowerCAmelCase__=1					,      lowerCAmelCase__=2					,      **lowerCAmelCase__					,      )				->     Dict:
        """simple docstring"""





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

        # ctc loss
        _UpperCamelCase  :Optional[int]       =ctc_loss_reduction
        _UpperCamelCase  :List[str]       =ctc_zero_infinity




   @property
   def  _UpperCamelCase		(    self     )				->     Optional[Any]:
        """simple docstring"""





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


"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_mpnet import MPNetTokenizer


_SCREAMING_SNAKE_CASE							:	Union[str, Any]										=			logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE							:	Union[str, Any]										=			{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

_SCREAMING_SNAKE_CASE							:	List[Any]										=			{
    """vocab_file""": {
        """microsoft/mpnet-base""": """https://huggingface.co/microsoft/mpnet-base/resolve/main/vocab.txt""",
    },
    """tokenizer_file""": {
        """microsoft/mpnet-base""": """https://huggingface.co/microsoft/mpnet-base/resolve/main/tokenizer.json""",
    },
}

_SCREAMING_SNAKE_CASE							:	List[Any]										=			{
    """microsoft/mpnet-base""": 5_1_2,
}

_SCREAMING_SNAKE_CASE							:	Optional[int]										=			{
    """microsoft/mpnet-base""": {"""do_lower_case""": True},
}

class      __a (   snake_case__     ):

			"""simple docstring"""

			SCREAMING_SNAKE_CASE_      =    VOCAB_FILES_NAMES
			SCREAMING_SNAKE_CASE_      =    PRETRAINED_VOCAB_FILES_MAP
			SCREAMING_SNAKE_CASE_      =    PRETRAINED_INIT_CONFIGURATION
			SCREAMING_SNAKE_CASE_      =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			SCREAMING_SNAKE_CASE_      =    MPNetTokenizer
			SCREAMING_SNAKE_CASE_      =    ['input_ids', 'attention_mask']






			def __init__(				self  :       List[str]    ,	lowercase_  :       List[Any]=None    ,	lowercase_  :       Optional[int]=None    ,	lowercase_  :       Optional[int]=True    ,	lowercase_  :       str="<s>"    ,	lowercase_  :       str="</s>"    ,	lowercase_  :       List[Any]="</s>"    ,	lowercase_  :       Tuple="<s>"    ,	lowercase_  :       Any="[UNK]"    ,	lowercase_  :       Dict="<pad>"    ,	lowercase_  :       Optional[Any]="<mask>"    ,	lowercase_  :       List[str]=True    ,	lowercase_  :       Optional[Any]=None    ,	**lowercase_  :       Dict    ,	):
								super().__init__(
								    lowercase_    ,	tokenizer_file=lowercase_    ,	do_lower_case=lowercase_    ,	bos_token=lowercase_    ,	eos_token=lowercase_    ,	sep_token=lowercase_    ,	cls_token=lowercase_    ,	unk_token=lowercase_    ,	pad_token=lowercase_    ,	mask_token=lowercase_    ,	tokenize_chinese_chars=lowercase_    ,	strip_accents=lowercase_    ,	**lowercase_    ,	)

								UpperCamelCase__		:     List[str]								=json.loads(self.backend_tokenizer.normalizer.__getstate__()    )
								if (
								    pre_tok_state.get('''lowercase'''    ,	lowercase_    ) != do_lower_case
								    or pre_tok_state.get('''strip_accents'''    ,	lowercase_    ) != strip_accents
								):
													UpperCamelCase__		:     int								=getattr(lowercase_    ,	pre_tok_state.pop('''type'''    )    )
													UpperCamelCase__		:     List[Any]								=do_lower_case
													UpperCamelCase__		:     Optional[Any]								=strip_accents
													UpperCamelCase__		:     Optional[int]								=pre_tok_class(**lowercase_    )

								UpperCamelCase__		:     Tuple								=do_lower_case






			@property
			def  _lowerCAmelCase      (				self  :       List[str]    ):
								if self._mask_token is None:
													if self.verbose:
																		logger.error('''Using mask_token, but it is not set yet.'''    )
													return None
								return str(self._mask_token    )






			@mask_token.setter
			def  _lowerCAmelCase      (				self  :       int    ,	lowercase_  :       str    ):
								UpperCamelCase__		:     int								=AddedToken(lowercase_    ,	lstrip=lowercase_    ,	rstrip=lowercase_    ) if isinstance(lowercase_    ,	lowercase_    ) else value
								UpperCamelCase__		:     str								=value






			def  _lowerCAmelCase      (				self  :       Tuple    ,	lowercase_  :       Any    ,	lowercase_  :       Tuple=None    ):
								UpperCamelCase__		:     int								=[self.bos_token_id] + token_ids_a + [self.eos_token_id]
								if token_ids_a is None:
													return output

								return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]






			def  _lowerCAmelCase      (				self  :       List[str]    ,	lowercase_  :       List[int]    ,	lowercase_  :       Optional[List[int]] = None    ):
								UpperCamelCase__		:     str								=[self.sep_token_id]
								UpperCamelCase__		:     List[str]								=[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 + sep + token_ids_a + sep    ) * [0]






			def  _lowerCAmelCase      (				self  :       str    ,	lowercase_  :       str    ,	lowercase_  :       Optional[str] = None    ):
								UpperCamelCase__		:     List[Any]								=self._tokenizer.model.save(lowercase_    ,	name=lowercase_    )
								return tuple(lowercase_    )


