


'''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      (      lowercase	):

						"""simple docstring"""






						_UpperCAmelCase		:					Any      	="mock"






						def __init__(     self       :			Dict   ,     *lowerCAmelCase       :			Optional[Any]   ,     lowerCAmelCase       :			List[str]   ,     **lowerCAmelCase       :			Any  ):
													super().__init__()
													A_ 						=		LocalFileSystem(*lowerCAmelCase   ,     **lowerCAmelCase  )
													A_ 						=		Path(lowerCAmelCase  ).resolve().as_posix() + "/"






						def 							_UpperCAmelCase					(     self       :			Any   ,     lowerCAmelCase       :			Optional[Any]   ,     *lowerCAmelCase       :			Dict   ,     **lowerCAmelCase       :			Any  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.mkdir(lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			Union[str, Any]   ,     lowerCAmelCase       :			Tuple   ,     *lowerCAmelCase       :			Optional[Any]   ,     **lowerCAmelCase       :			Any  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.makedirs(lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			str   ,     lowerCAmelCase       :			int  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.rmdir(lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			Dict   ,     lowerCAmelCase       :			Any   ,     lowerCAmelCase       :			Dict=True   ,     *lowerCAmelCase       :			Dict   ,     **lowerCAmelCase       :			str  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													A_ 						=		self._fs.ls(lowerCAmelCase   ,     detail=lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )
													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 							_UpperCAmelCase					(     self       :			Any   ,     lowerCAmelCase       :			Optional[Any]   ,     *lowerCAmelCase       :			Optional[int]   ,     **lowerCAmelCase       :			str  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													A_ 						=		dict(self._fs.info(lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )  )
													A_ 						=		out["name"][len(self.local_root_dir  ) :]
													return out






						def 							_UpperCAmelCase					(     self       :			Optional[int]   ,     lowerCAmelCase       :			Tuple   ,     lowerCAmelCase       :			Any   ,     *lowerCAmelCase       :			Optional[Any]   ,     **lowerCAmelCase       :			Any  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.cp_file(lowerCAmelCase   ,     lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			List[Any]   ,     lowerCAmelCase       :			Any   ,     *lowerCAmelCase       :			List[str]   ,     **lowerCAmelCase       :			Optional[int]  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.rm_file(lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			List[str]   ,     lowerCAmelCase       :			Any   ,     *lowerCAmelCase       :			Optional[int]   ,     **lowerCAmelCase       :			Union[str, Any]  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.rm(lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			Optional[int]   ,     lowerCAmelCase       :			Optional[Any]   ,     *lowerCAmelCase       :			Tuple   ,     **lowerCAmelCase       :			Dict  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs._open(lowerCAmelCase   ,     *lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			str   ,     lowerCAmelCase       :			str  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.created(lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			int   ,     lowerCAmelCase       :			Any  ):
													A_ 						=		posixpath.join(self.local_root_dir   ,     self._strip_protocol(lowerCAmelCase  )  )
													return self._fs.modified(lowerCAmelCase  )






						@classmethod
						def 							_UpperCAmelCase					(     cls       :			Any   ,     lowerCAmelCase       :			List[Any]  ):
													A_ 						=		stringify_path(lowerCAmelCase  )
													if path.startswith("mock://"  ):
																				A_ 						=		path[7:]
													return path






class 				__lowerCAmelCase      (      lowercase	):

						"""simple docstring"""






						_UpperCAmelCase		:					Optional[Any]      	="tmp"
						_UpperCAmelCase		:					Optional[int]      	=None






						def __init__(     self       :			List[str]   ,     *lowerCAmelCase       :			Union[str, Any]   ,     **lowerCAmelCase       :			int  ):
													assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
													super().__init__(*lowerCAmelCase   ,     **lowerCAmelCase   ,     local_root_dir=self.tmp_dir   ,     auto_mkdir=lowerCAmelCase  )






						@classmethod
						def 							_UpperCAmelCase					(     cls       :			Optional[int]   ,     lowerCAmelCase       :			Optional[Any]  ):
													A_ 						=		stringify_path(lowerCAmelCase  )
													if path.startswith("tmp://"  ):
																				A_ 						=		path[6:]
													return path







@pytest.fixture
def 			a_							(  ):
							A_ 						=		MockFileSystem
							A_ 						=		TmpDirFileSystem
							yield
							del _fsspec_registry["mock"]
							del _fsspec_registry["tmp"]







@pytest.fixture
def 			a_							(  UpperCamelCase_	,     UpperCamelCase_   ):
							A_ 						=		tmp_path_factory.mktemp("mockfs"   )
							return MockFileSystem(local_root_dir=UpperCamelCase_	,     auto_mkdir=UpperCamelCase_   )







@pytest.fixture
def 			a_							(  UpperCamelCase_	,     UpperCamelCase_   ):
							A_ 						=		tmp_path_factory.mktemp("tmpfs"   )
							with patch.object(UpperCamelCase_	,     "tmp_dir"	,     UpperCamelCase_   ):
														yield TmpDirFileSystem()









'''simple docstring'''
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding






class 				__lowerCAmelCase      (      lowercase	):

						"""simple docstring"""






						_UpperCAmelCase		:					int      	=["image_processor", "tokenizer"]
						_UpperCAmelCase		:					Dict      	="EfficientNetImageProcessor"
						_UpperCAmelCase		:					Union[str, Any]      	=("BertTokenizer", "BertTokenizerFast")






						def __init__(     self       :			List[Any]   ,     lowerCAmelCase       :			Any   ,     lowerCAmelCase       :			int  ):
													super().__init__(lowerCAmelCase   ,     lowerCAmelCase  )






						def __call__(     self       :			str   ,     lowerCAmelCase       :			Tuple=None   ,     lowerCAmelCase       :			List[Any]=None   ,     lowerCAmelCase       :			Optional[int]="max_length"   ,     lowerCAmelCase       :			Tuple=64   ,     lowerCAmelCase       :			Dict=None   ,     **lowerCAmelCase       :			Any  ):
													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:
																				A_ 						=		self.tokenizer(
																				    lowerCAmelCase   ,     padding=lowerCAmelCase   ,     max_length=lowerCAmelCase   ,     return_tensors=lowerCAmelCase   ,     **lowerCAmelCase  )

													if images is not None:
																				A_ 						=		self.image_processor(lowerCAmelCase   ,     return_tensors=lowerCAmelCase   ,     **lowerCAmelCase  )

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






						def 							_UpperCAmelCase					(     self       :			List[str]   ,     *lowerCAmelCase       :			Optional[int]   ,     **lowerCAmelCase       :			str  ):
													return self.tokenizer.batch_decode(*lowerCAmelCase   ,     **lowerCAmelCase  )






						def 							_UpperCAmelCase					(     self       :			str   ,     *lowerCAmelCase       :			Any   ,     **lowerCAmelCase       :			Dict  ):
													return self.tokenizer.decode(*lowerCAmelCase   ,     **lowerCAmelCase  )






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





