

'''simple docstring'''



import importlib
import inspect
from functools import wraps
from typing import TYPE_CHECKING, Optional, Union

from .download.streaming_download_manager import (
    xbasename,
    xdirname,
    xet_parse,
    xexists,
    xgetsize,
    xglob,
    xgzip_open,
    xisdir,
    xisfile,
    xjoin,
    xlistdir,
    xnumpy_load,
    xopen,
    xpandas_read_csv,
    xpandas_read_excel,
    xPath,
    xrelpath,
    xsio_loadmat,
    xsplit,
    xsplitext,
    xwalk,
    xxml_dom_minidom_parse,
)
from .utils.logging import get_logger
from .utils.patching import patch_submodule
from .utils.py_utils import get_imports


UpperCAmelCase				: Dict         =  get_logger(__name__)


if TYPE_CHECKING:
  from .builder import DatasetBuilder







def      a__ (						a__   ,					a__ = None		):




     """simple docstring"""


     __SCREAMING_SNAKE_CASE						     =   importlib.import_module(a__		)

     # TODO(QL): always update the module to add subsequent new authentication
     if hasattr(a__   ,					"""_patched_for_streaming"""		) and module._patched_for_streaming:
          return

     def wrap_auth(a__		):
          @wraps(a__		)
          def wrapper(*a__   ,					**a__		):
               return function(*a__   ,					use_auth_token=a__   ,					**a__		)

          __SCREAMING_SNAKE_CASE						     =   """wrap_auth"""
          return wrapper

     # open files in a streaming fashion
     patch_submodule(a__   ,					"""open"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""os.listdir"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""os.walk"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""glob.glob"""   ,					wrap_auth(a__		)		).start()
     # allow to navigate in remote zip files
     patch_submodule(a__   ,					"""os.path.join"""   ,					a__		).start()
     patch_submodule(a__   ,					"""os.path.dirname"""   ,					a__		).start()
     patch_submodule(a__   ,					"""os.path.basename"""   ,					a__		).start()
     patch_submodule(a__   ,					"""os.path.relpath"""   ,					a__		).start()
     patch_submodule(a__   ,					"""os.path.split"""   ,					a__		).start()
     patch_submodule(a__   ,					"""os.path.splitext"""   ,					a__		).start()
     # allow checks on paths
     patch_submodule(a__   ,					"""os.path.exists"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""os.path.isdir"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""os.path.isfile"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""os.path.getsize"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""pathlib.Path"""   ,					a__		).start()
     # file readers
     patch_submodule(a__   ,					"""gzip.open"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""numpy.load"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""pandas.read_csv"""   ,					wrap_auth(a__		)   ,					attrs=["""__version__"""]		).start()
     patch_submodule(a__   ,					"""pandas.read_excel"""   ,					wrap_auth(a__		)   ,					attrs=["""__version__"""]		).start()
     patch_submodule(a__   ,					"""scipy.io.loadmat"""   ,					wrap_auth(a__		)   ,					attrs=["""__version__"""]		).start()
     patch_submodule(a__   ,					"""xml.etree.ElementTree.parse"""   ,					wrap_auth(a__		)		).start()
     patch_submodule(a__   ,					"""xml.dom.minidom.parse"""   ,					wrap_auth(a__		)		).start()
     __SCREAMING_SNAKE_CASE						     =   True







