

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__							):


		"""simple docstring"""




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


		def __init__(				self	,       __snake_case	,       __snake_case):
			_UpperCamelCase   :		Optional[Any]			=						False
			super().__init__(lowerCamelCase_	,       lowerCamelCase_)
			_UpperCamelCase   :		List[Any]			=						self.image_processor


		def __call__(				self	,       __snake_case = None	,       __snake_case = None	,       __snake_case = True	,       __snake_case = False	,       __snake_case = None	,       __snake_case = None	,       __snake_case = 0	,       __snake_case = None	,       __snake_case = None	,       __snake_case = False	,       __snake_case = False	,       __snake_case = False	,       __snake_case = False	,       __snake_case = False	,       __snake_case = True	,       __snake_case = None	,       **__snake_case	,       ):
			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   :		Any			=						self.tokenizer
				_UpperCamelCase   :		Any			=						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
			_UpperCamelCase   :		Any			=						self.image_processor(lowerCamelCase_	,       return_tensors=lowerCamelCase_)

			if text is not None:
				_UpperCamelCase   :		Union[str, Any]			=						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:
				_UpperCamelCase   :		Optional[int]			=						None

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

			return encoding_image_processor


		def 		A__					(				self	,       *__snake_case	,       **__snake_case):
			return self.tokenizer.batch_decode(*lowerCamelCase_	,       **lowerCamelCase_)


		def 		A__					(				self	,       *__snake_case	,       **__snake_case):
			return self.tokenizer.decode(*lowerCamelCase_	,       **lowerCamelCase_)






		@property
		def 		A__					(				self):
			_UpperCamelCase   :		List[Any]			=						self.tokenizer.model_input_names
			_UpperCamelCase   :		Any			=						self.image_processor.model_input_names
			return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))







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

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

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
lowerCAmelCase__								=		abspath(join(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 					lowerCamelCase_     (							UpperCAmelCase_							:     Any	)						->				Union[str, Any]:




	'''simple docstring'''




	config.addinivalue_line(
	    'markers'							,       'is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested'	)
	config.addinivalue_line(
	    'markers'							,       'is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested'	)
	config.addinivalue_line('markers'							,       'is_pipeline_test: mark test to run only when pipelines are tested'	)
	config.addinivalue_line('markers'							,       'is_staging_test: mark test to run only in the staging environment'	)
	config.addinivalue_line('markers'							,       'accelerate_tests: mark test that require accelerate'	)
	config.addinivalue_line('markers'							,       'tool_tests: mark the tool tests that are run on their specific schedule'	)






def 					lowerCamelCase_     (							UpperCAmelCase_							:     Optional[int]	)						->				List[Any]:




	'''simple docstring'''




	from transformers.testing_utils import pytest_addoption_shared

	pytest_addoption_shared(UpperCAmelCase_	)






def 					lowerCamelCase_     (							UpperCAmelCase_							:     Any	)						->				List[Any]:




	'''simple docstring'''




	from transformers.testing_utils import pytest_terminal_summary_main

	_UpperCamelCase   :		str			=						terminalreporter.config.getoption('--make-reports'	)
	if make_reports:
		pytest_terminal_summary_main(UpperCAmelCase_							,       id=UpperCAmelCase_	)






def 					lowerCamelCase_     (							UpperCAmelCase_							:     Dict							,       UpperCAmelCase_							:     Dict	)						->				Tuple:




	'''simple docstring'''




	if exitstatus == 5:
		_UpperCamelCase   :		List[Any]			=						0


# Doctest custom flag to ignore output.
lowerCAmelCase__								=		doctest.register_optionflag("""IGNORE_RESULT""")

lowerCAmelCase__								=		doctest.OutputChecker







class 	lowercase    (				_lowercase							):


		"""simple docstring"""




		def 		A__					(				self	,       __snake_case	,       __snake_case	,       __snake_case):
			if IGNORE_RESULT & optionflags:
				return True
			return OutputChecker.check_output(self	,       __snake_case	,       __snake_case	,       __snake_case)

lowerCAmelCase__								=		CustomOutputChecker
lowerCAmelCase__								=		HfDoctestModule







lowerCAmelCase__								=		HfDocTestParser




