


"""simple docstring"""

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


UpperCAmelCase__  							=logging.get_logger(__name__)

UpperCAmelCase__  							={
    "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json",
}





class    lowerCamelCase__						(		_a    ):
						a :     Union[str, Any]											=		"""transfo-xl"""
						a :     List[str]											=		["""mems"""]
						a :     str											=		{
						    """n_token""": """vocab_size""",
						    """hidden_size""": """d_model""",
						    """num_attention_heads""": """n_head""",
						    """num_hidden_layers""": """n_layer""",
						}
						def __init__(		self	:	Union[str, Any]      ,       A_	:	str=2_6_7_7_3_5      ,       A_	:	Dict=[2_0_0_0_0, 4_0_0_0_0, 2_0_0_0_0_0]      ,       A_	:	Union[str, Any]=1_0_2_4      ,       A_	:	List[str]=1_0_2_4      ,       A_	:	Optional[int]=1_6      ,       A_	:	str=6_4      ,       A_	:	Tuple=4_0_9_6      ,       A_	:	Dict=4      ,       A_	:	int=False      ,       A_	:	Optional[int]=1_8      ,       A_	:	int=1_6_0_0      ,       A_	:	List[str]=1_0_0_0      ,       A_	:	Dict=True      ,       A_	:	Union[str, Any]=True      ,       A_	:	Union[str, Any]=0      ,       A_	:	Tuple=-1      ,       A_	:	Dict=True      ,       A_	:	Optional[int]=0.1      ,       A_	:	Tuple=0.0      ,       A_	:	Tuple=True      ,       A_	:	str="normal"      ,       A_	:	Tuple=0.01      ,       A_	:	Optional[int]=0.01      ,       A_	:	str=0.02      ,       A_	:	Tuple=1e-5      ,       A_	:	Dict=0      ,       **A_	:	List[Any]      ,       ):






							'''simple docstring'''


							__lowercase									=	vocab_size
							__lowercase									=	[]
							self.cutoffs.extend(A_							)
							if proj_share_all_but_first:
								__lowercase									=	[False] + [True] * len(self.cutoffs							)
							else:
								__lowercase									=	[False] + [False] * len(self.cutoffs							)
							__lowercase									=	d_model
							__lowercase									=	d_embed
							__lowercase									=	d_head
							__lowercase									=	d_inner
							__lowercase									=	div_val
							__lowercase									=	pre_lnorm
							__lowercase									=	n_layer
							__lowercase									=	n_head
							__lowercase									=	mem_len
							__lowercase									=	same_length
							__lowercase									=	attn_type
							__lowercase									=	clamp_len
							__lowercase									=	sample_softmax
							__lowercase									=	adaptive
							__lowercase									=	dropout
							__lowercase									=	dropatt
							__lowercase									=	untie_r
							__lowercase									=	init
							__lowercase									=	init_range
							__lowercase									=	proj_init_std
							__lowercase									=	init_std
							__lowercase									=	layer_norm_epsilon
							super().__init__(eos_token_id=A_      ,       **A_							)
						@property
						def SCREAMING_SNAKE_CASE_	(		self	:	List[str]							):






							'''simple docstring'''


							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 SCREAMING_SNAKE_CASE_	(		self	:	Optional[int]      ,       A_	:	Optional[Any]							):






							'''simple docstring'''


							raise NotImplementedError(
							    F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''							)




"""simple docstring"""

import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.text import TextDatasetReader

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases


def lowerCAmelCase_      (				UpperCamelCase__	: List[str]				,   UpperCamelCase__	: Any ):






 """simple docstring"""







 assert isinstance(UpperCamelCase__				,   UpperCamelCase__ )
 assert dataset.num_rows == 4
 assert dataset.num_columns == 1
 assert dataset.column_names == ["text"]
 for feature, expected_dtype in expected_features.items():
  assert dataset.features[feature].dtype == expected_dtype


@pytest.mark.parametrize("""keep_in_memory"""				,   [False, True] )
def lowerCAmelCase_      (				UpperCamelCase__	: Dict				,   UpperCamelCase__	: Optional[int]				,   UpperCamelCase__	: List[str] ):






 """simple docstring"""







 __lowercase									=	tmp_path / """cache"""
 __lowercase									=	{"""text""": """string"""}
 with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
  __lowercase									=	TextDatasetReader(UpperCamelCase__				,   cache_dir=UpperCamelCase__				,   keep_in_memory=UpperCamelCase__ ).read()
 _check_text_dataset(UpperCamelCase__				,   UpperCamelCase__ )


@pytest.mark.parametrize(
    """features"""				,   [
        None,
        {"""text""": """string"""},
        {"""text""": """int32"""},
        {"""text""": """float32"""},
    ]				,   )
