

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



class       __snake_case  (    lowerCAmelCase__       ):
  __lowerCAmelCase     :	Optional[Any]						 =  ['image_processor', 'tokenizer']
  __lowerCAmelCase     :	List[str]						 =  'AutoImageProcessor'
  __lowerCAmelCase     :	List[Any]						 =  'AutoTokenizer'

  def __init__(					self						,		_A						,		_A):
      super().__init__(_A						,		_A)
      SCREAMING_SNAKE_CASE_									=						self.image_processor

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

      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:
          SCREAMING_SNAKE_CASE_									=						self.tokenizer(_A						,		return_tensors=_A						,		**_A)

      if images is not None:
          SCREAMING_SNAKE_CASE_									=						self.image_processor(_A						,		return_tensors=_A						,		**_A)

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

  def 						lowerCAmelCase__     (					self						,		*_A						,		**_A):
      return self.tokenizer.batch_decode(*_A						,		**_A)

  def 						lowerCAmelCase__     (					self						,		*_A						,		**_A):
      return self.tokenizer.decode(*_A						,		**_A)


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





import pytest

import datasets


# Import fixture modules as plugins
UpperCamelCase__  :      Union[str, Any]			=    ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]


def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Optional[Any] ,   _SCREAMING_SNAKE_CASE					:		Dict       ):





    """simple docstring"""


    for item in items:
        if any(marker in item.keywords for marker in ['integration', 'unit']       ):
            continue
        item.add_marker(pytest.mark.unit       )


def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Optional[int]       ):





    """simple docstring"""


    config.addinivalue_line('markers' ,   'torchaudio_latest: mark test to run with torchaudio>=0.12'       )


@pytest.fixture(autouse=_SCREAMING_SNAKE_CASE       )
def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Any ,   _SCREAMING_SNAKE_CASE					:		str       ):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_									=						tmp_path_factory.getbasetemp() / 'cache'
    SCREAMING_SNAKE_CASE_									=						test_hf_cache_home / 'datasets'
    SCREAMING_SNAKE_CASE_									=						test_hf_cache_home / 'metrics'
    SCREAMING_SNAKE_CASE_									=						test_hf_cache_home / 'modules'
    monkeypatch.setattr('datasets.config.HF_DATASETS_CACHE' ,   str(_SCREAMING_SNAKE_CASE       )       )
    monkeypatch.setattr('datasets.config.HF_METRICS_CACHE' ,   str(_SCREAMING_SNAKE_CASE       )       )
    monkeypatch.setattr('datasets.config.HF_MODULES_CACHE' ,   str(_SCREAMING_SNAKE_CASE       )       )
    SCREAMING_SNAKE_CASE_									=						test_hf_datasets_cache / 'downloads'
    monkeypatch.setattr('datasets.config.DOWNLOADED_DATASETS_PATH' ,   str(_SCREAMING_SNAKE_CASE       )       )
    SCREAMING_SNAKE_CASE_									=						test_hf_datasets_cache / 'downloads' / 'extracted'
    monkeypatch.setattr('datasets.config.EXTRACTED_DATASETS_PATH' ,   str(_SCREAMING_SNAKE_CASE       )       )


@pytest.fixture(autouse=_SCREAMING_SNAKE_CASE ,   scope='session'       )
def 					_UpperCAmelCase       (  ):





    """simple docstring"""


    datasets.disable_progress_bar()


@pytest.fixture(autouse=_SCREAMING_SNAKE_CASE       )
def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Any       ):





    """simple docstring"""


    monkeypatch.setattr('datasets.config.HF_UPDATE_DOWNLOAD_COUNTS' ,   _SCREAMING_SNAKE_CASE       )





@pytest.fixture
def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Tuple       ):





    """simple docstring"""


    monkeypatch.setattr('sqlalchemy.util.deprecations.SILENCE_UBER_WARNING' ,   _SCREAMING_SNAKE_CASE       )


