



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


 """simple docstring"""


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







 def __init__(							self  ,a_  ,a_							)		->   Any:
        _UpperCAmelCase  :						Union[str, Any]			     = False
        super().__init__(a_  ,a_							)
        _UpperCAmelCase  :						Optional[int]			     = 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:
               _UpperCAmelCase  :						int			     = self.tokenizer
               _UpperCAmelCase  :						Any			     = 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  :						Optional[Any]			     = self.image_processor(a_  ,return_tensors=a_							)

        if text is not None:
               _UpperCAmelCase  :						Tuple			     = 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  :						int			     = None

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

        return encoding_image_processor







 def _snake_case (							self  ,*a_  ,**a_							)		->   List[Any]:
        return self.tokenizer.batch_decode(*a_  ,**a_							)







 def _snake_case (							self  ,*a_  ,**a_							)		->   Tuple:
        return self.tokenizer.decode(*a_  ,**a_							)







 @property
 def _snake_case (							self							)		->   List[str]:
        _UpperCAmelCase  :						Union[str, Any]			     = self.tokenizer.model_input_names
        _UpperCAmelCase  :						Optional[int]			     = 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 _LazyModule


A_							: int						 =	{"""tokenization_bertweet""": ["""BertweetTokenizer"""]}


if TYPE_CHECKING:
   from .tokenization_bertweet import BertweetTokenizer

else:
   import sys

   A_							: int						 =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