def lowerCAmelCase_      (				UpperCamelCase__	: List[Any]				,   UpperCamelCase__	: List[str]				,   UpperCamelCase__	: Union[str, Any] ):






 """simple docstring"""







 __lowercase									=	tmp_path / """cache"""
 __lowercase									=	{"""text""": """string"""}
 __lowercase									=	features.copy() if features else default_expected_features
 __lowercase									=	(
     Features({feature: Value(UpperCamelCase__ ) for feature, dtype in features.items()} ) if features is not None else None
 )
 __lowercase									=	TextDatasetReader(UpperCamelCase__				,   features=UpperCamelCase__				,   cache_dir=UpperCamelCase__ ).read()
 _check_text_dataset(UpperCamelCase__				,   UpperCamelCase__ )


@pytest.mark.parametrize("""split"""				,   [None, NamedSplit("""train""" ), """train""", """test"""] )
def lowerCAmelCase_      (				UpperCamelCase__	: Union[str, Any]				,   UpperCamelCase__	: str				,   UpperCamelCase__	: Tuple ):






 """simple docstring"""







 __lowercase									=	tmp_path / """cache"""
 __lowercase									=	{"""text""": """string"""}
 __lowercase									=	TextDatasetReader(UpperCamelCase__				,   cache_dir=UpperCamelCase__				,   split=UpperCamelCase__ ).read()
 _check_text_dataset(UpperCamelCase__				,   UpperCamelCase__ )
 assert dataset.split == split if split else "train"


@pytest.mark.parametrize("""path_type"""				,   [str, list] )
def lowerCAmelCase_      (				UpperCamelCase__	: Union[str, Any]				,   UpperCamelCase__	: List[str]				,   UpperCamelCase__	: Any ):






 """simple docstring"""







 if issubclass(UpperCamelCase__				,   UpperCamelCase__ ):
  __lowercase									=	text_path
 elif issubclass(UpperCamelCase__				,   UpperCamelCase__ ):
  __lowercase									=	[text_path]
 __lowercase									=	tmp_path / """cache"""
 __lowercase									=	{"""text""": """string"""}
 __lowercase									=	TextDatasetReader(UpperCamelCase__				,   cache_dir=UpperCamelCase__ ).read()
 _check_text_dataset(UpperCamelCase__				,   UpperCamelCase__ )


def lowerCAmelCase_      (				UpperCamelCase__	: str				,   UpperCamelCase__	: str				,   UpperCamelCase__	: Any=("train",) ):






 """simple docstring"""







 assert isinstance(UpperCamelCase__				,   UpperCamelCase__ )
 for split in splits:
  __lowercase									=	dataset_dict[split]
  assert dataset.num_rows == 4
  assert dataset.num_columns == 1
  assert dataset.column_names == ["text"]
  for feature, expected_dtype in expected_features.items():
   assert dataset.features[feature].dtype == expected_dtype


@pytest.mark.parametrize("""keep_in_memory"""				,   [False, True] )
def lowerCAmelCase_      (				UpperCamelCase__	: int				,   UpperCamelCase__	: List[str]				,   UpperCamelCase__	: List[Any] ):






 """simple docstring"""







 __lowercase									=	tmp_path / """cache"""
 __lowercase									=	{"""text""": """string"""}
 with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
  __lowercase									=	TextDatasetReader({"""train""": text_path}				,   cache_dir=UpperCamelCase__				,   keep_in_memory=UpperCamelCase__ ).read()
 _check_text_datasetdict(UpperCamelCase__				,   UpperCamelCase__ )


@pytest.mark.parametrize(
    """features"""				,   [
        None,
        {"""text""": """string"""},
        {"""text""": """int32"""},
        {"""text""": """float32"""},
    ]				,   )
def lowerCAmelCase_      (				UpperCamelCase__	: Optional[Any]				,   UpperCamelCase__	: Dict				,   UpperCamelCase__	: Union[str, Any] ):






 """simple docstring"""







 __lowercase									=	tmp_path / """cache"""
 # CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
 __lowercase									=	{"""text""": """string"""}
 __lowercase									=	features.copy() if features else default_expected_features
 __lowercase									=	(
     Features({feature: Value(UpperCamelCase__ ) for feature, dtype in features.items()} ) if features is not None else None
 )
 __lowercase									=	TextDatasetReader({"""train""": text_path}				,   features=UpperCamelCase__				,   cache_dir=UpperCamelCase__ ).read()
 _check_text_datasetdict(UpperCamelCase__				,   UpperCamelCase__ )


@pytest.mark.parametrize("""split"""				,   [None, NamedSplit("""train""" ), """train""", """test"""] )
def lowerCAmelCase_      (				UpperCamelCase__	: Dict				,   UpperCamelCase__	: int				,   UpperCamelCase__	: int ):






 """simple docstring"""







 if split:
  __lowercase									=	{split: text_path}
 else:
  __lowercase									=	"""train"""
  __lowercase									=	{"""train""": text_path, """test""": text_path}
 __lowercase									=	tmp_path / """cache"""
 __lowercase									=	{"""text""": """string"""}
 __lowercase									=	TextDatasetReader(UpperCamelCase__				,   cache_dir=UpperCamelCase__ ).read()
 _check_text_datasetdict(UpperCamelCase__				,   UpperCamelCase__				,   splits=list(path.keys() ) )
 assert all(dataset[split].split == split for split in path.keys() )
