

from ...processing_utils import ProcessorMixin





class       __A(				_UpperCAmelCase       ):
					SCREAMING_SNAKE_CASE			    =    '''WhisperFeatureExtractor'''
					SCREAMING_SNAKE_CASE			    =    '''WhisperTokenizer'''

					def __init__(	self					:     List[Any]   ,					__UpperCamelCase					:     int   ,					__UpperCamelCase					:     Dict   ):
												super().__init__(A_   ,					A_   )
												lowerCamelCase_							  =					self.feature_extractor
												lowerCamelCase_							  =					False

					def    lowercase__      (	self					:     Any   ,					__UpperCamelCase					:     Union[str, Any]=None   ,					__UpperCamelCase					:     Optional[int]=None   ,					__UpperCamelCase					:     str=True   ):
												return self.tokenizer.get_decoder_prompt_ids(task=A_   ,					language=A_   ,					no_timestamps=A_   )

					def __call__(	self					:     Optional[int]   ,					*__UpperCamelCase					:     List[Any]   ,					**__UpperCamelCase					:     List[str]   ):
												# For backward compatibility
												if self._in_target_context_manager:
																			return self.current_processor(*A_   ,					**A_   )

												lowerCamelCase_							  =					kwargs.pop("""audio"""   ,					A_   )
												lowerCamelCase_							  =					kwargs.pop("""sampling_rate"""   ,					A_   )
												lowerCamelCase_							  =					kwargs.pop("""text"""   ,					A_   )
												if len(A_   ) > 0:
																			lowerCamelCase_							  =					args[0]
																			lowerCamelCase_							  =					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:
																			lowerCamelCase_							  =					self.feature_extractor(A_   ,					*A_   ,					sampling_rate=A_   ,					**A_   )
												if text is not None:
																			lowerCamelCase_							  =					self.tokenizer(A_   ,					**A_   )

												if text is None:
																			return inputs

												elif audio is None:
																			return encodings
												else:
																			lowerCamelCase_							  =					encodings["""input_ids"""]
																			return inputs

					def    lowercase__      (	self					:     str   ,					*__UpperCamelCase					:     List[str]   ,					**__UpperCamelCase					:     Any   ):
												return self.tokenizer.batch_decode(*A_   ,					**A_   )

					def    lowercase__      (	self					:     Tuple   ,					*__UpperCamelCase					:     str   ,					**__UpperCamelCase					:     Optional[int]   ):
												return self.tokenizer.decode(*A_   ,					**A_   )



					def    lowercase__      (	self					:     Optional[int]   ,					__UpperCamelCase					:     str   ,					__UpperCamelCase					:     Union[str, Any]="np"   ):
												return self.tokenizer.get_prompt_ids(A_   ,					return_tensors=A_   )







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


lowercase        =  logging.get_logger(__name__)

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

lowercase        =  {
    '''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'''
    },
}

lowercase        =  {'''mobilebert-uncased''': 5_1_2}


lowercase        =  {}





class       __A(				UpperCAmelCase       ):
					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			    =    MobileBertTokenizer

					def __init__(	self					:     Union[str, Any]   ,					__UpperCamelCase					:     str=None   ,					__UpperCamelCase					:     str=None   ,					__UpperCamelCase					:     Dict=True   ,					__UpperCamelCase					:     Any="[UNK]"   ,					__UpperCamelCase					:     str="[SEP]"   ,					__UpperCamelCase					:     Dict="[PAD]"   ,					__UpperCamelCase					:     List[str]="[CLS]"   ,					__UpperCamelCase					:     Any="[MASK]"   ,					__UpperCamelCase					:     Any=True   ,					__UpperCamelCase					:     int=None   ,					**__UpperCamelCase					:     Dict   ,					):
												super().__init__(
												    __UpperCamelCase   ,					tokenizer_file=__UpperCamelCase   ,					do_lower_case=__UpperCamelCase   ,					unk_token=__UpperCamelCase   ,					sep_token=__UpperCamelCase   ,					pad_token=__UpperCamelCase   ,					cls_token=__UpperCamelCase   ,					mask_token=__UpperCamelCase   ,					tokenize_chinese_chars=__UpperCamelCase   ,					strip_accents=__UpperCamelCase   ,					**__UpperCamelCase   ,					)

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

												lowerCamelCase_							  =					do_lower_case

					def    lowercase__      (	self					:     List[str]   ,					__UpperCamelCase					:     Union[str, Any]   ,					__UpperCamelCase					:     Dict=None   ):
												lowerCamelCase_							  =					[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    lowercase__      (	self					:     Tuple   ,					__UpperCamelCase					:     List[int]   ,					__UpperCamelCase					:     Optional[List[int]] = 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    lowercase__      (	self					:     List[str]   ,					__UpperCamelCase					:     str   ,					__UpperCamelCase					:     Optional[str] = None   ):
												lowerCamelCase_							  =					self._tokenizer.model.save(__UpperCamelCase   ,					name=__UpperCamelCase   )
												return tuple(__UpperCamelCase   )





