




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







						"""simple docstring"""


						_lowerCAmelCase         =       'mock'







						def __init__(  self   :							str				,			*_lowerCamelCase   :							Tuple				,			_lowerCamelCase   :							Union[str, Any]				,			**_lowerCamelCase   :							Dict     ):





											"""simple docstring"""







											super().__init__()
											A_			:  Dict			=				LocalFileSystem(*_lowerCamelCase				,			**_lowerCamelCase     )
											A_			:  Tuple			=				Path(_lowerCamelCase     ).resolve().as_posix() + '''/'''







						def    _a     (  self   :							List[str]				,			_lowerCamelCase   :							Optional[int]				,			*_lowerCamelCase   :							Any				,			**_lowerCamelCase   :							Dict     ):





											"""simple docstring"""







											A_			:  Any			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.mkdir(_lowerCamelCase				,			*_lowerCamelCase				,			**_lowerCamelCase     )







						def    _a     (  self   :							str				,			_lowerCamelCase   :							Optional[Any]				,			*_lowerCamelCase   :							Optional[int]				,			**_lowerCamelCase   :							str     ):





											"""simple docstring"""







											A_			:  str			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.makedirs(_lowerCamelCase				,			*_lowerCamelCase				,			**_lowerCamelCase     )







						def    _a     (  self   :							Dict				,			_lowerCamelCase   :							Optional[int]     ):





											"""simple docstring"""







											A_			:  List[Any]			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.rmdir(_lowerCamelCase     )







						def    _a     (  self   :							Optional[Any]				,			_lowerCamelCase   :							List[Any]				,			_lowerCamelCase   :							Optional[int]=True				,			*_lowerCamelCase   :							Optional[int]				,			**_lowerCamelCase   :							Union[str, Any]     ):





											"""simple docstring"""







											A_			:  Optional[int]			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											A_			:  Any			=				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    _a     (  self   :							int				,			_lowerCamelCase   :							List[str]				,			*_lowerCamelCase   :							Optional[int]				,			**_lowerCamelCase   :							Union[str, Any]     ):





											"""simple docstring"""







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







						def    _a     (  self   :							Optional[Any]				,			_lowerCamelCase   :							int				,			_lowerCamelCase   :							List[Any]				,			*_lowerCamelCase   :							int				,			**_lowerCamelCase   :							Optional[Any]     ):





											"""simple docstring"""







											A_			:  str			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											A_			:  Optional[Any]			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.cp_file(_lowerCamelCase				,			_lowerCamelCase				,			*_lowerCamelCase				,			**_lowerCamelCase     )







						def    _a     (  self   :							Optional[int]				,			_lowerCamelCase   :							Optional[int]				,			*_lowerCamelCase   :							Any				,			**_lowerCamelCase   :							int     ):





											"""simple docstring"""







											A_			:  Dict			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.rm_file(_lowerCamelCase				,			*_lowerCamelCase				,			**_lowerCamelCase     )







						def    _a     (  self   :							Any				,			_lowerCamelCase   :							Optional[int]				,			*_lowerCamelCase   :							Tuple				,			**_lowerCamelCase   :							Optional[Any]     ):





											"""simple docstring"""







											A_			:  Optional[int]			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.rm(_lowerCamelCase				,			*_lowerCamelCase				,			**_lowerCamelCase     )







						def    _a     (  self   :							Optional[int]				,			_lowerCamelCase   :							List[str]				,			*_lowerCamelCase   :							str				,			**_lowerCamelCase   :							Tuple     ):





											"""simple docstring"""







											A_			:  Optional[int]			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs._open(_lowerCamelCase				,			*_lowerCamelCase				,			**_lowerCamelCase     )







						def    _a     (  self   :							List[Any]				,			_lowerCamelCase   :							Any     ):





											"""simple docstring"""







											A_			:  Dict			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.created(_lowerCamelCase     )







						def    _a     (  self   :							Optional[Any]				,			_lowerCamelCase   :							Any     ):





											"""simple docstring"""







											A_			:  Optional[int]			=				posixpath.join(self.local_root_dir				,			self._strip_protocol(_lowerCamelCase     )     )
											return self._fs.modified(_lowerCamelCase     )







						@classmethod
						def    _a     (  cls   :							Optional[Any]				,			_lowerCamelCase   :							Optional[int]     ):





											"""simple docstring"""







											A_			:  Optional[Any]			=				stringify_path(_lowerCamelCase     )
											if path.startswith('''mock://'''     ):
																A_			:  Any			=				path[7:]
											return path






