'''simple docstring'''




import json
import os
from typing import Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


_a   :	Dict 							=   logging.get_logger(__name__)

_a   :	Optional[int] 							=   {"vocab_file": "vocab.json"}

_a   :	str 							=   {
    "vocab_file": {
        "mgp-str": "https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json",
    }
}

_a   :	Union[str, Any] 							=   {"mgp-str": 27}






class 		__A       (__magic_name__   ):
       snake_case       :str				    =					VOCAB_FILES_NAMES
       snake_case       :str				    =					PRETRAINED_VOCAB_FILES_MAP
       snake_case       :Any				    =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES






       def __init__(      self				,     UpperCamelCase_				,     UpperCamelCase_="[GO]"				,     UpperCamelCase_="[GO]"				,     UpperCamelCase_="[s]"				,     UpperCamelCase_="[GO]"				,     **UpperCamelCase_      ):
              super().__init__(
                  unk_token=UpperCamelCase_				,     bos_token=UpperCamelCase_				,     eos_token=UpperCamelCase_				,     pad_token=UpperCamelCase_				,     **UpperCamelCase_				,     )

              with open(UpperCamelCase_				,     encoding="utf-8"      ) as vocab_handle:
                     __UpperCAmelCase  :				int       				=		json.load(UpperCamelCase_      )
              __UpperCAmelCase  :				Any       				=		{v: k for k, v in self.vocab.items()}






       @property
       def 			_snake_case						(      self      ):
              return len(self.vocab      )






       def 			_snake_case						(      self      ):
              return dict(self.vocab				,     **self.added_tokens_encoder      )






       def 			_snake_case						(      self				,     UpperCamelCase_      ):
              __UpperCAmelCase  :				List[str]       				=		[]
              for s in text:
                     char_tokens.extend(UpperCamelCase_      )
              return char_tokens






       def 			_snake_case						(      self				,     UpperCamelCase_      ):
              return self.vocab.get(UpperCamelCase_				,     self.vocab.get(self.unk_token      )      )






       def 			_snake_case						(      self				,     UpperCamelCase_      ):
              return self.decoder.get(UpperCamelCase_      )







       def 			_snake_case						(      self				,     UpperCamelCase_				,     UpperCamelCase_ = None      ):
              if not os.path.isdir(UpperCamelCase_      ):
                     logger.error("Vocabulary path ({}) should be a directory".format(UpperCamelCase_      )      )
                     return
              __UpperCAmelCase  :				Union[str, Any]       				=		os.path.join(
                  UpperCamelCase_				,     (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]      )

              with open(UpperCamelCase_				,     "w"				,     encoding="utf-8"      ) as f:
                     f.write(json.dumps(self.vocab				,     indent=2				,     sort_keys=UpperCamelCase_				,     ensure_ascii=UpperCamelCase_      ) + "\n"      )

              return (vocab_file,)







'''simple docstring'''




def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       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"						)
       __UpperCAmelCase  :				Tuple       				=		sum(
           cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(lowerCamelCase__						)						)
       return round(lowerCamelCase__							,    ndigits=2						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()






