
"""simple docstring"""




import warnings

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


A__ :       int				= logging.get_logger(__name__)

A__ :       Dict				= {
    '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       __magic_name__							(							SCREAMING_SNAKE_CASE__			):
       UpperCamelCase_ =		'''xlnet'''
       UpperCamelCase_ =		['''mems''']
       UpperCamelCase_ =		{
           '''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_			,					)  ->						Tuple:





         """simple docstring"""




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

         _lowercase:      str   			=  initializer_range
         _lowercase:      List[str]   			=  layer_norm_eps

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

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

         _lowercase:      List[Any]   			=  bos_token_id
         _lowercase:      Union[str, Any]   			=  pad_token_id
         _lowercase:      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.'''			,					A_			,					)
           _lowercase:      Any   			=  kwargs['''use_cache''']

         _lowercase:      Dict   			=  use_mems_eval
         _lowercase:      Optional[Any]   			=  use_mems_train
         super().__init__(pad_token_id=A_			,					bos_token_id=A_			,					eos_token_id=A_			,					**A_							)
       @property
       def 				lowercase_				(  self							)  ->						int:





         """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 				lowercase_				(  self			,					A_							)  ->						Union[str, 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"""




from collections.abc import Callable




def 			_lowerCAmelCase		(		_UpperCamelCase			,					_UpperCamelCase			,					_UpperCamelCase    ):






  """simple docstring"""



  _lowercase:      float   			=  a
  _lowercase:      float   			=  b
  if function(_UpperCamelCase    ) == 0:  # one of the a or b is a root for the function
    return a
  elif function(_UpperCamelCase    ) == 0:
    return b
  elif (
      function(_UpperCamelCase    ) * function(_UpperCamelCase    ) > 0
  ):  # if none of these are root and they are both positive or negative,
    # then this algorithm can't find the root
    raise ValueError('''could not find root in given interval.'''    )
  else:
    _lowercase:      float   			=  start + (end - start) / 2.0
    while abs(start - mid    ) > 10**-7:  # until precisely equals to 10^-7
      if function(_UpperCamelCase    ) == 0:
        return mid
      elif function(_UpperCamelCase    ) * function(_UpperCamelCase    ) < 0:
        _lowercase:      Union[str, Any]   			=  mid
      else:
        _lowercase:      Any   			=  mid
      _lowercase:      List[Any]   			=  start + (end - start) / 2.0
    return mid




def 			_lowerCAmelCase		(		_UpperCamelCase    ):






  """simple docstring"""



  return x**3 - 2 * x - 5


if __name__ == "__main__":
  print(bisection(f, 1, 1_0_0_0))

  import doctest

  doctest.testmod()
