




'''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 		lowercase_   (			A       ):


   """simple docstring"""

   lowerCamelCase_      =						['''image_processor''', '''tokenizer''']
   lowerCamelCase_      =						'''BlipImageProcessor'''
   lowerCamelCase_      =						('''BertTokenizer''', '''BertTokenizerFast''')



   def __init__(   self :     List[str]  ,				__lowerCamelCase :     str  ,				__lowerCamelCase :     Optional[int]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				False
      super().__init__(__lowerCamelCase  ,				__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				self.image_processor



   def __call__(   self :     Tuple  ,				__lowerCamelCase :     ImageInput = None  ,				__lowerCamelCase :     Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None  ,				__lowerCamelCase :     bool = True  ,				__lowerCamelCase :     Union[bool, str, PaddingStrategy] = False  ,				__lowerCamelCase :     Union[bool, str, TruncationStrategy] = None  ,				__lowerCamelCase :     Optional[int] = None  ,				__lowerCamelCase :     int = 0  ,				__lowerCamelCase :     Optional[int] = None  ,				__lowerCamelCase :     Optional[bool] = None  ,				__lowerCamelCase :     bool = False  ,				__lowerCamelCase :     bool = False  ,				__lowerCamelCase :     bool = False  ,				__lowerCamelCase :     bool = False  ,				__lowerCamelCase :     bool = False  ,				__lowerCamelCase :     bool = True  ,				__lowerCamelCase :     Optional[Union[str, TensorType]] = None  ,				**__lowerCamelCase :     Dict  ,				):

      """simple docstring"""
      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:
         _SCREAMING_SNAKE_CASE	=				self.tokenizer
         _SCREAMING_SNAKE_CASE	=				self.tokenizer(
             text=__lowerCamelCase  ,				add_special_tokens=__lowerCamelCase  ,				padding=__lowerCamelCase  ,				truncation=__lowerCamelCase  ,				max_length=__lowerCamelCase  ,				stride=__lowerCamelCase  ,				pad_to_multiple_of=__lowerCamelCase  ,				return_attention_mask=__lowerCamelCase  ,				return_overflowing_tokens=__lowerCamelCase  ,				return_special_tokens_mask=__lowerCamelCase  ,				return_offsets_mapping=__lowerCamelCase  ,				return_token_type_ids=__lowerCamelCase  ,				return_length=__lowerCamelCase  ,				verbose=__lowerCamelCase  ,				return_tensors=__lowerCamelCase  ,				**__lowerCamelCase  ,				)
         return text_encoding

      # add pixel_values
      _SCREAMING_SNAKE_CASE	=				self.image_processor(__lowerCamelCase  ,				return_tensors=__lowerCamelCase   )

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

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

      return encoding_image_processor



   def 							lowerCAmelCase_      (   self :     str  ,				*__lowerCamelCase :     Dict  ,				**__lowerCamelCase :     List[Any]   ):

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



   def 							lowerCAmelCase_      (   self :     List[str]  ,				*__lowerCamelCase :     Optional[Any]  ,				**__lowerCamelCase :     Union[str, Any]   ):

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



   @property
   def 							lowerCAmelCase_      (   self :     List[Any]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.tokenizer.model_input_names
      _SCREAMING_SNAKE_CASE	=				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_torch_available, is_vision_available


lowerCamelCase_			=						{
    'configuration_bridgetower': [
        'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'BridgeTowerConfig',
        'BridgeTowerTextConfig',
        'BridgeTowerVisionConfig',
    ],
    'processing_bridgetower': ['BridgeTowerProcessor'],
}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase_			=						['BridgeTowerImageProcessor']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase_			=						[
     'BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST',
     'BridgeTowerForContrastiveLearning',
     'BridgeTowerForImageAndTextRetrieval',
     'BridgeTowerForMaskedLM',
     'BridgeTowerModel',
     'BridgeTowerPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_bridgetower import (
     BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP,
     BridgeTowerConfig,
     BridgeTowerTextConfig,
     BridgeTowerVisionConfig,
 )
 from .processing_bridgetower import BridgeTowerProcessor

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .image_processing_bridgetower import BridgeTowerImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_bridgetower import (
      BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST,
      BridgeTowerForContrastiveLearning,
      BridgeTowerForImageAndTextRetrieval,
      BridgeTowerForMaskedLM,
      BridgeTowerModel,
      BridgeTowerPreTrainedModel,
  )


else:
 import sys

 lowerCamelCase_			=						_LazyModule(__name__, globals()['__file__'], _import_structure)

