






'''simple docstring'''






import os
from typing import List, Optional, Union

from ...image_processing_utils import BatchFeature
from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
from ..auto import AutoTokenizer




class a_    (    UpperCamelCase_							):
   _snake_case        =							["""image_processor""", """tokenizer"""]
   _snake_case        =							"""BlipImageProcessor"""
   _snake_case        =							"""AutoTokenizer"""







   def __init__(self					,   __a					,   __a					,   __a)			->      Optional[Any]:
      """simple docstring"""






      super().__init__(__a					,   __a)

      # add QFormer tokenizer
      __snake_case				:      Optional[int]     							= qformer_tokenizer







   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					,   )			->      BatchFeature:
      """simple docstring"""






      if images is None and text is None:
         raise ValueError('You have to specify at least images or text.')

      __snake_case				:      Dict     							= BatchFeature()

      if text is not None:
         __snake_case				:      Optional[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					,   )
         encoding.update(__a)
         __snake_case				:      Dict     							= self.qformer_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					,   )
         __snake_case				:      Optional[Any]     							= qformer_text_encoding.pop('input_ids')
         __snake_case				:      List[str]     							= qformer_text_encoding.pop('attention_mask')

      if images is not None:
         __snake_case				:      Optional[int]     							= self.image_processor(__a					,   return_tensors=__a)
         encoding.update(__a)

      return encoding







   def     SCREAMING_SNAKE_CASE__					(self					,   *__a					,   **__a)			->      Dict:
      """simple docstring"""






      return self.tokenizer.batch_decode(*__a					,   **__a)







   def     SCREAMING_SNAKE_CASE__					(self					,   *__a					,   **__a)			->      Optional[Any]:
      """simple docstring"""






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







   @property
   # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
   def     SCREAMING_SNAKE_CASE__					(self)			->      str:
      """simple docstring"""






      __snake_case				:      Union[str, Any]     							= self.tokenizer.model_input_names
      __snake_case				:      Tuple     							= self.image_processor.model_input_names
      return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   **__a)			->      List[Any]:
      """simple docstring"""






      if os.path.isfile(__a):
         raise ValueError(F"""Provided path ({save_directory}) should be a directory, not a file""")
      os.makedirs(__a					,   exist_ok=__a)
      __snake_case				:      str     							= os.path.join(__a					,   'qformer_tokenizer')
      self.qformer_tokenizer.save_pretrained(__a)
      return super().save_pretrained(__a					,   **__a)







   @classmethod
   def     SCREAMING_SNAKE_CASE__					(cls					,   __a					,   **__a)			->      int:
      """simple docstring"""






      __snake_case				:      int     							= AutoTokenizer.from_pretrained(__a					,   subfolder='qformer_tokenizer')
      __snake_case				:      Dict     							= cls._get_arguments_from_pretrained(__a					,   **__a)
      args.append(__a)
      return cls(*__a)







'''simple docstring'''






# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
__A    	=   abspath(join(dirname(dirname(__file__)), '''src'''))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='''ignore''', category=FutureWarning)




def        _SCREAMING_SNAKE_CASE  (				A  :       Tuple  )    -> str:







   """simple docstring"""
   from diffusers.utils.testing_utils import pytest_addoption_shared

   pytest_addoption_shared(A  )





def        _SCREAMING_SNAKE_CASE  (				A  :       int  )    -> Optional[int]:







   """simple docstring"""
   from diffusers.utils.testing_utils import pytest_terminal_summary_main

   __snake_case				:      Any     							= terminalreporter.config.getoption('--make-reports'  )
   if make_reports:
      pytest_terminal_summary_main(A  ,		id=A  )