
"""simple docstring"""





from ...processing_utils import ProcessorMixin


class A_	(UpperCamelCase__      ):




  '''simple docstring'''
  SCREAMING_SNAKE_CASE__			:						Optional[Any]       =		"""WhisperFeatureExtractor"""
  SCREAMING_SNAKE_CASE__			:						Any       =		"""WhisperTokenizer"""







  def __init__(		self				,   lowercase_				,   lowercase_  ):

     """simple docstring"""
     super().__init__(_a				,   _a  )
     UpperCAmelCase_					:					Dict			     =    self.feature_extractor
     UpperCAmelCase_					:					List[Any]			     =    False







  def        UpperCamelCase__					(		self				,   lowercase_=None				,   lowercase_=None				,   lowercase_=True  ):

     """simple docstring"""
     return self.tokenizer.get_decoder_prompt_ids(task=_a				,   language=_a				,   no_timestamps=_a  )







  def __call__(		self				,   *lowercase_				,   **lowercase_  ):

     """simple docstring"""
     # For backward compatibility
     if self._in_target_context_manager:
        return self.current_processor(*_a				,   **_a  )

     UpperCAmelCase_					:					Union[str, Any]			     =    kwargs.pop("audio"				,   _a  )
     UpperCAmelCase_					:					Tuple			     =    kwargs.pop("sampling_rate"				,   _a  )
     UpperCAmelCase_					:					int			     =    kwargs.pop("text"				,   _a  )
     if len(_a  ) > 0:
        UpperCAmelCase_					:					Dict			     =    args[0]
        UpperCAmelCase_					:					int			     =    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:
        UpperCAmelCase_					:					Optional[int]			     =    self.feature_extractor(_a				,   *_a				,   sampling_rate=_a				,   **_a  )
     if text is not None:
        UpperCAmelCase_					:					int			     =    self.tokenizer(_a				,   **_a  )

     if text is None:
        return inputs

     elif audio is None:
        return encodings
     else:
        UpperCAmelCase_					:					List[Any]			     =    encodings["""input_ids"""]
        return inputs







  def        UpperCamelCase__					(		self				,   *lowercase_				,   **lowercase_  ):

     """simple docstring"""
     return self.tokenizer.batch_decode(*_a				,   **_a  )







  def        UpperCamelCase__					(		self				,   *lowercase_				,   **lowercase_  ):

     """simple docstring"""
     return self.tokenizer.decode(*_a				,   **_a  )







  def        UpperCamelCase__					(		self				,   lowercase_				,   lowercase_="np"  ):

     """simple docstring"""
     return self.tokenizer.get_prompt_ids(_a				,   return_tensors=_a  )








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_fnet import FNetTokenizer
else:
  _snake_case										=       None

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

_snake_case										=       {
    "vocab_file": {
        "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/spiece.model",
        "google/fnet-large": "https://huggingface.co/google/fnet-large/resolve/main/spiece.model",
    },
    "tokenizer_file": {
        "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/tokenizer.json",
        "google/fnet-large": "https://huggingface.co/google/fnet-large/resolve/main/tokenizer.json",
    },
}

_snake_case										=       {
    "google/fnet-base": 512,
    "google/fnet-large": 512,
}

_snake_case										=       "▁"







class 						lowercase							(   UpperCamelCase__		):
     _a							 =						VOCAB_FILES_NAMES
     _a							 =						PRETRAINED_VOCAB_FILES_MAP
     _a							 =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     _a							 =						["input_ids", "token_type_ids"]
     _a							 =						FNetTokenizer

     def __init__(  self		,     _a=None		,     _a=None		,     _a=False		,     _a=True		,     _a=True		,     _a="<unk>"		,     _a="[SEP]"		,     _a="<pad>"		,     _a="[CLS]"		,     _a="[MASK]"		,     **_a		,     )						->							Optional[int]:
           # 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.
           _A							:     int			=						(
               AddedToken(_a		,     lstrip=_a		,     rstrip=_a		,     normalized=_a				)
               if isinstance(_a		,     _a				)
               else mask_token
           )

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

           _A							:     Optional[int]			=						do_lower_case
           _A							:     List[Any]			=						remove_space
           _A							:     str			=						keep_accents
           _A							:     int			=						vocab_file
           _A							:     int			=						False if not self.vocab_file else True

     def 					a__	(  self		,     _a		,     _a = None				)						->							List[int]:
           _A							:     str			=						[self.sep_token_id]
           _A							:     Dict			=						[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		,     _a		,     _a = None				)						->							List[int]:
           _A							:     Any			=						[self.sep_token_id]
           _A							:     Any			=						[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		,     _a		,     _a = None				)						->							Tuple[str]:
           if not os.path.isdir(_a				):
                 logger.error(F'''Vocabulary path ({save_directory}) should be a directory'''				)
                 return
           _A							:     List[str]			=						os.path.join(
               _a		,     (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]				)

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

           return (out_vocab_file,)

