import warnings

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


SCREAMING_SNAKE_CASE			:						Optional[int]				  =		logging.get_logger(__name__)

SCREAMING_SNAKE_CASE			:						int				  =		{
    """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/config.json""",
    """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/config.json""",
}
class  A_			(							a_			):
  _SCREAMING_SNAKE_CASE     					=      """xlnet"""
  _SCREAMING_SNAKE_CASE     					=      ["""mems"""]
  _SCREAMING_SNAKE_CASE     					=      {
      """n_token""": """vocab_size""",  # Backward compatibility
      """hidden_size""": """d_model""",
      """num_attention_heads""": """n_head""",
      """num_hidden_layers""": """n_layer""",
  }

  def __init__(		self			:   Dict  ,				__SCREAMING_SNAKE_CASE			:   Optional[Any]=3_20_00  ,				__SCREAMING_SNAKE_CASE			:   Any=10_24  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=24  ,				__SCREAMING_SNAKE_CASE			:   Tuple=16  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=40_96  ,				__SCREAMING_SNAKE_CASE			:   str="gelu"  ,				__SCREAMING_SNAKE_CASE			:   Dict=True  ,				__SCREAMING_SNAKE_CASE			:   Optional[int]="bi"  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=0.02  ,				__SCREAMING_SNAKE_CASE			:   Tuple=1E-12  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=0.1  ,				__SCREAMING_SNAKE_CASE			:   Union[str, Any]=5_12  ,				__SCREAMING_SNAKE_CASE			:   Union[str, Any]=None  ,				__SCREAMING_SNAKE_CASE			:   str=True  ,				__SCREAMING_SNAKE_CASE			:   Any=False  ,				__SCREAMING_SNAKE_CASE			:   str=False  ,				__SCREAMING_SNAKE_CASE			:   List[str]=-1  ,				__SCREAMING_SNAKE_CASE			:   Any=False  ,				__SCREAMING_SNAKE_CASE			:   str="last"  ,				__SCREAMING_SNAKE_CASE			:   str=True  ,				__SCREAMING_SNAKE_CASE			:   Dict="tanh"  ,				__SCREAMING_SNAKE_CASE			:   Tuple=0.1  ,				__SCREAMING_SNAKE_CASE			:   Tuple=5  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=5  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=5  ,				__SCREAMING_SNAKE_CASE			:   Optional[int]=1  ,				__SCREAMING_SNAKE_CASE			:   List[Any]=2  ,				**__SCREAMING_SNAKE_CASE			:   List[Any]  ,				):
   __a							=	vocab_size
   __a							=	d_model
   __a							=	n_layer
   __a							=	n_head
   if d_model % n_head != 0:
    raise ValueError(f"""'d_model % n_head' ({d_model % n_head}) should be equal to 0"""							)
   if "d_head" in kwargs:
    if kwargs["d_head"] != d_model // n_head:
     raise ValueError(
         f"""`d_head` ({kwargs["d_head"]}) should be equal to `d_model // n_head` ({d_model // n_head})"""							)
   __a							=	d_model // n_head
   __a							=	ff_activation
   __a							=	d_inner
   __a							=	untie_r
   __a							=	attn_type

   __a							=	initializer_range
   __a							=	layer_norm_eps

   __a							=	dropout
   __a							=	mem_len
   __a							=	reuse_len
   __a							=	bi_data
   __a							=	clamp_len
   __a							=	same_length

   __a							=	summary_type
   __a							=	summary_use_proj
   __a							=	summary_activation
   __a							=	summary_last_dropout
   __a							=	start_n_top
   __a							=	end_n_top

   __a							=	bos_token_id
   __a							=	pad_token_id
   __a							=	eos_token_id

   if "use_cache" in kwargs:
    warnings.warn(
        "The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`"
        " instead."  ,				__SCREAMING_SNAKE_CASE  ,				)
    __a							=	kwargs["use_cache"]

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

  @property
  def 		_UpperCAmelCase (		self			:   List[str]							):
   logger.info(f"""The model {self.model_type} is one of the few models that has no sequence length limit."""							)
   return -1

  @max_position_embeddings.setter
  def 		_UpperCAmelCase (		self			:   int  ,				__SCREAMING_SNAKE_CASE			:   Optional[int]							):
   # Message copied from Transformer-XL documentation
   raise NotImplementedError(
       f"""The model {self.model_type} is one of the few models that has no sequence length limit."""							)



import enum
import os
from hashlib import shaaaa
from typing import Optional

from .. import config
from .logging import get_logger


SCREAMING_SNAKE_CASE			:						List[Any]				  =		get_logger(__name__)
class  A_			(							enum.Enum			):
  _SCREAMING_SNAKE_CASE     					=      """all_checks"""
  _SCREAMING_SNAKE_CASE     					=      """basic_checks"""
  _SCREAMING_SNAKE_CASE     					=      """no_checks"""
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass



def 	__A		(      _A				,					_A				,					_A=None       ):



 """simple docstring"""


 if expected_checksums is None:
  logger.info("Unable to verify checksums."       )
  return
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise ExpectedMoreDownloadedFiles(str(set(_A       ) - set(_A       )       )       )
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise UnexpectedDownloadedFile(str(set(_A       ) - set(_A       )       )       )
 __a							=	[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
 __a							=	" for " + verification_name if verification_name is not None else ""
 if len(_A       ) > 0:
  raise NonMatchingChecksumError(
      f"""Checksums didn't match{for_verification_name}:\n"""
      f"""{bad_urls}\n"""
      "Set `verification_mode='no_checks'` to skip checksums verification and ignore this error"       )
 logger.info("All the checksums matched successfully" + for_verification_name       )
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass
class  A_			(							a_			):
  pass



def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 if expected_splits is None:
  logger.info("Unable to verify splits sizes."       )
  return
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise ExpectedMoreSplits(str(set(_A       ) - set(_A       )       )       )
 if len(set(_A       ) - set(_A       )       ) > 0:
  raise UnexpectedSplits(str(set(_A       ) - set(_A       )       )       )
 __a							=	[
     {"expected": expected_splits[name], "recorded": recorded_splits[name]}
     for name in expected_splits
     if expected_splits[name].num_examples != recorded_splits[name].num_examples
 ]
 if len(_A       ) > 0:
  raise NonMatchingSplitsSizesError(str(_A       )       )
 logger.info("All the splits matched successfully."       )



def 	__A		(      _A				,					_A = True       ):



 """simple docstring"""


 if record_checksum:
  __a							=	shaaaa()
  with open(_A				,					"rb"       ) as f:
   for chunk in iter(lambda: f.read(1 << 20       )				,					B""       ):
    m.update(_A       )
   __a							=	m.hexdigest()
 else:
  __a							=	None
 return {"num_bytes": os.path.getsize(_A       ), "checksum": checksum}






def 	__A		(      _A       ):



 """simple docstring"""


 if dataset_size and config.IN_MEMORY_MAX_SIZE:
  return dataset_size < config.IN_MEMORY_MAX_SIZE
 else:
  return False


