

'''simple docstring'''






import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding






class      lowercase_      (lowerCamelCase__ ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE       :    List[Any]							     =     ['image_processor', 'tokenizer']
  SCREAMING_SNAKE_CASE       :    int							     =     'CLIPImageProcessor'
  SCREAMING_SNAKE_CASE       :    Union[str, Any]							     =     ('XLMRobertaTokenizer', 'XLMRobertaTokenizerFast')






  def __init__( self  :	int   ,lowercase__  :	int=None   ,lowercase__  :	List[str]=None   ,**lowercase__  :	Tuple     ):
   __lowercase				    =					None
   if "feature_extractor" in kwargs:
    warnings.warn(
        '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
        ''' instead.'''   ,lowercase__   ,)
    __lowercase				    =					kwargs.pop('''feature_extractor'''     )

   __lowercase				    =					image_processor if image_processor is not None else feature_extractor
   if image_processor is None:
    raise ValueError('''You need to specify an `image_processor`.'''     )
   if tokenizer is None:
    raise ValueError('''You need to specify a `tokenizer`.'''     )

   super().__init__(lowercase__   ,lowercase__     )






  def __call__( self  :	List[str]   ,lowercase__  :	List[Any]=None   ,lowercase__  :	Tuple=None   ,lowercase__  :	List[str]=None   ,**lowercase__  :	Union[str, Any]     ):

   if text is None and images is None:
    raise ValueError('''You have to specify either text or images. Both cannot be none.'''     )

   if text is not None:
    __lowercase				    =					self.tokenizer(lowercase__   ,return_tensors=lowercase__   ,**lowercase__     )

   if images is not None:
    __lowercase				    =					self.image_processor(lowercase__   ,return_tensors=lowercase__   ,**lowercase__     )

   if text is not None and images is not None:
    __lowercase				    =					image_features.pixel_values
    return encoding
   elif text is not None:
    return encoding
   else:
    return BatchEncoding(data=dict(**lowercase__     )   ,tensor_type=lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	int   ,*lowercase__  :	Dict   ,**lowercase__  :	Optional[int]     ):
   return self.tokenizer.batch_decode(*lowercase__   ,**lowercase__     )






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






  @property
  def    SCREAMING_SNAKE_CASE ( self  :	Optional[Any]     ):
   __lowercase				    =					self.tokenizer.model_input_names
   __lowercase				    =					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_tf_available,
    is_torch_available,
    is_vision_available,
)


lowercase_									=    {
    "configuration_blip": [
        "BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "BlipConfig",
        "BlipTextConfig",
        "BlipVisionConfig",
    ],
    "processing_blip": ["BlipProcessor"],
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_									=    ["BlipImageProcessor"]


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_									=    [
      "BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
      "BlipModel",
      "BlipPreTrainedModel",
      "BlipForConditionalGeneration",
      "BlipForQuestionAnswering",
      "BlipVisionModel",
      "BlipTextModel",
      "BlipForImageTextRetrieval",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_									=    [
      "TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFBlipModel",
      "TFBlipPreTrainedModel",
      "TFBlipForConditionalGeneration",
      "TFBlipForQuestionAnswering",
      "TFBlipVisionModel",
      "TFBlipTextModel",
      "TFBlipForImageTextRetrieval",
  ]

if TYPE_CHECKING:
  from .configuration_blip import BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP, BlipConfig, BlipTextConfig, BlipVisionConfig
  from .processing_blip import BlipProcessor

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .image_processing_blip import BlipImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_blip import (
        BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
        BlipForConditionalGeneration,
        BlipForImageTextRetrieval,
        BlipForQuestionAnswering,
        BlipModel,
        BlipPreTrainedModel,
        BlipTextModel,
        BlipVisionModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_blip import (
        TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFBlipForConditionalGeneration,
        TFBlipForImageTextRetrieval,
        TFBlipForQuestionAnswering,
        TFBlipModel,
        TFBlipPreTrainedModel,
        TFBlipTextModel,
        TFBlipVisionModel,
    )

else:
  import sys

  lowercase_									=    _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



