"""simple docstring"""





import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
				from .tokenization_xlnet import XLNetTokenizer
else:
				__A     = None


__A     = logging.get_logger(__name__)

__A     = {'''vocab_file''': '''spiece.model''', '''tokenizer_file''': '''tokenizer.json'''}

__A     = {
    '''vocab_file''': {
        '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/spiece.model''',
        '''xlnet-large-cased''': '''https://huggingface.co/xlnet-large-cased/resolve/main/spiece.model''',
    },
    '''tokenizer_file''': {
        '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/tokenizer.json''',
        '''xlnet-large-cased''': '''https://huggingface.co/xlnet-large-cased/resolve/main/tokenizer.json''',
    },
}

__A     = {
    '''xlnet-base-cased''': None,
    '''xlnet-large-cased''': None,
}

__A     = '''▁'''

# Segments (not really needed)
__A     = 0
__A     = 1
__A     = 2
__A     = 3
__A     = 4
class        _snake_case   (    a__						):
						snake_case__	     =	VOCAB_FILES_NAMES
						snake_case__	     =	PRETRAINED_VOCAB_FILES_MAP
						snake_case__	     =	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						snake_case__	     =	"""left"""
						snake_case__	     =	XLNetTokenizer






						def __init__(				self					:	Tuple							,    UpperCAmelCase					:	str=None							,    UpperCAmelCase					:	List[Any]=None							,    UpperCAmelCase					:	Tuple=False							,    UpperCAmelCase					:	Tuple=True							,    UpperCAmelCase					:	List[Any]=False							,    UpperCAmelCase					:	str="<s>"							,    UpperCAmelCase					:	int="</s>"							,    UpperCAmelCase					:	Tuple="<unk>"							,    UpperCAmelCase					:	Any="<sep>"							,    UpperCAmelCase					:	str="<pad>"							,    UpperCAmelCase					:	Union[str, Any]="<cls>"							,    UpperCAmelCase					:	Union[str, Any]="<mask>"							,    UpperCAmelCase					:	Optional[int]=["<eop>", "<eod>"]							,    **UpperCAmelCase					:	Any							,    ):
													__lowerCamelCase    :						Optional[int]						      =   AddedToken(__UpperCAmelCase							,    lstrip=__UpperCAmelCase							,    rstrip=__UpperCAmelCase			) if isinstance(__UpperCAmelCase							,    __UpperCAmelCase			) else mask_token

													super().__init__(
													    vocab_file=__UpperCAmelCase							,    tokenizer_file=__UpperCAmelCase							,    do_lower_case=__UpperCAmelCase							,    remove_space=__UpperCAmelCase							,    keep_accents=__UpperCAmelCase							,    bos_token=__UpperCAmelCase							,    eos_token=__UpperCAmelCase							,    unk_token=__UpperCAmelCase							,    sep_token=__UpperCAmelCase							,    pad_token=__UpperCAmelCase							,    cls_token=__UpperCAmelCase							,    mask_token=__UpperCAmelCase							,    additional_special_tokens=__UpperCAmelCase							,    **__UpperCAmelCase							,    )

													__lowerCamelCase    :						Optional[Any]						      =   3
													__lowerCamelCase    :						Dict						      =   do_lower_case
													__lowerCamelCase    :						Optional[Any]						      =   remove_space
													__lowerCamelCase    :						Union[str, Any]						      =   keep_accents
													__lowerCamelCase    :						Optional[Any]						      =   vocab_file
													__lowerCamelCase    :						List[str]						      =   False if not self.vocab_file else True






						def 					lowerCamelCase__   (				self					:	Union[str, Any]							,    UpperCAmelCase					:	Tuple							,    UpperCAmelCase					:	Optional[Any] = None			):
													__lowerCamelCase    :						Optional[int]						      =   [self.sep_token_id]
													__lowerCamelCase    :						Optional[int]						      =   [self.cls_token_id]
													if token_ids_a is None:
																				return token_ids_a + sep + cls
													return token_ids_a + sep + token_ids_a + sep + cls






						def 					lowerCamelCase__   (				self					:	Tuple							,    UpperCAmelCase					:	Any							,    UpperCAmelCase					:	List[Any] = None			):
													__lowerCamelCase    :						str						      =   [self.sep_token_id]
													__lowerCamelCase    :						List[str]						      =   [2]

													if token_ids_a is None:
																				return len(token_ids_a + sep			) * [0] + cls_segment_id
													return len(token_ids_a + sep			) * [0] + len(token_ids_a + sep			) * [1] + cls_segment_id







						def 					lowerCamelCase__   (				self					:	List[str]							,    UpperCAmelCase					:	Any							,    UpperCAmelCase					:	int = None			):

													if not self.can_save_slow_tokenizer:
																				raise ValueError(
																				    "Your fast tokenizer does not have the necessary information to save the vocabulary for a slow "
																				    "tokenizer."			)

													if not os.path.isdir(__UpperCAmelCase			):
																				logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""			)
																				return
													__lowerCamelCase    :						List[str]						      =   os.path.join(
													    __UpperCAmelCase							,    (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]			)

													if os.path.abspath(self.vocab_file			) != os.path.abspath(__UpperCAmelCase			):
																				copyfile(self.vocab_file							,    __UpperCAmelCase			)

													return (out_vocab_file,)






"""simple docstring"""





def  __A   (_SCREAMING_SNAKE_CASE     ,   _SCREAMING_SNAKE_CASE			)					->float:





  """simple docstring"""


  if discount_rate < 0:
    raise ValueError('Discount rate cannot be negative'			)
  if not cash_flows:
    raise ValueError('Cash flows list cannot be empty'			)
  lowerCAmelCase__			:Union[str, Any]											=							sum(
      cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_SCREAMING_SNAKE_CASE			)			)
  return round(_SCREAMING_SNAKE_CASE     ,   ndigits=2			)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
