


"""simple docstring"""







from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType






class 				__A    (	_SCREAMING_SNAKE_CASE      ):






 """simple docstring"""




 __lowerCAmelCase			 =  ["image_processor", "tokenizer"]
 __lowerCAmelCase			 =  "BlipImageProcessor"
 __lowerCAmelCase			 =  ("BertTokenizer", "BertTokenizerFast")


 def __init__(		self			,   __A			,   __A						) ->					List[Any]:
     a					=False
     super().__init__(__A			,   __A						)
     a					=self.image_processor


 def __call__(		self			,   __A = None			,   __A = None			,   __A = True			,   __A = False			,   __A = None			,   __A = None			,   __A = 0			,   __A = None			,   __A = None			,   __A = False			,   __A = False			,   __A = False			,   __A = False			,   __A = False			,   __A = True			,   __A = None			,   **__A			,   ) ->					BatchEncoding:
     if images is None and text is None:
         raise ValueError('''You have to specify either images or text.'''						)

     # Get only text
     if images is None:
         a					=self.tokenizer
         a					=self.tokenizer(
             text=__A			,   add_special_tokens=__A			,   padding=__A			,   truncation=__A			,   max_length=__A			,   stride=__A			,   pad_to_multiple_of=__A			,   return_attention_mask=__A			,   return_overflowing_tokens=__A			,   return_special_tokens_mask=__A			,   return_offsets_mapping=__A			,   return_token_type_ids=__A			,   return_length=__A			,   verbose=__A			,   return_tensors=__A			,   **__A			,   )
         return text_encoding

     # add pixel_values
     a					=self.image_processor(__A			,   return_tensors=__A						)

     if text is not None:
         a					=self.tokenizer(
             text=__A			,   add_special_tokens=__A			,   padding=__A			,   truncation=__A			,   max_length=__A			,   stride=__A			,   pad_to_multiple_of=__A			,   return_attention_mask=__A			,   return_overflowing_tokens=__A			,   return_special_tokens_mask=__A			,   return_offsets_mapping=__A			,   return_token_type_ids=__A			,   return_length=__A			,   verbose=__A			,   return_tensors=__A			,   **__A			,   )
     else:
         a					=None

     if text_encoding is not None:
         encoding_image_processor.update(__A						)

     return encoding_image_processor


 def 				SCREAMING_SNAKE_CASE							(		self			,   *__A			,   **__A						) ->					str:
     return self.tokenizer.batch_decode(*__A			,   **__A						)


 def 				SCREAMING_SNAKE_CASE							(		self			,   *__A			,   **__A						) ->					str:
     return self.tokenizer.decode(*__A			,   **__A						)





 @property
 def 				SCREAMING_SNAKE_CASE							(		self						) ->					Dict:
     a					=self.tokenizer.model_input_names
     a					=self.image_processor.model_input_names
     return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names						)						)



"""simple docstring"""







from ...processing_utils import ProcessorMixin






class 				__A    (	_SCREAMING_SNAKE_CASE      ):






 """simple docstring"""




 __lowerCAmelCase			 =  "WhisperFeatureExtractor"
 __lowerCAmelCase			 =  "WhisperTokenizer"


 def __init__(		self			,   __A			,   __A						) ->					Dict:
     super().__init__(__A			,   __A						)
     a					=self.feature_extractor
     a					=False


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A=None			,   __A=None			,   __A=True						) ->					int:
     return self.tokenizer.get_decoder_prompt_ids(task=__A			,   language=__A			,   no_timestamps=__A						)


 def __call__(		self			,   *__A			,   **__A						) ->					Tuple:
     # For backward compatibility
     if self._in_target_context_manager:
         return self.current_processor(*__A			,   **__A						)

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

     if text is None:
         return inputs

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


 def 				SCREAMING_SNAKE_CASE							(		self			,   *__A			,   **__A						) ->					Optional[Any]:
     return self.tokenizer.batch_decode(*__A			,   **__A						)


 def 				SCREAMING_SNAKE_CASE							(		self			,   *__A			,   **__A						) ->					Union[str, Any]:
     return self.tokenizer.decode(*__A			,   **__A						)





 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A="np"						) ->					Optional[Any]:
     return self.tokenizer.get_prompt_ids(__A			,   return_tensors=__A						)