




'''simple docstring'''


import warnings
from contextlib import contextmanager

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





class    __lowercase						(  __magic_name__ ):
   _a							=      """Wav2Vec2FeatureExtractor"""
   _a							=      """AutoTokenizer"""







   def __init__(	self      ,							UpperCamelCase      ,							UpperCamelCase      )				->    Any:
     super().__init__(UpperCamelCase      ,							UpperCamelCase      )
     __a			=					self.feature_extractor
     __a			=					False







   @classmethod
   def 		UpperCamelCase__			(	cls      ,							UpperCamelCase      ,							**UpperCamelCase      )				->    Optional[int]:
     try:
       return super().from_pretrained(UpperCamelCase      ,							**UpperCamelCase      )
     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: '      ,							UpperCamelCase      ,							)

       __a			=					WavaVecaFeatureExtractor.from_pretrained(UpperCamelCase      ,							**UpperCamelCase      )
       __a			=					WavaVecaCTCTokenizer.from_pretrained(UpperCamelCase      ,							**UpperCamelCase      )

       return cls(feature_extractor=UpperCamelCase      ,							tokenizer=UpperCamelCase      )







   def __call__(	self      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    List[str]:
     # For backward compatibility
     if self._in_target_context_manager:
       return self.current_processor(*UpperCamelCase      ,							**UpperCamelCase      )

     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'      ,							UpperCamelCase      )
     __a			=					kwargs.pop('sampling_rate'      ,							UpperCamelCase      )
     __a			=					kwargs.pop('text'      ,							UpperCamelCase      )
     if len(UpperCamelCase      ) > 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(UpperCamelCase      ,							*UpperCamelCase      ,							sampling_rate=UpperCamelCase      ,							**UpperCamelCase      )
     if text is not None:
       __a			=					self.tokenizer(UpperCamelCase      ,							**UpperCamelCase      )

     if text is None:
       return inputs
     elif audio is None:
       return encodings
     else:
       __a			=					encodings['input_ids']
       return inputs







   def 		UpperCamelCase__			(	self      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    Any:
     # For backward compatibility
     if self._in_target_context_manager:
       return self.current_processor.pad(*UpperCamelCase      ,							**UpperCamelCase      )

     __a			=					kwargs.pop('input_features'      ,							UpperCamelCase      )
     __a			=					kwargs.pop('labels'      ,							UpperCamelCase      )
     if len(UpperCamelCase      ) > 0:
       __a			=					args[0]
       __a			=					args[1:]

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

     if labels is None:
       return input_features
     elif input_features is None:
       return labels
     else:
       __a			=					labels['input_ids']
       return input_features







   def 		UpperCamelCase__			(	self      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    str:
     return self.tokenizer.batch_decode(*UpperCamelCase      ,							**UpperCamelCase      )







   def 		UpperCamelCase__			(	self      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    Optional[int]:
     return self.tokenizer.decode(*UpperCamelCase      ,							**UpperCamelCase      )







   @contextmanager
   def 		UpperCamelCase__			(	self      )				->    Any:
     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









'''simple docstring'''


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


UpperCAmelCase_ 		=      logging.get_logger(__name__)

UpperCAmelCase_ 		=      {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

UpperCAmelCase_ 		=      {
    "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"
    },
}

UpperCAmelCase_ 		=      {"mobilebert-uncased": 5_12}


UpperCAmelCase_ 		=      {}





class    __lowercase						(  __magic_name__ ):
   _a							=      VOCAB_FILES_NAMES
   _a							=      PRETRAINED_VOCAB_FILES_MAP
   _a							=      PRETRAINED_INIT_CONFIGURATION
   _a							=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   _a							=      MobileBertTokenizer







   def __init__(	self      ,							UpperCamelCase=None      ,							UpperCamelCase=None      ,							UpperCamelCase=True      ,							UpperCamelCase="[UNK]"      ,							UpperCamelCase="[SEP]"      ,							UpperCamelCase="[PAD]"      ,							UpperCamelCase="[CLS]"      ,							UpperCamelCase="[MASK]"      ,							UpperCamelCase=True      ,							UpperCamelCase=None      ,							**UpperCamelCase      ,							)				->    List[Any]:
     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      ,							)

     __a			=					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
     ):
       __a			=					getattr(UpperCamelCase      ,							normalizer_state.pop('type'      )      )
       __a			=					do_lower_case
       __a			=					strip_accents
       __a			=					tokenize_chinese_chars
       __a			=					normalizer_class(**UpperCamelCase      )

     __a			=					do_lower_case







   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase=None      )				->    Tuple:
     __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 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase = None      )				->    List[int]:
     __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 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase = None      )				->    Tuple[str]:
     __a			=					self._tokenizer.model.save(UpperCamelCase      ,							name=UpperCamelCase      )
     return tuple(UpperCamelCase      )



