


"""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_				):
   __UpperCAmelCase							       =					['''image_processor''', '''tokenizer''']
   __UpperCAmelCase							       =					'''BlipImageProcessor'''
   __UpperCAmelCase							       =					('''BertTokenizer''', '''BertTokenizerFast''')





   def __init__(							self      ,   SCREAMING_SNAKE_CASE      ,   SCREAMING_SNAKE_CASE)  ->  List[str]:
      _lowerCamelCase	:					Dict   =		False
      super().__init__(SCREAMING_SNAKE_CASE      ,   SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Optional[Any]   =		self.image_processor





   def __call__(							self      ,   SCREAMING_SNAKE_CASE = None      ,   SCREAMING_SNAKE_CASE = None      ,   SCREAMING_SNAKE_CASE = True      ,   SCREAMING_SNAKE_CASE = False      ,   SCREAMING_SNAKE_CASE = None      ,   SCREAMING_SNAKE_CASE = None      ,   SCREAMING_SNAKE_CASE = 0      ,   SCREAMING_SNAKE_CASE = None      ,   SCREAMING_SNAKE_CASE = None      ,   SCREAMING_SNAKE_CASE = False      ,   SCREAMING_SNAKE_CASE = False      ,   SCREAMING_SNAKE_CASE = False      ,   SCREAMING_SNAKE_CASE = False      ,   SCREAMING_SNAKE_CASE = False      ,   SCREAMING_SNAKE_CASE = True      ,   SCREAMING_SNAKE_CASE = None      ,   **SCREAMING_SNAKE_CASE      ,   )  ->  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:
         _lowerCamelCase	:					Any   =		self.tokenizer
         _lowerCamelCase	:					str   =		self.tokenizer(
             text=SCREAMING_SNAKE_CASE      ,   add_special_tokens=SCREAMING_SNAKE_CASE      ,   padding=SCREAMING_SNAKE_CASE      ,   truncation=SCREAMING_SNAKE_CASE      ,   max_length=SCREAMING_SNAKE_CASE      ,   stride=SCREAMING_SNAKE_CASE      ,   pad_to_multiple_of=SCREAMING_SNAKE_CASE      ,   return_attention_mask=SCREAMING_SNAKE_CASE      ,   return_overflowing_tokens=SCREAMING_SNAKE_CASE      ,   return_special_tokens_mask=SCREAMING_SNAKE_CASE      ,   return_offsets_mapping=SCREAMING_SNAKE_CASE      ,   return_token_type_ids=SCREAMING_SNAKE_CASE      ,   return_length=SCREAMING_SNAKE_CASE      ,   verbose=SCREAMING_SNAKE_CASE      ,   return_tensors=SCREAMING_SNAKE_CASE      ,   **SCREAMING_SNAKE_CASE      ,   )
         return text_encoding

      # add pixel_values
      _lowerCamelCase	:					Dict   =		self.image_processor(SCREAMING_SNAKE_CASE      ,   return_tensors=SCREAMING_SNAKE_CASE)

      if text is not None:
         _lowerCamelCase	:					Optional[Any]   =		self.tokenizer(
             text=SCREAMING_SNAKE_CASE      ,   add_special_tokens=SCREAMING_SNAKE_CASE      ,   padding=SCREAMING_SNAKE_CASE      ,   truncation=SCREAMING_SNAKE_CASE      ,   max_length=SCREAMING_SNAKE_CASE      ,   stride=SCREAMING_SNAKE_CASE      ,   pad_to_multiple_of=SCREAMING_SNAKE_CASE      ,   return_attention_mask=SCREAMING_SNAKE_CASE      ,   return_overflowing_tokens=SCREAMING_SNAKE_CASE      ,   return_special_tokens_mask=SCREAMING_SNAKE_CASE      ,   return_offsets_mapping=SCREAMING_SNAKE_CASE      ,   return_token_type_ids=SCREAMING_SNAKE_CASE      ,   return_length=SCREAMING_SNAKE_CASE      ,   verbose=SCREAMING_SNAKE_CASE      ,   return_tensors=SCREAMING_SNAKE_CASE      ,   **SCREAMING_SNAKE_CASE      ,   )
      else:
         _lowerCamelCase	:					List[Any]   =		None

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

      return encoding_image_processor





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





   def 		UpperCamelCase_  (							self      ,   *SCREAMING_SNAKE_CASE      ,   **SCREAMING_SNAKE_CASE)  ->  Optional[int]:
      return self.tokenizer.decode(*SCREAMING_SNAKE_CASE      ,   **SCREAMING_SNAKE_CASE)





   @property
   def 		UpperCamelCase_  (							self)  ->  Tuple:
      _lowerCamelCase	:					str   =		self.tokenizer.model_input_names
      _lowerCamelCase	:					Optional[Any]   =		self.image_processor.model_input_names
      return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))






from typing import TYPE_CHECKING

from ...utils import _LazyModule


a      :  int			     =			{'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']}


if TYPE_CHECKING:
	from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer
else:
	import sys

	a      :  int			     =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)






