

# 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.
_UpperCAmelCase						:  Optional[Any]									=			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__ ):







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







							'''simple docstring'''






							from transformers.testing_utils import pytest_addoption_shared

							pytest_addoption_shared(UpperCamelCase__ )





def    __lowerCamelCase      (					UpperCamelCase__ ):







							'''simple docstring'''






							from transformers.testing_utils import pytest_terminal_summary_main

							snake_case_     							=       terminalreporter.config.getoption('--make-reports' )
							if make_reports:
														pytest_terminal_summary_main(UpperCamelCase__  ,				id=UpperCamelCase__ )





def    __lowerCamelCase      (					UpperCamelCase__  ,				UpperCamelCase__ ):







							'''simple docstring'''






							if exitstatus == 5:
														snake_case_     							=       0


# Doctest custom flag to ignore output.
_UpperCAmelCase						:  Dict									=			doctest.register_optionflag("""IGNORE_RESULT""")

_UpperCAmelCase						:  Dict									=			doctest.OutputChecker







class 					lowercase							(			lowercase_     ):




				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			)



_UpperCAmelCase						:  str									=			CustomOutputChecker
_UpperCAmelCase						:  List[str]									=			HfDoctestModule


_UpperCAmelCase						:  Optional[Any]									=			HfDocTestParser







from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class 					lowercase							(			lowercase_     ):
				__SCREAMING_SNAKE_CASE   :					Union[str, Any]			     =     ['''image_processor''', '''tokenizer''']
				__SCREAMING_SNAKE_CASE   :					Tuple			     =     '''AutoImageProcessor'''
				__SCREAMING_SNAKE_CASE   :					Dict			     =     '''AutoTokenizer'''




				def __init__(   self ,  snake_case ,  snake_case			):
											super().__init__(snake_case ,  snake_case			)
											snake_case_     							=       self.image_processor




				def __call__(   self ,  snake_case=None ,  snake_case=None ,  snake_case=None ,  **snake_case			):

											if text is None and images is None:
																		raise ValueError('You have to specify either text or images. Both cannot be none.'			)

											if text is not None:
																		snake_case_     							=       self.tokenizer(snake_case ,  return_tensors=snake_case ,  **snake_case			)

											if images is not None:
																		snake_case_     							=       self.image_processor(snake_case ,  return_tensors=snake_case ,  **snake_case			)

											if text is not None and images is not None:
																		snake_case_     							=       image_features.pixel_values
																		return encoding
											elif text is not None:
																		return encoding
											else:
																		return BatchEncoding(data=dict(**snake_case			) ,  tensor_type=snake_case			)




				def        a				(   self ,  *snake_case ,  **snake_case			):
											return self.tokenizer.batch_decode(*snake_case ,  **snake_case			)




				def        a				(   self ,  *snake_case ,  **snake_case			):
											return self.tokenizer.decode(*snake_case ,  **snake_case			)




				@property
				def        a				(   self			):
											return ["input_ids", "attention_mask", "pixel_values"]




