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


class 			UpperCamelCase_				(  lowerCamelCase_     ):




      '''simple docstring'''







      a		:Dict						 =      ['image_processor', 'tokenizer']
      a		:int						 =      'EfficientNetImageProcessor'
      a		:Tuple						 =      ('BertTokenizer', 'BertTokenizerFast')







      def __init__( self					,					_UpperCAmelCase					,					_UpperCAmelCase):
            super().__init__(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE)







      def __call__( self					,					_UpperCAmelCase=None					,					_UpperCAmelCase=None					,					_UpperCAmelCase="max_length"					,					_UpperCAmelCase=64					,					_UpperCAmelCase=None					,					**_UpperCAmelCase):





            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:
                  lowerCAmelCase_						=      self.tokenizer(
                      __SCREAMING_SNAKE_CASE					,					padding=__SCREAMING_SNAKE_CASE					,					max_length=__SCREAMING_SNAKE_CASE					,					return_tensors=__SCREAMING_SNAKE_CASE					,					**__SCREAMING_SNAKE_CASE)

            if images is not None:
                  lowerCAmelCase_						=      self.image_processor(__SCREAMING_SNAKE_CASE					,					return_tensors=__SCREAMING_SNAKE_CASE					,					**__SCREAMING_SNAKE_CASE)

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







      def lowercase__		( self					,					*_UpperCAmelCase					,					**_UpperCAmelCase):
            return self.tokenizer.batch_decode(*__SCREAMING_SNAKE_CASE					,					**__SCREAMING_SNAKE_CASE)







      def lowercase__		( self					,					*_UpperCAmelCase					,					**_UpperCAmelCase):
            return self.tokenizer.decode(*__SCREAMING_SNAKE_CASE					,					**__SCREAMING_SNAKE_CASE)







      @property
      def lowercase__		( self):
            lowerCAmelCase_						=      self.tokenizer.model_input_names
            lowerCAmelCase_						=      self.image_processor.model_input_names
            return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))





'''simple docstring'''







import posixpath
from pathlib import Path
from unittest.mock import patch

import pytest
from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
from fsspec.registry import _registry as _fsspec_registry






class 					lowerCAmelCase__  (    lowerCamelCase_	):
					lowerCAmelCase_	  =	'''mock'''






					def __init__(  self							,				*__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											super().__init__()
											lowercase_      :	int						=			LocalFileSystem(*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)
											lowercase_      :	Tuple						=			Path(__SCREAMING_SNAKE_CASE						).resolve().as_posix() + '''/'''






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	List[str]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.mkdir(__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Optional[int]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.makedirs(__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Any						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.rmdir(__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE=True							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	str						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											lowercase_      :	Union[str, Any]						=			self._fs.ls(__SCREAMING_SNAKE_CASE							,				detail=__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)
											if detail:
																	return [{**info, "name": info["name"][len(self.local_root_dir						) :]} for info in out]
											else:
																	return [name[len(self.local_root_dir						) :] for name in out]






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Optional[int]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											lowercase_      :	Optional[Any]						=			dict(self._fs.info(__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)						)
											lowercase_      :	Dict						=			out['''name'''][len(self.local_root_dir						) :]
											return out






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	List[str]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											lowercase_      :	str						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.cp_file(__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	List[Any]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.rm_file(__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Union[str, Any]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.rm(__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Union[str, Any]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs._open(__SCREAMING_SNAKE_CASE							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Dict						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.created(__SCREAMING_SNAKE_CASE						)






					def       _snake_case       (  self							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Optional[Any]						=			posixpath.join(self.local_root_dir							,				self._strip_protocol(__SCREAMING_SNAKE_CASE						)						)
											return self._fs.modified(__SCREAMING_SNAKE_CASE						)






					@classmethod
					def       _snake_case       (  cls							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	Optional[Any]						=			stringify_path(__SCREAMING_SNAKE_CASE						)
											if path.startswith('''mock://'''						):
																	lowercase_      :	int						=			path[7:]
											return path







class 					lowerCAmelCase__  (    lowerCamelCase_	):
					lowerCAmelCase_	  =	'''tmp'''
					lowerCAmelCase_	  =	None






					def __init__(  self							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
											super().__init__(*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE							,				local_root_dir=self.tmp_dir							,				auto_mkdir=__SCREAMING_SNAKE_CASE						)






					@classmethod
					def       _snake_case       (  cls							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											lowercase_      :	str						=			stringify_path(__SCREAMING_SNAKE_CASE						)
											if path.startswith('''tmp://'''						):
																	lowercase_      :	Union[str, Any]						=			path[6:]
											return path







@pytest.fixture
def    snake_case_						(							):



						"""simple docstring"""





						lowercase_      :	List[Any]						=			MockFileSystem
						lowercase_      :	Tuple						=			TmpDirFileSystem
						yield
						del _fsspec_registry["mock"]
						del _fsspec_registry["tmp"]
@pytest.fixture
def    snake_case_						(							__SCREAMING_SNAKE_CASE   :					List[Any] , __SCREAMING_SNAKE_CASE   :					List[Any]				):



						"""simple docstring"""





						lowercase_      :	List[str]						=			tmp_path_factory.mktemp('''mockfs'''				)
						return MockFileSystem(local_root_dir=__SCREAMING_SNAKE_CASE , auto_mkdir=__SCREAMING_SNAKE_CASE				)




@pytest.fixture
def    snake_case_						(							__SCREAMING_SNAKE_CASE   :					Union[str, Any] , __SCREAMING_SNAKE_CASE   :					Any				):



						"""simple docstring"""





						lowercase_      :	Union[str, Any]						=			tmp_path_factory.mktemp('''tmpfs'''				)
						with patch.object(__SCREAMING_SNAKE_CASE , '''tmp_dir''' , __SCREAMING_SNAKE_CASE				):
												yield TmpDirFileSystem()



