


"""simple docstring"""


import importlib
import shutil
import threading
import warnings
from typing import List

import fsspec
import fsspec.asyn

from . import compression
from .hffilesystem import HfFileSystem


a_       							=    importlib.util.find_spec("s3fs") is not None

if _has_safs:
		from .safilesystem import SaFileSystem  # noqa: F401

a_       							=    [
    compression.BzaFileSystem,
    compression.GzipFileSystem,
    compression.LzaFileSystem,
    compression.XzFileSystem,
    compression.ZstdFileSystem,
]

# Register custom filesystems
for fs_class in COMPRESSION_FILESYSTEMS + [HfFileSystem]:
		if fs_class.protocol in fsspec.registry and fsspec.registry[fs_class.protocol] is not fs_class:
				warnings.warn(f'''A filesystem protocol was already set for {fs_class.protocol} and will be overwritten.''')
		fsspec.register_implementation(fs_class.protocol, fs_class, clobber=True)






def      a__ (				__lowercase   )	->	str:
				if "://" in dataset_path:
								_A					  =			dataset_path.split("://"   )[1]
				return dataset_path






def      a__ (				__lowercase   )	->	bool:
				if fs is not None and fs.protocol != "file":
								return True
				else:
								return False






def      a__ (				__lowercase     ,			__lowercase     ,			__lowercase   )	->	Optional[Any]:
				_A					  =			not is_remote_filesystem(__lowercase   )
				if is_local:
								# LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
								shutil.move(fs._strip_protocol(__lowercase   )     ,			fs._strip_protocol(__lowercase   )   )
				else:
								fs.mv(__lowercase     ,			__lowercase     ,			recursive=__lowercase   )






def      a__ (				)	->	None:
				if hasattr(fsspec.asyn     ,			"reset_lock"   ):
								# for future fsspec>2022.05.0
								fsspec.asyn.reset_lock()
				else:
								_A					  =			None
								_A					  =			None
								_A					  =			threading.Lock()



"""simple docstring"""


import numpy as np






def      a__ (				__lowercase     ,			__lowercase   )	->	np.ndarray:
				return np.where(vector > 0     ,			__lowercase     ,			(alpha * (np.exp(__lowercase   ) - 1))   )


if __name__ == "__main__":
		import doctest

		doctest.testmod()