






import warnings

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


__UpperCAmelCase								=						logging.get_logger(__name__)

__UpperCAmelCase								=						{
    '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   lowerCamelCase      (_snake_case			):







		'''simple docstring'''



		_snake_case    :    Dict       						=  '''xlnet'''
		_snake_case    :    Optional[int]       						=  ['''mems''']
		_snake_case    :    List[str]       						=  {
		    '''n_token''': '''vocab_size''',  # Backward compatibility
		    '''hidden_size''': '''d_model''',
		    '''num_attention_heads''': '''n_head''',
		    '''num_hidden_layers''': '''n_layer''',
		}



		def __init__(							self				,		_UpperCamelCase=3_2_0_0_0				,		_UpperCamelCase=1_0_2_4				,		_UpperCamelCase=2_4				,		_UpperCamelCase=1_6				,		_UpperCamelCase=4_0_9_6				,		_UpperCamelCase="gelu"				,		_UpperCamelCase=True				,		_UpperCamelCase="bi"				,		_UpperCamelCase=0.02				,		_UpperCamelCase=1E-12				,		_UpperCamelCase=0.1				,		_UpperCamelCase=5_1_2				,		_UpperCamelCase=None				,		_UpperCamelCase=True				,		_UpperCamelCase=False				,		_UpperCamelCase=False				,		_UpperCamelCase=-1				,		_UpperCamelCase=False				,		_UpperCamelCase="last"				,		_UpperCamelCase=True				,		_UpperCamelCase="tanh"				,		_UpperCamelCase=0.1				,		_UpperCamelCase=5				,		_UpperCamelCase=5				,		_UpperCamelCase=5				,		_UpperCamelCase=1				,		_UpperCamelCase=2				,		**_UpperCamelCase				,		)	->							Any:
							UpperCAmelCase_    :      int            =						vocab_size
							UpperCAmelCase_    :      int            =						d_model
							UpperCAmelCase_    :      Any            =						n_layer
							UpperCAmelCase_    :      Tuple            =						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})"   )
							UpperCAmelCase_    :      Dict            =						d_model // n_head
							UpperCAmelCase_    :      int            =						ff_activation
							UpperCAmelCase_    :      Tuple            =						d_inner
							UpperCAmelCase_    :      Any            =						untie_r
							UpperCAmelCase_    :      Optional[int]            =						attn_type

							UpperCAmelCase_    :      Optional[int]            =						initializer_range
							UpperCAmelCase_    :      Union[str, Any]            =						layer_norm_eps

							UpperCAmelCase_    :      int            =						dropout
							UpperCAmelCase_    :      Optional[int]            =						mem_len
							UpperCAmelCase_    :      str            =						reuse_len
							UpperCAmelCase_    :      List[Any]            =						bi_data
							UpperCAmelCase_    :      Tuple            =						clamp_len
							UpperCAmelCase_    :      Dict            =						same_length

							UpperCAmelCase_    :      int            =						summary_type
							UpperCAmelCase_    :      Optional[Any]            =						summary_use_proj
							UpperCAmelCase_    :      List[str]            =						summary_activation
							UpperCAmelCase_    :      Dict            =						summary_last_dropout
							UpperCAmelCase_    :      str            =						start_n_top
							UpperCAmelCase_    :      str            =						end_n_top

							UpperCAmelCase_    :      Any            =						bos_token_id
							UpperCAmelCase_    :      Tuple            =						pad_token_id
							UpperCAmelCase_    :      str            =						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.'				,		_UpperCamelCase				,		)
												UpperCAmelCase_    :      Any            =						kwargs['use_cache']

							UpperCAmelCase_    :      Union[str, Any]            =						use_mems_eval
							UpperCAmelCase_    :      Union[str, Any]            =						use_mems_train
							super().__init__(pad_token_id=_UpperCamelCase				,		bos_token_id=_UpperCamelCase				,		eos_token_id=_UpperCamelCase				,		**_UpperCamelCase   )



		@property
		def 					__UpperCAmelCase			(							self   )	->							Tuple:
							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				,		_UpperCamelCase   )	->							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 importlib
import shutil
import threading
import warnings
from typing import List

import fsspec
import fsspec.asyn

from . import compression
from .hffilesystem import HfFileSystem


__UpperCAmelCase								=						importlib.util.find_spec('s3fs') is not None

if _has_safs:
		from .safilesystem import SaFileSystem  # noqa: F401

__UpperCAmelCase								=						[
    compression.BzaFileSystem,
    compression.GzipFileSystem,
    compression.LzaFileSystem,
    compression.XzFileSystem,
    compression.ZstdFileSystem,
]

# Register custom filesystems
for fs_class in COMPRESSION_FILESYSTEMS + [HfFileSystem]:
		if fs_class.protocol in fsspec.registry and fsspec.registry[fs_class.protocol] is not fs_class:
				warnings.warn(F'A filesystem protocol was already set for {fs_class.protocol} and will be overwritten.')
		fsspec.register_implementation(fs_class.protocol, fs_class, clobber=True)




def      lowercase__      (     __snake_case    :							str  ):


					'''simple docstring'''


					if "://" in dataset_path:
										UpperCAmelCase_    :      int            =						dataset_path.split('://'  )[1]
					return dataset_path




def      lowercase__      (     __snake_case    :							fsspec.AbstractFileSystem  ):


					'''simple docstring'''


					if fs is not None and fs.protocol != "file":
										return True
					else:
										return False




def      lowercase__      (     __snake_case    :							fsspec.AbstractFileSystem     ,       __snake_case    :							str     ,       __snake_case    :							str  ):


					'''simple docstring'''


					UpperCAmelCase_    :      List[str]            =						not is_remote_filesystem(__snake_case  )
					if is_local:
										# LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
										shutil.move(fs._strip_protocol(__snake_case  )     ,       fs._strip_protocol(__snake_case  )  )
					else:
										fs.mv(__snake_case     ,       __snake_case     ,       recursive=__snake_case  )






def      lowercase__      (     ):


					'''simple docstring'''


					if hasattr(fsspec.asyn     ,       'reset_lock'  ):
										# for future fsspec>2022.05.0
										fsspec.asyn.reset_lock()
					else:
										UpperCAmelCase_    :      Optional[Any]            =						None
										UpperCAmelCase_    :      Union[str, Any]            =						None
										UpperCAmelCase_    :      int            =						threading.Lock()






