




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__ :   List[Any]						=							importlib.util.find_spec('''s3fs''') is not None

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

UpperCamelCase__ :   List[compression.BaseCompressedFileFileSystem]						=							[
    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        __UpperCAmelCase						(							lowerCamelCase_ :     str  )       ->  str:







			"""simple docstring"""





			if "://" in dataset_path:
						SCREAMING_SNAKE_CASE_   : Any					  =      dataset_path.split('://'  )[1]
			return dataset_path





def        __UpperCAmelCase						(							lowerCamelCase_ :     fsspec.AbstractFileSystem  )       ->  bool:







			"""simple docstring"""





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





def        __UpperCAmelCase						(							lowerCamelCase_ :     fsspec.AbstractFileSystem  ,							lowerCamelCase_ :     str  ,							lowerCamelCase_ :     str  )       ->  str:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Optional[int]					  =      not is_remote_filesystem(lowerCamelCase_  )
			if is_local:
						# LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
						shutil.move(fs._strip_protocol(lowerCamelCase_  )  ,							fs._strip_protocol(lowerCamelCase_  )  )
			else:
						fs.mv(lowerCamelCase_  ,							lowerCamelCase_  ,							recursive=lowerCamelCase_  )





def        __UpperCAmelCase						(							)       ->  None:







			"""simple docstring"""





			if hasattr(fsspec.asyn  ,							'reset_lock'  ):
						# for future fsspec>2022.05.0
						fsspec.asyn.reset_lock()
			else:
						SCREAMING_SNAKE_CASE_   : Any					  =      None
						SCREAMING_SNAKE_CASE_   : Dict					  =      None
						SCREAMING_SNAKE_CASE_   : List[str]					  =      threading.Lock()









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCamelCase__ :   Optional[Any]						=							{
    '''configuration_whisper''': ['''WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''WhisperConfig''', '''WhisperOnnxConfig'''],
    '''feature_extraction_whisper''': ['''WhisperFeatureExtractor'''],
    '''processing_whisper''': ['''WhisperProcessor'''],
    '''tokenization_whisper''': ['''WhisperTokenizer'''],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__ :   str						=							['''WhisperTokenizerFast''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__ :   List[Any]						=							[
						    '''WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''WhisperForConditionalGeneration''',
						    '''WhisperModel''',
						    '''WhisperPreTrainedModel''',
						    '''WhisperForAudioClassification''',
						]

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__ :   Tuple						=							[
						    '''TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TFWhisperForConditionalGeneration''',
						    '''TFWhisperModel''',
						    '''TFWhisperPreTrainedModel''',
						]

try:
						if not is_flax_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__ :   List[str]						=							[
						    '''FlaxWhisperForConditionalGeneration''',
						    '''FlaxWhisperModel''',
						    '''FlaxWhisperPreTrainedModel''',
						    '''FlaxWhisperForAudioClassification''',
						]


if TYPE_CHECKING:
						from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
						from .feature_extraction_whisper import WhisperFeatureExtractor
						from .processing_whisper import WhisperProcessor
						from .tokenization_whisper import WhisperTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_whisper_fast import WhisperTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_whisper import (
												    WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    WhisperForAudioClassification,
												    WhisperForConditionalGeneration,
												    WhisperModel,
												    WhisperPreTrainedModel,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_whisper import (
												    TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFWhisperForConditionalGeneration,
												    TFWhisperModel,
												    TFWhisperPreTrainedModel,
												)

						try:
												if not is_flax_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_flax_whisper import (
												    FlaxWhisperForAudioClassification,
												    FlaxWhisperForConditionalGeneration,
												    FlaxWhisperModel,
												    FlaxWhisperPreTrainedModel,
												)

else:
						import sys

						UpperCamelCase__ :   Optional[Any]						=							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



