





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_mobilebert import MobileBertTokenizer


A       :   Tuple					= logging.get_logger(__name__)

A       :   List[str]					= {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

A       :   List[Any]					= {
    '''vocab_file''': {'''mobilebert-uncased''': '''https://huggingface.co/google/mobilebert-uncased/resolve/main/vocab.txt'''},
    '''tokenizer_file''': {
        '''mobilebert-uncased''': '''https://huggingface.co/google/mobilebert-uncased/resolve/main/tokenizer.json'''
    },
}

A       :   str					= {'''mobilebert-uncased''': 5_1_2}


A       :   str					= {}


class     A     (SCREAMING_SNAKE_CASE       ):
			'''simple docstring'''




			__lowerCamelCase      :			Dict							     =       VOCAB_FILES_NAMES
			__lowerCamelCase      :			List[Any]							     =       PRETRAINED_VOCAB_FILES_MAP
			__lowerCamelCase      :			Optional[Any]							     =       PRETRAINED_INIT_CONFIGURATION
			__lowerCamelCase      :			Union[str, Any]							     =       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			__lowerCamelCase      :			Optional[int]							     =       MobileBertTokenizer






			def __init__(     self  :       Dict				,      __lowerCAmelCase  :       Optional[int]=None				,      __lowerCAmelCase  :       Union[str, Any]=None				,      __lowerCAmelCase  :       Dict=True				,      __lowerCAmelCase  :       List[str]="[UNK]"				,      __lowerCAmelCase  :       str="[SEP]"				,      __lowerCAmelCase  :       Tuple="[PAD]"				,      __lowerCAmelCase  :       Optional[int]="[CLS]"				,      __lowerCAmelCase  :       List[Any]="[MASK]"				,      __lowerCAmelCase  :       Tuple=True				,      __lowerCAmelCase  :       Any=None				,      **__lowerCAmelCase  :       List[Any]				,      )      ->      Tuple:







					"""simple docstring"""






					super().__init__(
					    __lowerCAmelCase				,      tokenizer_file=__lowerCAmelCase				,      do_lower_case=__lowerCAmelCase				,      unk_token=__lowerCAmelCase				,      sep_token=__lowerCAmelCase				,      pad_token=__lowerCAmelCase				,      cls_token=__lowerCAmelCase				,      mask_token=__lowerCAmelCase				,      tokenize_chinese_chars=__lowerCAmelCase				,      strip_accents=__lowerCAmelCase				,      **__lowerCAmelCase				,      )

					A__     =  json.loads(self.backend_tokenizer.normalizer.__getstate__()  )
					if (
					    normalizer_state.get("""lowercase"""				,      __lowerCAmelCase  ) != do_lower_case
					    or normalizer_state.get("""strip_accents"""				,      __lowerCAmelCase  ) != strip_accents
					    or normalizer_state.get("""handle_chinese_chars"""				,      __lowerCAmelCase  ) != tokenize_chinese_chars
					):
							A__     =  getattr(__lowerCAmelCase				,      normalizer_state.pop("""type"""  )  )
							A__     =  do_lower_case
							A__     =  strip_accents
							A__     =  tokenize_chinese_chars
							A__     =  normalizer_class(**__lowerCAmelCase  )

					A__     =  do_lower_case






			def   a_			(     self  :       List[Any]				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       int=None  )      ->      int:







					"""simple docstring"""






					A__     =  [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   a_			(     self  :       Any				,      __lowerCAmelCase  :       List[int]				,      __lowerCAmelCase  :       Optional[List[int]] = None  )      ->      List[int]:







					"""simple docstring"""






					A__     =  [self.sep_token_id]
					A__     =  [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  :       List[Any]				,      __lowerCAmelCase  :       str				,      __lowerCAmelCase  :       Optional[str] = None  )      ->      Tuple[str]:







					"""simple docstring"""






					A__     =  self._tokenizer.model.save(__lowerCAmelCase				,      name=__lowerCAmelCase  )
					return tuple(__lowerCAmelCase  )










import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer


class     A     (SCREAMING_SNAKE_CASE       ):
			'''simple docstring'''




			__lowerCamelCase      :			Dict							     =       '''Wav2Vec2FeatureExtractor'''
			__lowerCamelCase      :			str							     =       '''AutoTokenizer'''






			def __init__(     self  :       Union[str, Any]				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       Optional[Any]  )      ->      Tuple:







					"""simple docstring"""






					super().__init__(__lowerCAmelCase				,      __lowerCAmelCase  )
					A__     =  self.feature_extractor
					A__     =  False






			@classmethod
			def   a_			(     cls  :       Union[str, Any]				,      __lowerCAmelCase  :       Optional[Any]				,      **__lowerCAmelCase  :       Union[str, Any]  )      ->      int:







					"""simple docstring"""






					try:
							return super().from_pretrained(__lowerCAmelCase				,      **__lowerCAmelCase  )
					except OSError:
							warnings.warn(
							    f'Loading a tokenizer inside {cls.__name__} from a config that does not'
							    """ include a `tokenizer_class` attribute is deprecated and will be """
							    """removed in v5. Please add `'tokenizer_class': 'Wav2Vec2CTCTokenizer'`"""
							    """ attribute to either your `config.json` or `tokenizer_config.json` """
							    """file to suppress this warning: """				,      __lowerCAmelCase				,      )

							A__     =  WavaVecaFeatureExtractor.from_pretrained(__lowerCAmelCase				,      **__lowerCAmelCase  )
							A__     =  WavaVecaCTCTokenizer.from_pretrained(__lowerCAmelCase				,      **__lowerCAmelCase  )

							return cls(feature_extractor=__lowerCAmelCase				,      tokenizer=__lowerCAmelCase  )






			def __call__(     self  :       Any				,      *__lowerCAmelCase  :       Union[str, Any]				,      **__lowerCAmelCase  :       List[Any]  )      ->      Optional[Any]:







					"""simple docstring"""






					if self._in_target_context_manager:
							return self.current_processor(*__lowerCAmelCase				,      **__lowerCAmelCase  )

					if "raw_speech" in kwargs:
							warnings.warn("""Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."""  )
							A__     =  kwargs.pop("""raw_speech"""  )
					else:
							A__     =  kwargs.pop("""audio"""				,      __lowerCAmelCase  )
					A__     =  kwargs.pop("""sampling_rate"""				,      __lowerCAmelCase  )
					A__     =  kwargs.pop("""text"""				,      __lowerCAmelCase  )
					if len(__lowerCAmelCase  ) > 0:
							A__     =  args[0]
							A__     =  args[1:]

					if audio is None and text is None:
							raise ValueError("""You need to specify either an `audio` or `text` input to process."""  )

					if audio is not None:
							A__     =  self.feature_extractor(__lowerCAmelCase				,      *__lowerCAmelCase				,      sampling_rate=__lowerCAmelCase				,      **__lowerCAmelCase  )
					if text is not None:
							A__     =  self.tokenizer(__lowerCAmelCase				,      **__lowerCAmelCase  )

					if text is None:
							return inputs
					elif audio is None:
							return encodings
					else:
							A__     =  encodings["""input_ids"""]
							return inputs






			def   a_			(     self  :       List[str]				,      *__lowerCAmelCase  :       Optional[Any]				,      **__lowerCAmelCase  :       Tuple  )      ->      List[str]:







					"""simple docstring"""






					if self._in_target_context_manager:
							return self.current_processor.pad(*__lowerCAmelCase				,      **__lowerCAmelCase  )

					A__     =  kwargs.pop("""input_features"""				,      __lowerCAmelCase  )
					A__     =  kwargs.pop("""labels"""				,      __lowerCAmelCase  )
					if len(__lowerCAmelCase  ) > 0:
							A__     =  args[0]
							A__     =  args[1:]

					if input_features is not None:
							A__     =  self.feature_extractor.pad(__lowerCAmelCase				,      *__lowerCAmelCase				,      **__lowerCAmelCase  )
					if labels is not None:
							A__     =  self.tokenizer.pad(__lowerCAmelCase				,      **__lowerCAmelCase  )

					if labels is None:
							return input_features
					elif input_features is None:
							return labels
					else:
							A__     =  labels["""input_ids"""]
							return input_features






			def   a_			(     self  :       Optional[int]				,      *__lowerCAmelCase  :       List[str]				,      **__lowerCAmelCase  :       List[Any]  )      ->      Dict:







					"""simple docstring"""






					return self.tokenizer.batch_decode(*__lowerCAmelCase				,      **__lowerCAmelCase  )






			def   a_			(     self  :       Any				,      *__lowerCAmelCase  :       List[str]				,      **__lowerCAmelCase  :       Union[str, Any]  )      ->      List[str]:







					"""simple docstring"""






					return self.tokenizer.decode(*__lowerCAmelCase				,      **__lowerCAmelCase  )







			@contextmanager
			def   a_			(     self  :       Union[str, Any]  )      ->      int:







					"""simple docstring"""






					warnings.warn(
					    """`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your """
					    """labels by using the argument `text` of the regular `__call__` method (either in the same call as """
					    """your audio inputs, or in a separate call."""  )
					A__     =  True
					A__     =  self.tokenizer
					yield
					A__     =  self.feature_extractor
					A__     =  False



