





import os
from typing import Optional

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







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





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





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





   @classmethod
   def 	_snake_case ( cls					,			snake_case      )				->  Optional[Any]:
      """simple docstring"""





      return super()._strip_protocol(snake_case      ).lstrip("/"      )





   def 	_snake_case ( self      )				->  Optional[int]:
      """simple docstring"""





      if self.dir_cache is None:
         a__	:						str      		=  {**self.file.fs.info(self.file.path      ), "name": self.uncompressed_name}
         a__	:						Dict      		=  {f["name"]: f}





   def 	_snake_case ( self					,			snake_case      )				->  Optional[Any]:
      """simple docstring"""





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





   def 	_snake_case ( self					,			snake_case					,			snake_case = "rb"					,			snake_case=None					,			snake_case=True					,			snake_case=None					,			**snake_case					,			)				->  Dict:
      """simple docstring"""





      a__	:						Optional[int]      		=  self._strip_protocol(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   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						Optional[Any]     		=				"""bz2"""
   _UpperCamelCase :						Tuple     		=				"""bz2"""
   _UpperCamelCase :						Dict     		=				""".bz2"""







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						Dict     		=				"""gzip"""
   _UpperCamelCase :						int     		=				"""gzip"""
   _UpperCamelCase :						Any     		=				""".gz"""







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						int     		=				"""lz4"""
   _UpperCamelCase :						Dict     		=				"""lz4"""
   _UpperCamelCase :						str     		=				""".lz4"""







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						int     		=				"""xz"""
   _UpperCamelCase :						Tuple     		=				"""xz"""
   _UpperCamelCase :						Optional[Any]     		=				""".xz"""







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						str     		=				"""zstd"""
   _UpperCamelCase :						int     		=				"""zstd"""
   _UpperCamelCase :						Optional[Any]     		=				""".zst"""





   def __init__( self					,			snake_case					,			snake_case = "rb"					,			snake_case = None					,			snake_case = None					,			snake_case = DEFAULT_BLOCK_SIZE					,			**snake_case					,			)				->  Optional[int]:
      """simple docstring"""





      super().__init__(
          fo=snake_case					,			mode=snake_case					,			target_protocol=snake_case					,			target_options=snake_case					,			block_size=snake_case					,			**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
      a__	:						Optional[Any]      		=  self.file.__enter__







      class   __lowerCAmelCase			:





         def __init__( self					,			snake_case      )				->  str:
            """simple docstring"""





            a__	:						List[str]      		=  file_





         def __enter__( self      )				->  Any:
            """simple docstring"""





            self._file.__enter__()
            return self





         def __exit__( self					,			*snake_case					,			**snake_case      )				->  Tuple:
            """simple docstring"""





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





         def __iter__( self      )				->  Dict:
            """simple docstring"""





            return iter(self._file      )





         def 	_snake_case ( self      )				->  Tuple:
            """simple docstring"""





            return next(self._file      )





         def __getattr__( self					,			snake_case      )				->  Optional[int]:
            """simple docstring"""





            return getattr(self._file					,			snake_case      )

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

      a__	:						Optional[Any]      		=  fixed_enter








from typing import TYPE_CHECKING

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


SCREAMING_SNAKE_CASE__       :			str			      =						{
    """configuration_distilbert""": [
        """DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """DistilBertConfig""",
        """DistilBertOnnxConfig""",
    ],
    """tokenization_distilbert""": ["""DistilBertTokenizer"""],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE__       :			Optional[int]			      =						["""DistilBertTokenizerFast"""]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE__       :			Tuple			      =						[
      """DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """DistilBertForMaskedLM""",
      """DistilBertForMultipleChoice""",
      """DistilBertForQuestionAnswering""",
      """DistilBertForSequenceClassification""",
      """DistilBertForTokenClassification""",
      """DistilBertModel""",
      """DistilBertPreTrainedModel""",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE__       :			List[Any]			      =						[
      """TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """TFDistilBertForMaskedLM""",
      """TFDistilBertForMultipleChoice""",
      """TFDistilBertForQuestionAnswering""",
      """TFDistilBertForSequenceClassification""",
      """TFDistilBertForTokenClassification""",
      """TFDistilBertMainLayer""",
      """TFDistilBertModel""",
      """TFDistilBertPreTrainedModel""",
  ]

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE__       :			Any			      =						[
      """FlaxDistilBertForMaskedLM""",
      """FlaxDistilBertForMultipleChoice""",
      """FlaxDistilBertForQuestionAnswering""",
      """FlaxDistilBertForSequenceClassification""",
      """FlaxDistilBertForTokenClassification""",
      """FlaxDistilBertModel""",
      """FlaxDistilBertPreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_distilbert import (
      DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
      DistilBertConfig,
      DistilBertOnnxConfig,
  )
  from .tokenization_distilbert import DistilBertTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_distilbert_fast import DistilBertTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_distilbert import (
        DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        DistilBertForMaskedLM,
        DistilBertForMultipleChoice,
        DistilBertForQuestionAnswering,
        DistilBertForSequenceClassification,
        DistilBertForTokenClassification,
        DistilBertModel,
        DistilBertPreTrainedModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_distilbert import (
        TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFDistilBertForMaskedLM,
        TFDistilBertForMultipleChoice,
        TFDistilBertForQuestionAnswering,
        TFDistilBertForSequenceClassification,
        TFDistilBertForTokenClassification,
        TFDistilBertMainLayer,
        TFDistilBertModel,
        TFDistilBertPreTrainedModel,
    )

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_distilbert import (
        FlaxDistilBertForMaskedLM,
        FlaxDistilBertForMultipleChoice,
        FlaxDistilBertForQuestionAnswering,
        FlaxDistilBertForSequenceClassification,
        FlaxDistilBertForTokenClassification,
        FlaxDistilBertModel,
        FlaxDistilBertPreTrainedModel,
    )

else:
  import sys

  SCREAMING_SNAKE_CASE__       :			Optional[int]			      =						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

