






import copy
import random

from transformers import CLIPTokenizer
class 						lowerCamelCase_				(      lowerCamelCase ):







				def __init__(						self       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								super().__init__(*__lowerCAmelCase       ,					**__lowerCAmelCase     )
								__magic_name__		:Tuple        =      {}







				def 			A	(						self       ,					__lowerCAmelCase       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								__magic_name__		:Dict        =      super().add_tokens(__lowerCAmelCase       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     )
								if num_added_tokens == 0:
												raise ValueError(
												    F'''The tokenizer already contains the token {placeholder_token}. Please pass a different'''
												    ''' `placeholder_token` that is not already in the tokenizer.'''     )







				def 			A	(						self       ,					__lowerCAmelCase       ,					*__lowerCAmelCase       ,					__lowerCAmelCase=1       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								__magic_name__		:Optional[int]        =      []
								if num_vec_per_token == 1:
												self.try_adding_tokens(__lowerCAmelCase       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     )
												output.append(__lowerCAmelCase     )
								else:
												__magic_name__		:Any        =      []
												for i in range(__lowerCAmelCase     ):
																__magic_name__		:Optional[int]        =      placeholder_token + F'''_{i}'''
																self.try_adding_tokens(__lowerCAmelCase       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     )
																output.append(__lowerCAmelCase     )
        # handle cases where there is a new placeholder token that contains the current placeholder token but is larger
								for token in self.token_map:
												if token in placeholder_token:
																raise ValueError(
																    F'''The tokenizer already has placeholder token {token} that can get confused with'''
																    F''' {placeholder_token}keep placeholder tokens independent'''     )
								__magic_name__		:Dict        =      output







				def 			A	(						self       ,					__lowerCAmelCase       ,					__lowerCAmelCase=False       ,					__lowerCAmelCase=1.0     ):
								"""simple docstring"""
								if isinstance(__lowerCAmelCase       ,					__lowerCAmelCase     ):
												__magic_name__		:Union[str, Any]        =      []
												for i in range(len(__lowerCAmelCase     )     ):
																output.append(self.replace_placeholder_tokens_in_text(text[i]       ,					vector_shuffle=__lowerCAmelCase     )     )
												return output
								for placeholder_token in self.token_map:
												if placeholder_token in text:
																__magic_name__		:Optional[Any]        =      self.token_map[placeholder_token]
																__magic_name__		:List[Any]        =      tokens[: 1 + int(len(__lowerCAmelCase     ) * prop_tokens_to_load     )]
																if vector_shuffle:
																				__magic_name__		:str        =      copy.copy(__lowerCAmelCase     )
																				random.shuffle(__lowerCAmelCase     )
																__magic_name__		:int        =      text.replace(__lowerCAmelCase       ,					''' '''.join(__lowerCAmelCase     )     )
								return text







				def __call__(						self       ,					__lowerCAmelCase       ,					*__lowerCAmelCase       ,					__lowerCAmelCase=False       ,					__lowerCAmelCase=1.0       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return super().__call__(
								    self.replace_placeholder_tokens_in_text(
								        __lowerCAmelCase       ,					vector_shuffle=__lowerCAmelCase       ,					prop_tokens_to_load=__lowerCAmelCase     )       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase       ,					)







				def 			A	(						self       ,					__lowerCAmelCase       ,					*__lowerCAmelCase       ,					__lowerCAmelCase=False       ,					__lowerCAmelCase=1.0       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return super().encode(
								    self.replace_placeholder_tokens_in_text(
								        __lowerCAmelCase       ,					vector_shuffle=__lowerCAmelCase       ,					prop_tokens_to_load=__lowerCAmelCase     )       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase       ,					)














from ...processing_utils import ProcessorMixin
class 						lowerCamelCase_				(      lowerCamelCase ):
				a__					       =  '''WhisperFeatureExtractor'''
				a__					       =  '''WhisperTokenizer'''







				def __init__(						self       ,					__lowerCAmelCase       ,					__lowerCAmelCase     ):
								"""simple docstring"""
								super().__init__(__lowerCAmelCase       ,					__lowerCAmelCase     )
								__magic_name__		:int        =      self.feature_extractor
								__magic_name__		:int        =      False







				def 			A	(						self       ,					__lowerCAmelCase=None       ,					__lowerCAmelCase=None       ,					__lowerCAmelCase=True     ):
								"""simple docstring"""
								return self.tokenizer.get_decoder_prompt_ids(task=__lowerCAmelCase       ,					language=__lowerCAmelCase       ,					no_timestamps=__lowerCAmelCase     )







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

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

								if text is None:
												return inputs

								elif audio is None:
												return encodings
								else:
												__magic_name__		:str        =      encodings['''input_ids''']
												return inputs







				def 			A	(						self       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return self.tokenizer.batch_decode(*__lowerCAmelCase       ,					**__lowerCAmelCase     )







				def 			A	(						self       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return self.tokenizer.decode(*__lowerCAmelCase       ,					**__lowerCAmelCase     )







				def 			A	(						self       ,					__lowerCAmelCase       ,					__lowerCAmelCase="np"     ):
								"""simple docstring"""
								return self.tokenizer.get_prompt_ids(__lowerCAmelCase       ,					return_tensors=__lowerCAmelCase     )






