






import os
from typing import Optional

import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE




class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						Optional[Any]										=''''''
       a							:						str										=(
           None  # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
       )
       a							:						str										=None  # compression type in fsspec. ex: "gzip"
       a							:						str										=None  # extension of the filename to strip. ex: "".gz" to get file.txt from file.txt.gz





       def __init__(   self    ,     _lowerCamelCase = ""    ,     _lowerCamelCase = None    ,     _lowerCamelCase = None    ,     **_lowerCamelCase				):
         super().__init__(self    ,     **_lowerCamelCase				)
         # always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
         UpperCamelCase_:   Union[str, Any]        =							fsspec.open(
             _lowerCamelCase    ,     mode='rb'    ,     protocol=_lowerCamelCase    ,     compression=self.compression    ,     client_kwargs={
                 'requote_redirect_url': False,  # see https://github.com/huggingface/datasets/pull/5459
                 'trust_env': True,  # Enable reading proxy env variables.
                 **(target_options or {}).pop('client_kwargs'    ,     {}				),  # To avoid issues if it was already passed.
             }    ,     **(target_options or {})    ,     )
         UpperCamelCase_:   Optional[Any]        =							os.path.basename(self.file.path.split('::'				)[0]				)
         UpperCamelCase_:   Union[str, Any]        =							(
             self.compressed_name[: self.compressed_name.rindex('.'				)]
             if '.' in self.compressed_name
             else self.compressed_name
         )
         UpperCamelCase_:   List[Any]        =							None





       @classmethod
       def      _a       (   cls    ,     _lowerCamelCase				):
         # compressed file paths are always relative to the archive root
         return super()._strip_protocol(_lowerCamelCase				).lstrip('/'				)





       def      _a       (   self				):
         if self.dir_cache is None:
           UpperCamelCase_:   Any        =							{**self.file.fs.info(self.file.path				), 'name': self.uncompressed_name}
           UpperCamelCase_:   Tuple        =							{f['name']: f}





       def      _a       (   self    ,     _lowerCamelCase				):
         return self.file.open().read()





       def      _a       (   self    ,     _lowerCamelCase    ,     _lowerCamelCase = "rb"    ,     _lowerCamelCase=None    ,     _lowerCamelCase=True    ,     _lowerCamelCase=None    ,     **_lowerCamelCase    ,     ):
         UpperCamelCase_:   Union[str, Any]        =							self._strip_protocol(_lowerCamelCase				)
         if mode != "rb":
           raise ValueError(f'''Tried to read with mode {mode} on file {self.file.path} opened with mode \'rb\''''				)
         return self.file.open()







class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						int										='''bz2'''
       a							:						Union[str, Any]										='''bz2'''
       a							:						Optional[Any]										='''.bz2'''







class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						List[Any]										='''gzip'''
       a							:						List[str]										='''gzip'''
       a							:						Any										='''.gz'''







class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						List[Any]										='''lz4'''
       a							:						int										='''lz4'''
       a							:						Union[str, Any]										='''.lz4'''







class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						Optional[Any]										='''xz'''
       a							:						int										='''xz'''
       a							:						Union[str, Any]										='''.xz'''







class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						List[Any]										='''zstd'''
       a							:						List[Any]										='''zstd'''
       a							:						List[str]										='''.zst'''





       def __init__(   self    ,     _lowerCamelCase    ,     _lowerCamelCase = "rb"    ,     _lowerCamelCase = None    ,     _lowerCamelCase = None    ,     _lowerCamelCase = DEFAULT_BLOCK_SIZE    ,     **_lowerCamelCase    ,     ):
         super().__init__(
             fo=_lowerCamelCase    ,     mode=_lowerCamelCase    ,     target_protocol=_lowerCamelCase    ,     target_options=_lowerCamelCase    ,     block_size=_lowerCamelCase    ,     **_lowerCamelCase    ,     )
         # We need to wrap the zstd decompressor to avoid this error in fsspec==2021.7.0 and zstandard==0.15.2:
         #
         # File "/Users/user/.virtualenvs/hf-datasets/lib/python3.7/site-packages/fsspec/core.py", line 145, in open
         #     out.close = close
         # AttributeError: 'zstd.ZstdDecompressionReader' object attribute 'close' is read-only
         #
         # see https://github.com/intake/filesystem_spec/issues/725
         UpperCamelCase_:   str        =							self.file.__enter__




         class 							_lowerCAmelCase:





                """simple docstring"""







                def __init__(   self    ,     _lowerCamelCase				):
                  UpperCamelCase_:   Any        =							file_





                def __enter__(   self				):
                  self._file.__enter__()
                  return self





                def __exit__(   self    ,     *_lowerCamelCase    ,     **_lowerCamelCase				):
                  self._file.__exit__(*_lowerCamelCase    ,     **_lowerCamelCase				)





                def __iter__(   self				):
                  return iter(self._file				)





                def      _a       (   self				):
                  return next(self._file				)





                def __getattr__(   self    ,     _lowerCamelCase				):
                  return getattr(self._file    ,     _lowerCamelCase				)

         def fixed_enter(*_lowerCamelCase    ,     **_lowerCamelCase				):
           return WrappedFile(_enter(*_lowerCamelCase    ,     **_lowerCamelCase				)				)

         UpperCamelCase_:   Tuple        =							fixed_enter



'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available


__A   :    str											= {
    "configuration_audio_spectrogram_transformer": [
        "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "ASTConfig",
    ]
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __A   :    List[str]											= [
      "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "ASTForAudioClassification",
      "ASTModel",
      "ASTPreTrainedModel",
  ]

try:
  if not is_speech_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __A   :    Union[str, Any]											= ["ASTFeatureExtractor"]

if TYPE_CHECKING:
  from .configuration_audio_spectrogram_transformer import (
      AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
      ASTConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_audio_spectrogram_transformer import (
        AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        ASTForAudioClassification,
        ASTModel,
        ASTPreTrainedModel,
    )

  try:
    if not is_speech_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
  import sys

  __A   :    List[Any]											= _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



