





"""simple docstring"""



import os
import re
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


a_			=      logging.get_logger(__name__)

a_			=      {"""vocab_file""": """spiece.model"""}

a_			=      {
    """vocab_file""": {
        """google/bigbird-roberta-base""": """https://huggingface.co/google/bigbird-roberta-base/resolve/main/spiece.model""",
        """google/bigbird-roberta-large""": (
            """https://huggingface.co/google/bigbird-roberta-large/resolve/main/spiece.model"""
        ),
        """google/bigbird-base-trivia-itc""": (
            """https://huggingface.co/google/bigbird-base-trivia-itc/resolve/main/spiece.model"""
        ),
    }
}

a_			=      {
    """google/bigbird-roberta-base""": 4096,
    """google/bigbird-roberta-large""": 4096,
    """google/bigbird-base-trivia-itc""": 4096,
}






class 		__snake_case (		SCREAMING_SNAKE_CASE__					):





 """simple docstring"""


 _lowerCamelCase				=					VOCAB_FILES_NAMES
 _lowerCamelCase				=					PRETRAINED_VOCAB_FILES_MAP
 _lowerCamelCase				=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 _lowerCamelCase				=					["""input_ids""", """attention_mask"""]
 _lowerCamelCase				=					[]

 def __init__(   self ,						__lowerCamelCase ,						__lowerCamelCase="<unk>" ,						__lowerCamelCase="<s>" ,						__lowerCamelCase="</s>" ,						__lowerCamelCase="<pad>" ,						__lowerCamelCase="[SEP]" ,						__lowerCamelCase="[MASK]" ,						__lowerCamelCase="[CLS]" ,						__lowerCamelCase = None ,						**__lowerCamelCase ,						):



     '''simple docstring'''




     __A   :						Optional[Any]									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else bos_token
     __A   :						Union[str, Any]									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else eos_token
     __A   :						Optional[int]									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else unk_token
     __A   :						Optional[Any]									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else pad_token
     __A   :						List[str]									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else cls_token
     __A   :						Tuple									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else sep_token

     # Mask token behave like a normal word, i.e. include the space before it
     __A   :						List[Any]									=					AddedToken(__lowerCamelCase ,						lstrip=__lowerCamelCase ,						rstrip=__lowerCamelCase  ) if isinstance(__lowerCamelCase ,						__lowerCamelCase  ) else mask_token

     __A   :						Optional[int]									=					{} if sp_model_kwargs is None else sp_model_kwargs

     super().__init__(
         bos_token=__lowerCamelCase ,						eos_token=__lowerCamelCase ,						unk_token=__lowerCamelCase ,						pad_token=__lowerCamelCase ,						sep_token=__lowerCamelCase ,						mask_token=__lowerCamelCase ,						cls_token=__lowerCamelCase ,						sp_model_kwargs=self.sp_model_kwargs ,						**__lowerCamelCase ,						)

     __A   :						Any									=					vocab_file

     __A   :						Any									=					spm.SentencePieceProcessor(**self.sp_model_kwargs  )
     self.sp_model.Load(__lowerCamelCase  )

 @property
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     return self.sp_model.get_piece_size()

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Optional[int]									=					{self.convert_ids_to_tokens(__lowerCamelCase  ): i for i in range(self.vocab_size  )}
     vocab.update(self.added_tokens_encoder  )
     return vocab

 def __getstate__(   self  ):



     '''simple docstring'''




     __A   :						Tuple									=					self.__dict__.copy()
     __A   :						int									=					None
     return state

 def __setstate__(   self ,						__lowerCamelCase  ):



     '''simple docstring'''




     __A   :						Optional[int]									=					d

     # for backward compatibility
     if not hasattr(self ,						'''sp_model_kwargs'''  ):
         __A   :						Union[str, Any]									=					{}

     __A   :						Optional[Any]									=					spm.SentencePieceProcessor(**self.sp_model_kwargs  )
     self.sp_model.Load(self.vocab_file  )

 def  UpperCamelCase__(   self ,						__lowerCamelCase  ):



     '''simple docstring'''




     return self.sp_model.encode(__lowerCamelCase ,						out_type=__lowerCamelCase  )

 def  UpperCamelCase__(   self ,						__lowerCamelCase  ):



     '''simple docstring'''




     return self.sp_model.piece_to_id(__lowerCamelCase  )

 def  UpperCamelCase__(   self ,						__lowerCamelCase  ):



     '''simple docstring'''




     __A   :						Optional[int]									=					self.sp_model.IdToPiece(__lowerCamelCase  )
     return token

 def  UpperCamelCase__(   self ,						__lowerCamelCase  ):



     '''simple docstring'''




     __A   :						List[Any]									=					[]
     __A   :						int									=					''''''
     __A   :						Optional[int]									=					False
     for token in tokens:
         # make sure that special tokens are not decoded using sentencepiece model
         if token in self.all_special_tokens:
             if not prev_is_special:
                 out_string += " "
             out_string += self.sp_model.decode(__lowerCamelCase  ) + token
             __A   :						Optional[Any]									=					True
             __A   :						Optional[int]									=					[]
         else:
             current_sub_tokens.append(__lowerCamelCase  )
             __A   :						List[Any]									=					False
     out_string += self.sp_model.decode(__lowerCamelCase  )
     return out_string.strip()

 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase = False ,						__lowerCamelCase = None ,						__lowerCamelCase = True ,						**__lowerCamelCase ,						):



     '''simple docstring'''




     __A   :						Tuple									=					kwargs.pop('''use_source_tokenizer''' ,						__lowerCamelCase  )

     __A   :						Optional[Any]									=					self.convert_ids_to_tokens(__lowerCamelCase ,						skip_special_tokens=__lowerCamelCase  )

     # To avoid mixing byte-level and unicode for byte-level BPT
     # we need to build string separately for added tokens and byte-level tokens
     # cf. https://github.com/huggingface/transformers/issues/1133
     __A   :						Dict									=					[]
     __A   :						Any									=					[]
     for token in filtered_tokens:
         if skip_special_tokens and token in self.all_special_ids:
             continue
         if token in self.added_tokens_encoder:
             if current_sub_text:
                 sub_texts.append(self.convert_tokens_to_string(__lowerCamelCase  )  )
                 __A   :						Any									=					[]
             sub_texts.append(__lowerCamelCase  )
         else:
             current_sub_text.append(__lowerCamelCase  )
     if current_sub_text:
         sub_texts.append(self.convert_tokens_to_string(__lowerCamelCase  )  )

     # Mimic the behavior of the Rust tokenizer:
     # No space before [MASK] and [SEP]
     if spaces_between_special_tokens:
         __A   :						int									=					re.sub(r''' (\[(MASK|SEP)\])''' ,						r'''\1''' ,						''' '''.join(__lowerCamelCase  )  )
     else:
         __A   :						str									=					''''''.join(__lowerCamelCase  )

     __A   :						Dict									=					(
         clean_up_tokenization_spaces
         if clean_up_tokenization_spaces is not None
         else self.clean_up_tokenization_spaces
     )
     if clean_up_tokenization_spaces:
         __A   :						Dict									=					self.clean_up_tokenization(__lowerCamelCase  )
         return clean_text
     else:
         return text

 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase = None  ):



     '''simple docstring'''




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

     if os.path.abspath(self.vocab_file  ) != os.path.abspath(__lowerCamelCase  ) and os.path.isfile(self.vocab_file  ):
         copyfile(self.vocab_file ,						__lowerCamelCase  )
     elif not os.path.isfile(self.vocab_file  ):
         with open(__lowerCamelCase ,						'''wb'''  ) as fi:
             __A   :						Any									=					self.sp_model.serialized_model_proto()
             fi.write(__lowerCamelCase  )

     return (out_vocab_file,)

 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase = None  ):



     '''simple docstring'''




     if token_ids_a is None:
         return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
     __A   :						Tuple									=					[self.cls_token_id]
     __A   :						Dict									=					[self.sep_token_id]
     return cls + token_ids_a + sep + token_ids_a + sep

 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase = None ,						__lowerCamelCase = False  ):



     '''simple docstring'''




     if already_has_special_tokens:
         return super().get_special_tokens_mask(
             token_ids_a=__lowerCamelCase ,						token_ids_a=__lowerCamelCase ,						already_has_special_tokens=__lowerCamelCase  )

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







 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase = None  ):



     '''simple docstring'''




     __A   :						Dict									=					[self.sep_token_id]
     __A   :						Union[str, Any]									=					[self.cls_token_id]
     if token_ids_a is None:
         return len(cls + token_ids_a + sep  ) * [0]
     return len(cls + token_ids_a + sep  ) * [0] + len(token_ids_a + sep  ) * [1]











"""simple docstring"""



from decimal import Decimal, getcontext
from math import ceil, factorial







def 		__lowercase					(       snake_case_  :  int						)       ->str:



    '''simple docstring'''







    if not isinstance(snake_case_    ,snake_case_						):
        raise TypeError('''Undefined for non-integers'''						)
    elif precision < 1:
        raise ValueError('''Undefined for non-natural numbers'''						)

    __A   :						int									=					precision
    __A   :						Tuple									=					ceil(precision / 14						)
    __A   :						Dict									=					426880 * Decimal(10005						).sqrt()
    __A   :						Optional[Any]									=					1
    __A   :						int									=					13591409
    __A   :						Optional[int]									=					Decimal(snake_case_						)
    for k in range(1    ,snake_case_						):
        __A   :						int									=					factorial(6 * k						) // (factorial(3 * k						) * factorial(snake_case_						) ** 3)
        linear_term += 545140134
        exponential_term *= -262537412640768000
        partial_sum += Decimal(multinomial_term * linear_term						) / exponential_term
    return str(constant_term / partial_sum						)[:-1]


if __name__ == "__main__":
       a_			=      50
       print(f'''The first {n} digits of pi is: {pi(n)}''')