def      a__ (						a__		):




     """simple docstring"""


     extend_module_for_streaming(builder.__module__   ,					use_auth_token=builder.use_auth_token		)
     # if needed, we also have to extend additional internal imports (like wmt14 -> wmt_utils)
     if not builder.__module__.startswith("""datasets."""		):  # check that it's not a packaged builder like csv
          for imports in get_imports(inspect.getfile(builder.__class__		)		):
               if imports[0] == "internal":
                    __SCREAMING_SNAKE_CASE						     =   imports[1]
                    __SCREAMING_SNAKE_CASE						     =   """.""".join(builder.__module__.split("""."""		)[:-1] + [internal_import_name]		)
                    extend_module_for_streaming(a__   ,					use_auth_token=builder.use_auth_token		)

    # builders can inherit from other builders that might use streaming functionality
    # (for example, ImageFolder and AudioFolder inherit from FolderBuilder which implements examples generation)
    # but these parents builders are not patched automatically as they are not instantiated, so we patch them here
     from .builder import DatasetBuilder

     __SCREAMING_SNAKE_CASE						     =   [
         cls.__module__
         for cls in type(a__		).__mro__[1:]  # make sure it's not the same module we've already patched
         if issubclass(cls   ,					a__		) and cls.__module__ != DatasetBuilder.__module__
     ]  # check it's not a standard builder from datasets.builder
     for module in parent_builder_modules:
          extend_module_for_streaming(a__   ,					use_auth_token=builder.use_auth_token		)









'''simple docstring'''



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


UpperCAmelCase				: Union[str, Any]         =  logging.get_logger(__name__)

UpperCAmelCase				: Optional[int]         =  {
    'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/config.json',
    # QDQBERT models can be loaded from any BERT checkpoint, available at https://huggingface.co/models?filter=bert
}







class 		lowerCAmelCase__     (   a      ):



 """simple docstring"""



 lowerCAmelCase__						      =   "qdqbert"
 def __init__(	self      : str      ,							__SCREAMING_SNAKE_CASE      : Optional[int]=30_522      ,							__SCREAMING_SNAKE_CASE      : str=768      ,							__SCREAMING_SNAKE_CASE      : Union[str, Any]=12      ,							__SCREAMING_SNAKE_CASE      : Any=12      ,							__SCREAMING_SNAKE_CASE      : Any=3_072      ,							__SCREAMING_SNAKE_CASE      : List[str]="gelu"      ,							__SCREAMING_SNAKE_CASE      : Any=0.1      ,							__SCREAMING_SNAKE_CASE      : Any=0.1      ,							__SCREAMING_SNAKE_CASE      : Optional[int]=512      ,							__SCREAMING_SNAKE_CASE      : List[str]=2      ,							__SCREAMING_SNAKE_CASE      : Dict=0.02      ,							__SCREAMING_SNAKE_CASE      : List[str]=1E-12      ,							__SCREAMING_SNAKE_CASE      : str=True      ,							__SCREAMING_SNAKE_CASE      : Optional[int]=1      ,							__SCREAMING_SNAKE_CASE      : Optional[int]=0      ,							__SCREAMING_SNAKE_CASE      : Dict=2      ,							**__SCREAMING_SNAKE_CASE      : Union[str, Any]      ,							)						->				str:


      """simple docstring"""




      super().__init__(pad_token_id=__SCREAMING_SNAKE_CASE      ,							bos_token_id=__SCREAMING_SNAKE_CASE      ,							eos_token_id=__SCREAMING_SNAKE_CASE      ,							**__SCREAMING_SNAKE_CASE    )

      __SCREAMING_SNAKE_CASE						     =   vocab_size
      __SCREAMING_SNAKE_CASE						     =   max_position_embeddings
      __SCREAMING_SNAKE_CASE						     =   hidden_size
      __SCREAMING_SNAKE_CASE						     =   num_hidden_layers
      __SCREAMING_SNAKE_CASE						     =   num_attention_heads
      __SCREAMING_SNAKE_CASE						     =   intermediate_size
      __SCREAMING_SNAKE_CASE						     =   hidden_act
      __SCREAMING_SNAKE_CASE						     =   hidden_dropout_prob
      __SCREAMING_SNAKE_CASE						     =   attention_probs_dropout_prob
      __SCREAMING_SNAKE_CASE						     =   initializer_range
      __SCREAMING_SNAKE_CASE						     =   type_vocab_size
      __SCREAMING_SNAKE_CASE						     =   layer_norm_eps
      __SCREAMING_SNAKE_CASE						     =   use_cache






