

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



 """simple docstring"""



 lowerCAmelCase__  					=      ["image_processor", "tokenizer"]
 lowerCAmelCase__  					=      "BlipImageProcessor"
 lowerCAmelCase__  					=      "AutoTokenizer"
 def __init__(		self					:       Dict					,							__SCREAMING_SNAKE_CASE					:       Any					,							__SCREAMING_SNAKE_CASE					:       Optional[Any]			)  -> str:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE     =      False
      super().__init__(lowerCamelCase__					,							lowerCamelCase__			)
      __SCREAMING_SNAKE_CASE     =      self.image_processor
 def __call__(		self					:       str					,							__SCREAMING_SNAKE_CASE					:       ImageInput = None					,							__SCREAMING_SNAKE_CASE					:       Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None					,							__SCREAMING_SNAKE_CASE					:       bool = True					,							__SCREAMING_SNAKE_CASE					:       Union[bool, str, PaddingStrategy] = False					,							__SCREAMING_SNAKE_CASE					:       Union[bool, str, TruncationStrategy] = None					,							__SCREAMING_SNAKE_CASE					:       Optional[int] = None					,							__SCREAMING_SNAKE_CASE					:       int = 0					,							__SCREAMING_SNAKE_CASE					:       Optional[int] = None					,							__SCREAMING_SNAKE_CASE					:       Optional[bool] = None					,							__SCREAMING_SNAKE_CASE					:       bool = False					,							__SCREAMING_SNAKE_CASE					:       bool = False					,							__SCREAMING_SNAKE_CASE					:       bool = False					,							__SCREAMING_SNAKE_CASE					:       bool = False					,							__SCREAMING_SNAKE_CASE					:       bool = False					,							__SCREAMING_SNAKE_CASE					:       bool = True					,							__SCREAMING_SNAKE_CASE					:       Optional[Union[str, TensorType]] = None					,							**__SCREAMING_SNAKE_CASE					:       Optional[int]					,							)  -> Optional[Any]:


      """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       UpperCAmelCase__		(		self					:       Any					,							*__SCREAMING_SNAKE_CASE					:       Tuple					,							**__SCREAMING_SNAKE_CASE					:       Optional[Any]			)  -> Dict:


      """simple docstring"""




      return self.tokenizer.batch_decode(*lowerCamelCase__					,							**lowerCamelCase__			)
 def       UpperCAmelCase__		(		self					:       Union[str, Any]					,							*__SCREAMING_SNAKE_CASE					:       List[Any]					,							**__SCREAMING_SNAKE_CASE					:       Dict			)  -> Optional[Any]:


      """simple docstring"""




      return self.tokenizer.decode(*lowerCamelCase__					,							**lowerCamelCase__			)


 @property
 # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
 def       UpperCAmelCase__		(		self					:       Union[str, Any]			)  -> 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"""






def   a_						(					lowerCamelCase					,			lowerCamelCase       ):
				if a < 0 or b < 0:
								raise ValueError('the value of both inputs must be positive'       )

				UpperCAmelCase__             =							str(bin(lowerCamelCase       )       )[2:]  # remove the leading "0b"
				UpperCAmelCase__             =							str(bin(lowerCamelCase       )       )[2:]  # remove the leading "0b"

				UpperCAmelCase__             =							max(len(lowerCamelCase       )					,			len(lowerCamelCase       )       )

				return "0b" + "".join(
				    str(int(char_a == '1' and char_b == '1'       )       )
				    for char_a, char_b in zip(a_binary.zfill(lowerCamelCase       )					,			b_binary.zfill(lowerCamelCase       )       )       )


if __name__ == "__main__":
						import doctest

						doctest.testmod()



