





'''simple docstring'''

import warnings

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


__lowerCAmelCase							:     Dict		     =logging.get_logger(__name__)

__lowerCAmelCase							:     Optional[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        UpperCAmelCase     (	UpperCamelCase__    ):
 __lowercase       		=    """xlnet"""
 __lowercase       		=    ["""mems"""]
 __lowercase       		=    {
     """n_token""": """vocab_size""",  # Backward compatibility
     """hidden_size""": """d_model""",
     """num_attention_heads""": """n_head""",
     """num_hidden_layers""": """n_layer""",
 }
 def __init__(    self				:int						,	lowercase_				:Any=3_20_00						,	lowercase_				:Optional[int]=10_24						,	lowercase_				:Optional[Any]=24						,	lowercase_				:Optional[Any]=16						,	lowercase_				:Union[str, Any]=40_96						,	lowercase_				:Dict="gelu"						,	lowercase_				:int=True						,	lowercase_				:int="bi"						,	lowercase_				:Dict=0.0_2						,	lowercase_				:str=1E-12						,	lowercase_				:Optional[int]=0.1						,	lowercase_				:Tuple=5_12						,	lowercase_				:Tuple=None						,	lowercase_				:Any=True						,	lowercase_				:Tuple=False						,	lowercase_				:List[Any]=False						,	lowercase_				:int=-1						,	lowercase_				:Tuple=False						,	lowercase_				:Optional[Any]="last"						,	lowercase_				:str=True						,	lowercase_				:Tuple="tanh"						,	lowercase_				:List[Any]=0.1						,	lowercase_				:Optional[int]=5						,	lowercase_				:Dict=5						,	lowercase_				:int=5						,	lowercase_				:Dict=1						,	lowercase_				:List[Any]=2						,	**lowercase_				:Optional[int]						,	)->							Dict:
     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."						,	lowercase_						,	)
         A__    =      kwargs["use_cache"]

     A__    =      use_mems_eval
     A__    =      use_mems_train
     super().__init__(pad_token_id=lowercase_						,	bos_token_id=lowercase_						,	eos_token_id=lowercase_						,	**lowercase_							)
 @property
 def 					UpperCAmelCase_							(    self				:Any							)->							List[Any]:
     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				:Tuple						,	lowercase_				:str							)->							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."							)










'''simple docstring'''

from .imports import is_tqdm_available


if is_tqdm_available():
  from tqdm.auto import tqdm as _tqdm

from ..state import PartialState





def 						UpperCamelCase    (							_lowerCamelCase : bool = True						,	*_lowerCamelCase : Optional[int]						,	**_lowerCamelCase : Optional[Any]	):
    if not is_tqdm_available():
        raise ImportError("Accelerate's `tqdm` module requires `tqdm` to be installed. Please run `pip install tqdm`."	)
    A__    =      False
    if main_process_only:
        A__    =      PartialState().local_process_index == 0
    return _tqdm(*_lowerCamelCase						,	**_lowerCamelCase						,	disable=_lowerCamelCase	)



