



'''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


UpperCAmelCase     		=   importlib.util.find_spec('s3fs') is not None

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

UpperCAmelCase     		=   [
    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 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						str:







	"""simple docstring"""
	if "://" in dataset_path:
		lowerCAmelCase   =     dataset_path.split("""://"""							)[1]
	return dataset_path






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						fsspec.AbstractFileSystem							)      ->						bool:







	"""simple docstring"""
	if fs is not None and fs.protocol != "file":
		return True
	else:
		return False






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						fsspec.AbstractFileSystem							,		_SCREAMING_SNAKE_CASE					:						str							,		_SCREAMING_SNAKE_CASE					:						str							)      ->						str:







	"""simple docstring"""
	lowerCAmelCase   =     not is_remote_filesystem(_SCREAMING_SNAKE_CASE							)
	if is_local:
		# LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
		shutil.move(fs._strip_protocol(_SCREAMING_SNAKE_CASE							)							,		fs._strip_protocol(_SCREAMING_SNAKE_CASE							)							)
	else:
		fs.mv(_SCREAMING_SNAKE_CASE							,		_SCREAMING_SNAKE_CASE							,		recursive=_SCREAMING_SNAKE_CASE							)






def 		_snake_case		( )      ->						None:







	"""simple docstring"""
	if hasattr(fsspec.asyn							,		"""reset_lock"""							):
		# for future fsspec>2022.05.0
		fsspec.asyn.reset_lock()
	else:
		lowerCAmelCase   =     None
		lowerCAmelCase   =     None
		lowerCAmelCase   =     threading.Lock()




'''simple docstring'''

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


UpperCAmelCase     		=   logging.get_logger(__name__)

class __snake_case(				_lowerCAmelCase ):


						'''simple docstring'''



						UpperCAmelCase							:   Optional[int]									=		"timm_backbone"


						def __init__( self     ,	A_=None     ,	A_=3     ,	A_=True     ,	A_=True     ,	A_=None     ,	**A_     ,	)     ->     int:
							super().__init__(**A_				)
							lowerCAmelCase   =     backbone
							lowerCAmelCase   =     num_channels
							lowerCAmelCase   =     features_only
							lowerCAmelCase   =     use_pretrained_backbone
							lowerCAmelCase   =     True
							lowerCAmelCase   =     out_indices if out_indices is not None else (-1,)