class      UpperCamelCase_  (a__  ):







						"""simple docstring"""


						_lowerCAmelCase         =       'tmp'
						_lowerCAmelCase         =       None







						def __init__(  self   :							str				,			*_lowerCamelCase   :							Union[str, Any]				,			**_lowerCamelCase   :							Dict     ):





											"""simple docstring"""







											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    _a     (  cls   :							List[Any]				,			_lowerCamelCase   :							List[str]     ):





											"""simple docstring"""







											A_			:  Any			=				stringify_path(_lowerCamelCase     )
											if path.startswith('''tmp://'''     ):
																A_			:  str			=				path[6:]
											return path






@pytest.fixture
def     snake_case__     (			) -> int:
					A_			:  Union[str, Any]			=				MockFileSystem
					A_			:  Union[str, Any]			=				TmpDirFileSystem
					yield
					del _fsspec_registry["mock"]
					del _fsspec_registry["tmp"]




@pytest.fixture
def     snake_case__     (			lowerCamelCase__					: Any      ,		lowerCamelCase__					: Tuple      ) -> Dict:
					A_			:  Optional[Any]			=				tmp_path_factory.mktemp('''mockfs'''      )
					return MockFileSystem(local_root_dir=lowerCamelCase__      ,		auto_mkdir=lowerCamelCase__      )





@pytest.fixture
def     snake_case__     (			lowerCamelCase__					: Union[str, Any]      ,		lowerCamelCase__					: List[str]      ) -> Union[str, Any]:
					A_			:  Dict			=				tmp_path_factory.mktemp('''tmpfs'''      )
					with patch.object(lowerCamelCase__      ,		'''tmp_dir'''      ,		lowerCamelCase__      ):
										yield TmpDirFileSystem()









'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


snake_case__ 							=    logging.get_logger(__name__)

snake_case__ 							=    {
    """uw-madison/nystromformer-512""": """https://huggingface.co/uw-madison/nystromformer-512/resolve/main/config.json""",
    # See all Nystromformer models at https://huggingface.co/models?filter=nystromformer
}






class      UpperCamelCase_  (a__  ):







						"""simple docstring"""


						_lowerCAmelCase         =       'nystromformer'







						def __init__(  self   :							Optional[Any]				,			_lowerCamelCase   :							str=30000				,			_lowerCamelCase   :							Optional[Any]=768				,			_lowerCamelCase   :							Optional[Any]=12				,			_lowerCamelCase   :							str=12				,			_lowerCamelCase   :							List[str]=3072				,			_lowerCamelCase   :							Any="gelu_new"				,			_lowerCamelCase   :							List[Any]=0.1				,			_lowerCamelCase   :							List[str]=0.1				,			_lowerCamelCase   :							List[str]=510				,			_lowerCamelCase   :							Optional[Any]=2				,			_lowerCamelCase   :							List[Any]=64				,			_lowerCamelCase   :							str=64				,			_lowerCamelCase   :							str=65				,			_lowerCamelCase   :							List[Any]=False				,			_lowerCamelCase   :							List[Any]=0.02				,			_lowerCamelCase   :							List[Any]=1E-5				,			_lowerCamelCase   :							Dict=1				,			_lowerCamelCase   :							Tuple=0				,			_lowerCamelCase   :							List[str]=2				,			**_lowerCamelCase   :							List[str]				,			):





											"""simple docstring"""







											A_			:  List[Any]			=				vocab_size
											A_			:  Tuple			=				max_position_embeddings
											A_			:  Dict			=				hidden_size
											A_			:  Optional[Any]			=				num_hidden_layers
											A_			:  Dict			=				num_attention_heads
											A_			:  Tuple			=				intermediate_size
											A_			:  Dict			=				hidden_act
											A_			:  List[Any]			=				hidden_dropout_prob
											A_			:  str			=				attention_probs_dropout_prob
											A_			:  Optional[Any]			=				initializer_range
											A_			:  List[str]			=				type_vocab_size
											A_			:  List[Any]			=				segment_means_seq_len
											A_			:  Dict			=				num_landmarks
											A_			:  int			=				conv_kernel_size
											A_			:  Optional[Any]			=				inv_coeff_init_option
											A_			:  str			=				layer_norm_eps
											super().__init__(pad_token_id=_lowerCamelCase				,			bos_token_id=_lowerCamelCase				,			eos_token_id=_lowerCamelCase				,			**_lowerCamelCase     )



