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


__magic_name__								=logging.get_logger(__name__)

__magic_name__								={
    '''facebook/s2t-small-librispeech-asr''': (
        '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}



class     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Any						="speech_to_text"
  SCREAMING_SNAKE_CASE_	:	Optional[Any]						=["past_key_values"]
  SCREAMING_SNAKE_CASE_	:	Dict						={"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}






  def __init__(self   ,				SCREAMING_SNAKE_CASE_=1_0000   ,				SCREAMING_SNAKE_CASE_=12   ,				SCREAMING_SNAKE_CASE_=2048   ,				SCREAMING_SNAKE_CASE_=4   ,				SCREAMING_SNAKE_CASE_=6   ,				SCREAMING_SNAKE_CASE_=2048   ,				SCREAMING_SNAKE_CASE_=4   ,				SCREAMING_SNAKE_CASE_=0.0   ,				SCREAMING_SNAKE_CASE_=0.0   ,				SCREAMING_SNAKE_CASE_=True   ,				SCREAMING_SNAKE_CASE_=True   ,				SCREAMING_SNAKE_CASE_="relu"   ,				SCREAMING_SNAKE_CASE_=256   ,				SCREAMING_SNAKE_CASE_=0.1   ,				SCREAMING_SNAKE_CASE_=0.0   ,				SCREAMING_SNAKE_CASE_=0.0   ,				SCREAMING_SNAKE_CASE_=0.02   ,				SCREAMING_SNAKE_CASE_=2   ,				SCREAMING_SNAKE_CASE_=True   ,				SCREAMING_SNAKE_CASE_=1   ,				SCREAMING_SNAKE_CASE_=0   ,				SCREAMING_SNAKE_CASE_=2   ,				SCREAMING_SNAKE_CASE_=6000   ,				SCREAMING_SNAKE_CASE_=1024   ,				SCREAMING_SNAKE_CASE_=2   ,				SCREAMING_SNAKE_CASE_=(5, 5)   ,				SCREAMING_SNAKE_CASE_=1024   ,				SCREAMING_SNAKE_CASE_=80   ,				SCREAMING_SNAKE_CASE_=1   ,				**SCREAMING_SNAKE_CASE_   ,				)		->      Any:





       '''simple docstring'''





       UpperCamelCase__										=      vocab_size
       UpperCamelCase__										=      d_model
       UpperCamelCase__										=      encoder_ffn_dim
       UpperCamelCase__										=      encoder_layers
       UpperCamelCase__										=      encoder_attention_heads
       UpperCamelCase__										=      decoder_ffn_dim
       UpperCamelCase__										=      decoder_layers
       UpperCamelCase__										=      decoder_attention_heads
       UpperCamelCase__										=      dropout
       UpperCamelCase__										=      attention_dropout
       UpperCamelCase__										=      activation_dropout
       UpperCamelCase__										=      activation_function
       UpperCamelCase__										=      init_std
       UpperCamelCase__										=      encoder_layerdrop
       UpperCamelCase__										=      decoder_layerdrop
       UpperCamelCase__										=      use_cache
       UpperCamelCase__										=      encoder_layers
       UpperCamelCase__										=      scale_embedding  # scale factor will be sqrt(d_model) if True
       UpperCamelCase__										=      max_source_positions
       UpperCamelCase__										=      max_target_positions
       UpperCamelCase__										=      num_conv_layers
       UpperCamelCase__										=      list(SCREAMING_SNAKE_CASE_	)
       UpperCamelCase__										=      conv_channels
       UpperCamelCase__										=      input_feat_per_channel
       UpperCamelCase__										=      input_channels

       if len(self.conv_kernel_sizes	) != self.num_conv_layers:
            raise ValueError(
                '''Configuration for convolutional module is incorrect. '''
                '''It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` '''
                F"but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes	)}`, "
                F"`config.num_conv_layers = {self.num_conv_layers}`."	)

       super().__init__(
           pad_token_id=SCREAMING_SNAKE_CASE_   ,				bos_token_id=SCREAMING_SNAKE_CASE_   ,				eos_token_id=SCREAMING_SNAKE_CASE_   ,				is_encoder_decoder=SCREAMING_SNAKE_CASE_   ,				decoder_start_token_id=SCREAMING_SNAKE_CASE_   ,				**SCREAMING_SNAKE_CASE_   ,				)




import os
from typing import Optional

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



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






  def __init__(self   ,				SCREAMING_SNAKE_CASE_ = ""   ,				SCREAMING_SNAKE_CASE_ = None   ,				SCREAMING_SNAKE_CASE_ = None   ,				**SCREAMING_SNAKE_CASE_	)		->      List[str]:





       '''simple docstring'''





       super().__init__(self   ,				**SCREAMING_SNAKE_CASE_	)
       # always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
       UpperCamelCase__										=      fsspec.open(
           SCREAMING_SNAKE_CASE_   ,				mode='''rb'''   ,				protocol=SCREAMING_SNAKE_CASE_   ,				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__										=      os.path.basename(self.file.path.split('''::'''	)[0]	)
       UpperCamelCase__										=      (
           self.compressed_name[: self.compressed_name.rindex('''.'''	)]
           if '''.''' in self.compressed_name
           else self.compressed_name
       )
       UpperCamelCase__										=      None






  @classmethod
  def 		_a					(cls   ,				SCREAMING_SNAKE_CASE_	)		->      Optional[Any]:





       '''simple docstring'''





       return super()._strip_protocol(SCREAMING_SNAKE_CASE_	).lstrip('''/'''	)






  def 		_a					(self	)		->      Union[str, Any]:





       '''simple docstring'''





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






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      List[Any]:





       '''simple docstring'''





       return self.file.open().read()






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_ = "rb"   ,				SCREAMING_SNAKE_CASE_=None   ,				SCREAMING_SNAKE_CASE_=True   ,				SCREAMING_SNAKE_CASE_=None   ,				**SCREAMING_SNAKE_CASE_   ,				)		->      List[Any]:





       '''simple docstring'''





       UpperCamelCase__										=      self._strip_protocol(SCREAMING_SNAKE_CASE_	)
       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     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Tuple						="bz2"
  SCREAMING_SNAKE_CASE_	:	List[str]						="bz2"
  SCREAMING_SNAKE_CASE_	:	List[Any]						=".bz2"



class     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Tuple						="gzip"
  SCREAMING_SNAKE_CASE_	:	Dict						="gzip"
  SCREAMING_SNAKE_CASE_	:	List[Any]						=".gz"



class     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	List[Any]						="lz4"
  SCREAMING_SNAKE_CASE_	:	str						="lz4"
  SCREAMING_SNAKE_CASE_	:	Any						=".lz4"



class     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Dict						="xz"
  SCREAMING_SNAKE_CASE_	:	List[str]						="xz"
  SCREAMING_SNAKE_CASE_	:	Optional[int]						=".xz"



class     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Optional[Any]						="zstd"
  SCREAMING_SNAKE_CASE_	:	Optional[int]						="zstd"
  SCREAMING_SNAKE_CASE_	:	Optional[int]						=".zst"






  def __init__(self   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_ = "rb"   ,				SCREAMING_SNAKE_CASE_ = None   ,				SCREAMING_SNAKE_CASE_ = None   ,				SCREAMING_SNAKE_CASE_ = DEFAULT_BLOCK_SIZE   ,				**SCREAMING_SNAKE_CASE_   ,				)		->      List[Any]:





       '''simple docstring'''





       super().__init__(
           fo=SCREAMING_SNAKE_CASE_   ,				mode=SCREAMING_SNAKE_CASE_   ,				target_protocol=SCREAMING_SNAKE_CASE_   ,				target_options=SCREAMING_SNAKE_CASE_   ,				block_size=SCREAMING_SNAKE_CASE_   ,				**SCREAMING_SNAKE_CASE_   ,				)
       # 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__										=      self.file.__enter__



       class     _A   :






         def __init__(self   ,				SCREAMING_SNAKE_CASE_	)		->      int:





              '''simple docstring'''





              UpperCamelCase__										=      file_






         def __enter__(self	)		->      Union[str, Any]:





              '''simple docstring'''





              self._file.__enter__()
              return self






         def __exit__(self   ,				*SCREAMING_SNAKE_CASE_   ,				**SCREAMING_SNAKE_CASE_	)		->      List[Any]:





              '''simple docstring'''





              self._file.__exit__(*SCREAMING_SNAKE_CASE_   ,				**SCREAMING_SNAKE_CASE_	)






         def __iter__(self	)		->      Dict:





              '''simple docstring'''





              return iter(self._file	)






         def 		_a					(self	)		->      Dict:





              '''simple docstring'''





              return next(self._file	)






         def __getattr__(self   ,				SCREAMING_SNAKE_CASE_	)		->      str:





              '''simple docstring'''





              return getattr(self._file   ,				SCREAMING_SNAKE_CASE_	)

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

       UpperCamelCase__										=      fixed_enter



