



from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union

import pyarrow as pa


if TYPE_CHECKING:
						from .features import FeatureType



@dataclass
class 						UpperCAmelCase_					:
							lowerCamelCase__         =	42
							lowerCamelCase__         =	None
							# Automatically constructed
							lowerCamelCase__         =	"dict"
							lowerCamelCase__         =	None
							lowerCamelCase__         =	field(default='Translation'     ,      init=a     ,      repr=a)







							def __call__(     self):

														'''simple docstring'''

														return pa.struct({lang: pa.string() for lang in sorted(self.languages)})







							def      snake_case__   (     self):

														'''simple docstring'''

														from .features import Value

														return {k: Value("string") for k in sorted(self.languages)}



@dataclass
class 						UpperCAmelCase_					:
							lowerCamelCase__         =	None
							lowerCamelCase__         =	None
							lowerCamelCase__         =	None
							# Automatically constructed
							lowerCamelCase__         =	"dict"
							lowerCamelCase__         =	None
							lowerCamelCase__         =	field(default='TranslationVariableLanguages'     ,      init=a     ,      repr=a)







							def      snake_case__   (     self):

														'''simple docstring'''

														_lowerCAmelCase  :							str				     =					sorted(set(self.languages)) if self.languages else None
														_lowerCAmelCase  :							str				     =					len(self.languages) if self.languages else None







							def __call__(     self):

														'''simple docstring'''

														return pa.struct({"language": pa.list_(pa.string()), "translation": pa.list_(pa.string())})







							def      snake_case__   (     self,    __a):

														'''simple docstring'''

														_lowerCAmelCase  :							str				     =					set(self.languages)
														if self.languages and set(__a) - lang_set:
																					raise ValueError(
																					    f"Some languages in example ({', '.join(sorted(set(__a) - lang_set))}) are not in valid set ({', '.join(__a)}).")

														# Convert dictionary into tuples, splitting out cases where there are
														# multiple translations for a single language.
														_lowerCAmelCase  :							List[str]				     =					[]
														for lang, text in translation_dict.items():
																					if isinstance(__a,    __a):
																												translation_tuples.append((lang, text))
																					else:
																												translation_tuples.extend([(lang, el) for el in text])

        # Ensure translations are in ascending order by language code.
														_lowerCAmelCase     ,					_lowerCAmelCase  :							List[str]				     =					zip(*sorted(__a))

														return {"language": languages, "translation": translations}







							def      snake_case__   (     self):

														'''simple docstring'''

														from .features import Sequence, Value

														return {
														    "language": Sequence(Value("string")),
														    "translation": Sequence(Value("string")),
														}





import warnings

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


_snake_case	=						logging.get_logger(__name__)

_snake_case	=						{
    "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 						UpperCAmelCase_					( a):
							lowerCamelCase__         =	'xlnet'
							lowerCamelCase__         =	['mems']
							lowerCamelCase__         =	{
							    'n_token': 'vocab_size',  # Backward compatibility
							    'hidden_size': 'd_model',
							    'num_attention_heads': 'n_head',
							    'num_hidden_layers': 'n_layer',
							}







							def __init__(     self,    __a=3_2000,    __a=1024,    __a=24,    __a=16,    __a=4096,    __a="gelu",    __a=True,    __a="bi",    __a=0.02,    __a=1E-12,    __a=0.1,    __a=512,    __a=None,    __a=True,    __a=False,    __a=False,    __a=-1,    __a=False,    __a="last",    __a=True,    __a="tanh",    __a=0.1,    __a=5,    __a=5,    __a=5,    __a=1,    __a=2,    **__a,    ):

														'''simple docstring'''

														_lowerCAmelCase  :							int				     =					vocab_size
														_lowerCAmelCase  :							Optional[int]				     =					d_model
														_lowerCAmelCase  :							Tuple				     =					n_layer
														_lowerCAmelCase  :							List[Any]				     =					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})")
														_lowerCAmelCase  :							Optional[int]				     =					d_model // n_head
														_lowerCAmelCase  :							List[str]				     =					ff_activation
														_lowerCAmelCase  :							Tuple				     =					d_inner
														_lowerCAmelCase  :							List[Any]				     =					untie_r
														_lowerCAmelCase  :							List[str]				     =					attn_type

														_lowerCAmelCase  :							Union[str, Any]				     =					initializer_range
														_lowerCAmelCase  :							Any				     =					layer_norm_eps

														_lowerCAmelCase  :							List[Any]				     =					dropout
														_lowerCAmelCase  :							Optional[int]				     =					mem_len
														_lowerCAmelCase  :							Union[str, Any]				     =					reuse_len
														_lowerCAmelCase  :							List[str]				     =					bi_data
														_lowerCAmelCase  :							List[str]				     =					clamp_len
														_lowerCAmelCase  :							Any				     =					same_length

														_lowerCAmelCase  :							List[str]				     =					summary_type
														_lowerCAmelCase  :							int				     =					summary_use_proj
														_lowerCAmelCase  :							Optional[Any]				     =					summary_activation
														_lowerCAmelCase  :							Tuple				     =					summary_last_dropout
														_lowerCAmelCase  :							Union[str, Any]				     =					start_n_top
														_lowerCAmelCase  :							Optional[int]				     =					end_n_top

														_lowerCAmelCase  :							Tuple				     =					bos_token_id
														_lowerCAmelCase  :							List[Any]				     =					pad_token_id
														_lowerCAmelCase  :							Dict				     =					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.",    __a,    )
																					_lowerCAmelCase  :							Union[str, Any]				     =					kwargs["use_cache"]

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







							@property
							def      snake_case__   (     self):

														'''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      snake_case__   (     self,    __a):

														'''simple docstring'''

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