






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


__A      =				logging.get_logger(__name__)

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





class 						SCREAMING_SNAKE_CASE				( snake_case					):





							"""simple docstring"""

							A_						  =					"transfo-xl"
							A_						  =					["mems"]
							A_						  =					{
							    "n_token": "vocab_size",
							    "hidden_size": "d_model",
							    "num_attention_heads": "n_head",
							    "num_hidden_layers": "n_layer",
							}

							def __init__(  self:   int		,     __A:   str=26_77_35		,     __A:   Tuple=[2_00_00, 4_00_00, 20_00_00]		,     __A:   Any=10_24		,     __A:   int=10_24		,     __A:   Optional[int]=16		,     __A:   List[str]=64		,     __A:   List[Any]=40_96		,     __A:   Optional[int]=4		,     __A:   Optional[int]=False		,     __A:   str=18		,     __A:   str=16_00		,     __A:   str=10_00		,     __A:   Optional[Any]=True		,     __A:   Optional[int]=True		,     __A:   Optional[Any]=0		,     __A:   Optional[int]=-1		,     __A:   int=True		,     __A:   Optional[int]=0.1		,     __A:   Dict=0.0		,     __A:   Optional[Any]=True		,     __A:   int="normal"		,     __A:   Any=0.01		,     __A:   Optional[Any]=0.01		,     __A:   Optional[int]=0.02		,     __A:   Dict=1e-5		,     __A:   List[Any]=0		,     **__A:   Tuple		,     )    ->				Dict:
												_A								= vocab_size
												_A								= []
												self.cutoffs.extend(__A   )
												if proj_share_all_but_first:
																	_A								= [False] + [True] * len(self.cutoffs   )
												else:
																	_A								= [False] + [False] * len(self.cutoffs   )
												_A								= d_model
												_A								= d_embed
												_A								= d_head
												_A								= d_inner
												_A								= div_val
												_A								= pre_lnorm
												_A								= n_layer
												_A								= n_head
												_A								= mem_len
												_A								= same_length
												_A								= attn_type
												_A								= clamp_len
												_A								= sample_softmax
												_A								= adaptive
												_A								= dropout
												_A								= dropatt
												_A								= untie_r
												_A								= init
												_A								= init_range
												_A								= proj_init_std
												_A								= init_std
												_A								= layer_norm_epsilon
												super().__init__(eos_token_id=__A		,     **__A   )

							@property
							def       __A (  self:   Any   )    ->				Optional[int]:
												# Message copied from Transformer-XL documentation
												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       __A (  self:   Union[str, Any]		,     __A:   Tuple   )    ->				Optional[Any]:
												# 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 os
import warnings
from typing import List, Optional

from ...tokenization_utils_base import BatchEncoding
from ...utils import logging
from .configuration_rag import RagConfig


__A      =				logging.get_logger(__name__)





class 						SCREAMING_SNAKE_CASE				:





							"""simple docstring"""

							def __init__(  self:   int		,     __A:   Optional[int]		,     __A:   Optional[Any]   )    ->				str:
												_A								= question_encoder
												_A								= generator
												_A								= self.question_encoder

							def       __A (  self:   Optional[int]		,     __A:   Union[str, Any]   )    ->				Dict:
												if os.path.isfile(__A   ):
																	raise ValueError(f"""Provided path ({save_directory}) should be a directory, not a file"""   )
												os.makedirs(__A		,     exist_ok=__A   )
												_A								= os.path.join(__A		,     '''question_encoder_tokenizer'''   )
												_A								= os.path.join(__A		,     '''generator_tokenizer'''   )
												self.question_encoder.save_pretrained(__A   )
												self.generator.save_pretrained(__A   )

							@classmethod
							def       __A (  cls:   Optional[Any]		,     __A:   List[str]		,     **__A:   int   )    ->				Any:
												# dynamically import AutoTokenizer
												from ..auto.tokenization_auto import AutoTokenizer

												_A								= kwargs.pop('''config'''		,     __A   )

												if config is None:
																	_A								= RagConfig.from_pretrained(__A   )

												_A								= AutoTokenizer.from_pretrained(
												    __A		,     config=config.question_encoder		,     subfolder='''question_encoder_tokenizer'''   )
												_A								= AutoTokenizer.from_pretrained(
												    __A		,     config=config.generator		,     subfolder='''generator_tokenizer'''   )
												return cls(question_encoder=__A		,     generator=__A   )

							def __call__(  self:   int		,     *__A:   Optional[int]		,     **__A:   List[str]   )    ->				int:
												return self.current_tokenizer(*__A		,     **__A   )

							def       __A (  self:   Dict		,     *__A:   List[str]		,     **__A:   List[str]   )    ->				Dict:
												return self.generator.batch_decode(*__A		,     **__A   )

							def       __A (  self:   Union[str, Any]		,     *__A:   Tuple		,     **__A:   List[str]   )    ->				Tuple:
												return self.generator.decode(*__A		,     **__A   )

							def       __A (  self:   Dict   )    ->				List[str]:
												_A								= self.question_encoder

							def       __A (  self:   Union[str, Any]   )    ->				int:
												_A								= self.generator



							def       __A (  self:   Dict		,     __A:   List[str]		,     __A:   Optional[List[str]] = None		,     __A:   Optional[int] = None		,     __A:   Optional[int] = None		,     __A:   str = "longest"		,     __A:   str = None		,     __A:   bool = True		,     **__A:   Tuple		,     )    ->				BatchEncoding:
												warnings.warn(
												    '''`prepare_seq2seq_batch` is deprecated and will be removed in version 5 of 🤗 Transformers. Use the '''
												    '''regular `__call__` method to prepare your inputs and the tokenizer under the `with_target_tokenizer` '''
												    '''context manager to prepare your targets. See the documentation of your specific tokenizer for more '''
												    '''details'''		,     __A		,     )
												if max_length is None:
																	_A								= self.current_tokenizer.model_max_length
												_A								= self(
												    __A		,     add_special_tokens=__A		,     return_tensors=__A		,     max_length=__A		,     padding=__A		,     truncation=__A		,     **__A		,     )
												if tgt_texts is None:
																	return model_inputs
												# Process tgt_texts
												if max_target_length is None:
																	_A								= self.current_tokenizer.model_max_length
												_A								= self(
												    text_target=__A		,     add_special_tokens=__A		,     return_tensors=__A		,     padding=__A		,     max_length=__A		,     truncation=__A		,     **__A		,     )
												_A								= labels['''input_ids''']
												return model_inputs



