





'''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      snake_case     (    __lowerCamelCase       ):




 """simple docstring"""



 SCREAMING_SNAKE_CASE_	:					Any					=["image_processor", "tokenizer"]
 SCREAMING_SNAKE_CASE_	:					List[Any]					="BlipImageProcessor"
 SCREAMING_SNAKE_CASE_	:					Optional[int]					=("BertTokenizer", "BertTokenizerFast")






 def __init__(       self       :							Dict							,	__A       :							Optional[int]							,	__A       :							List[Any]	):
        __UpperCamelCase       =  False
        super().__init__(__A							,	__A	)
        __UpperCamelCase       =  self.image_processor






 def __call__(       self       :							List[Any]							,	__A       :							ImageInput = None							,	__A       :							Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None							,	__A       :							bool = True							,	__A       :							Union[bool, str, PaddingStrategy] = False							,	__A       :							Union[bool, str, TruncationStrategy] = None							,	__A       :							Optional[int] = None							,	__A       :							int = 0							,	__A       :							Optional[int] = None							,	__A       :							Optional[bool] = None							,	__A       :							bool = False							,	__A       :							bool = False							,	__A       :							bool = False							,	__A       :							bool = False							,	__A       :							bool = False							,	__A       :							bool = True							,	__A       :							Optional[Union[str, TensorType]] = None							,	**__A       :							List[Any]							,	):
        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:
               __UpperCamelCase       =  self.tokenizer
               __UpperCamelCase       =  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
        __UpperCamelCase       =  self.image_processor(__A							,	return_tensors=__A	)

        if text is not None:
               __UpperCamelCase       =  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:
               __UpperCamelCase       =  None

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

        return encoding_image_processor






 def        _lowerCamelCase					(       self       :							List[Any]							,	*__A       :							Dict							,	**__A       :							Optional[int]	):
        return self.tokenizer.batch_decode(*__A							,	**__A	)






 def        _lowerCamelCase					(       self       :							List[Any]							,	*__A       :							List[str]							,	**__A       :							Dict	):
        return self.tokenizer.decode(*__A							,	**__A	)






 @property
 def        _lowerCamelCase					(       self       :							Tuple	):
        __UpperCamelCase       =  self.tokenizer.model_input_names
        __UpperCamelCase       =  self.image_processor.model_input_names
        return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)


'''simple docstring'''




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_tf_available,
    is_torch_available,
)


lowercase			:				Dict    		=			{
    'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Speech2TextConfig'],
    'processing_speech_to_text': ['Speech2TextProcessor'],
}

try:
      if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase			:				List[Any]    		=			['Speech2TextTokenizer']

try:
      if not is_speech_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase			:				List[str]    		=			['Speech2TextFeatureExtractor']

try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase			:				Dict    		=			[
          'TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
          'TFSpeech2TextForConditionalGeneration',
          'TFSpeech2TextModel',
          'TFSpeech2TextPreTrainedModel',
      ]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase			:				Any    		=			[
          'SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Speech2TextForConditionalGeneration',
          'Speech2TextModel',
          'Speech2TextPreTrainedModel',
      ]


if TYPE_CHECKING:
      from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
      from .processing_speech_to_text import SpeechaTextProcessor

      try:
            if not is_sentencepiece_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_speech_to_text import SpeechaTextTokenizer

      try:
            if not is_speech_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_speech_to_text import (
                TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
                TFSpeechaTextForConditionalGeneration,
                TFSpeechaTextModel,
                TFSpeechaTextPreTrainedModel,
            )

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_speech_to_text import (
                SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
                SpeechaTextForConditionalGeneration,
                SpeechaTextModel,
                SpeechaTextPreTrainedModel,
            )

else:
      import sys

      lowercase			:				List[Any]    		=			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




