



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

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


__snake_case						:int      		=     logging.get_logger(__name__)

__snake_case						:Union[str, Any]      		=     '''▁'''

__snake_case						:List[str]      		=     {'''vocab_file''': '''prophetnet.tokenizer'''}

__snake_case						:List[str]      		=     {
    '''vocab_file''': {
        '''microsoft/xprophetnet-large-wiki100-cased''': (
            '''https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased/resolve/main/prophetnet.tokenizer'''
        ),
    }
}

__snake_case						:Dict      		=     {
    '''microsoft/xprophetnet-large-wiki100-cased''': {'''do_lower_case''': False},
}

__snake_case						:str      		=     {
    '''microsoft/xprophetnet-large-wiki100-cased''': 512,
}





def      __snake_case	(			_UpperCAmelCase				):
    __a						       =				collections.OrderedDict()
    with open(_UpperCAmelCase   , '''r'''   , encoding='''utf-8'''				) as reader:
        __a						       =				reader.readlines()
    for index, token in enumerate(_UpperCAmelCase				):
        __a						       =				token.rstrip('''\n'''				)
        __a						       =				index
    return vocab

class     _A       (	__UpperCAmelCase    ):
       UpperCamelCase__  :    Optional[Any]											=						VOCAB_FILES_NAMES
       UpperCamelCase__  :    List[str]											=						PRETRAINED_VOCAB_FILES_MAP
       UpperCamelCase__  :    Optional[Any]											=						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       UpperCamelCase__  :    Dict											=						['''input_ids''', '''attention_mask''']



       def __init__(		self							:     str     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]="[SEP]"     ,		__SCREAMING_SNAKE_CASE							:     List[str]="[SEP]"     ,		__SCREAMING_SNAKE_CASE							:     str="[SEP]"     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]="[UNK]"     ,		__SCREAMING_SNAKE_CASE							:     str="[PAD]"     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]="[CLS]"     ,		__SCREAMING_SNAKE_CASE							:     Tuple="[MASK]"     ,		__SCREAMING_SNAKE_CASE							:     Optional[Dict[str, Any]] = None     ,		**__SCREAMING_SNAKE_CASE							:     Union[str, Any]     ,		):


           '''simple docstring'''

           __a						       =				{} if sp_model_kwargs is None else sp_model_kwargs

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

           try:
               import sentencepiece as spm
           except ImportError:
               logger.warning(
                   '''You need to install SentencePiece to use XLMRobertaTokenizer: https://github.com/google/sentencepiece'''
                   ''' pip install sentencepiece''')
               raise

           __a						       =				spm.SentencePieceProcessor(**self.sp_model_kwargs)
           self.sp_model.Load(str(__SCREAMING_SNAKE_CASE))
           __a						       =				vocab_file

           # Original fairseq vocab and spm vocab must be "aligned":
           # Vocab    |    0    |    1    |   2    |    3    |  4  |  5  |  6  |   7   |   8   |  9
           # -------- | ------- | ------- | ------ | ------- | --- | --- | --- | ----- | ----- | ----
           # fairseq  | '<s>'   | '<pad>' | '</s>' | '<unk>' | ',' | '.' | '▁' | 's'   | '▁de' | '-'
           # spm      | '<unk>' | '<s>'   | '</s>' | ','     | '.' | '▁' | 's' | '▁de' | '-'   | '▁a'

           # put special tokens and [unused] tokens into the vocab
           __a						       =				{'''[PAD]''': 0, '''[CLS]''': 1, '''[SEP]''': 2, '''[UNK]''': 3, '''[MASK]''': 4}

           for i in range(10):
               __a						       =				F'[unused{i}]'
               __a						       =				5 + i

           # The first "real" token "," has position 15 in the embedding vocab and position 3 in the spm vocab
           __a						       =				12
           __a						       =				{v: k for k, v in self.fairseq_tokens_to_ids.items()}
           for k in self.fairseq_tokens_to_ids.keys():
               self.unique_no_split_tokens.append(__SCREAMING_SNAKE_CASE)



       def __getstate__(		self							:     Dict):


           '''simple docstring'''

           __a						       =				self.__dict__.copy()
           __a						       =				None
           return state



       def __setstate__(		self							:     Optional[int]     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]):


           '''simple docstring'''

           __a						       =				d
           try:
               import sentencepiece as spm
           except ImportError:
               logger.warning(
                   '''You need to install SentencePiece to use XLMRobertaTokenizer: https://github.com/google/sentencepiece'''
                   ''' pip install sentencepiece''')
               raise

           # for backward compatibility
           if not hasattr(self     ,		'''sp_model_kwargs'''):
               __a						       =				{}

           __a						       =				spm.SentencePieceProcessor(**self.sp_model_kwargs)
           self.sp_model.Load(self.vocab_file)



       def 		_lowerCamelCase			(		self							:     Dict     ,		__SCREAMING_SNAKE_CASE							:     List[int]     ,		__SCREAMING_SNAKE_CASE							:     Optional[List[int]] = None     ,		__SCREAMING_SNAKE_CASE							:     bool = False):


           '''simple docstring'''

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

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



       def 		_lowerCamelCase			(		self							:     List[Any]     ,		__SCREAMING_SNAKE_CASE							:     List[int]     ,		__SCREAMING_SNAKE_CASE							:     Optional[List[int]] = None):


           '''simple docstring'''

           __a						       =				[self.sep_token_id]

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



       @property
       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

           return len(self.sp_model) + self.fairseq_offset



       def 		_lowerCamelCase			(		self							:     int):


           '''simple docstring'''

           __a						       =				{self.convert_ids_to_tokens(__SCREAMING_SNAKE_CASE): i for i in range(self.vocab_size)}
           vocab.update(self.added_tokens_encoder)
           return vocab



       def 		_lowerCamelCase			(		self							:     List[str]     ,		__SCREAMING_SNAKE_CASE							:     str):


           '''simple docstring'''

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



       def 		_lowerCamelCase			(		self							:     Tuple     ,		__SCREAMING_SNAKE_CASE							:     Dict):


           '''simple docstring'''

           if token in self.fairseq_tokens_to_ids:
               return self.fairseq_tokens_to_ids[token]
           __a						       =				self.sp_model.PieceToId(__SCREAMING_SNAKE_CASE)

           # Need to return unknown token if the SP model returned 0
           return spm_id + self.fairseq_offset if spm_id else self.unk_token_id



       def 		_lowerCamelCase			(		self							:     Union[str, Any]     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]):


           '''simple docstring'''

           if index in self.fairseq_ids_to_tokens:
               return self.fairseq_ids_to_tokens[index]
           return self.sp_model.IdToPiece(index - self.fairseq_offset)



       def 		_lowerCamelCase			(		self							:     Union[str, Any]     ,		__SCREAMING_SNAKE_CASE							:     Tuple):


           '''simple docstring'''

           __a						       =				''''''.join(__SCREAMING_SNAKE_CASE).replace(__SCREAMING_SNAKE_CASE     ,		''' ''').strip()
           return out_string



       def 		_lowerCamelCase			(		self							:     List[Any]     ,		__SCREAMING_SNAKE_CASE							:     str     ,		__SCREAMING_SNAKE_CASE							:     Optional[str] = None):


           '''simple docstring'''

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

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

           return (out_vocab_file,)





       def 		_lowerCamelCase			(		self							:     int     ,		__SCREAMING_SNAKE_CASE							:     List[int]     ,		__SCREAMING_SNAKE_CASE							:     Optional[List[int]] = None):


           '''simple docstring'''

           if token_ids_a is None:
               return token_ids_a + [self.sep_token_id]
           __a						       =				[self.sep_token_id]
           return token_ids_a + sep + token_ids_a + sep









import math







class 		_snake_case  :




 def __init__(		self					,  _lowerCamelCase=0    ):  # a graph with Node 0,1,...,N-1
       a						:Optional[int] 							=       n
       a						:Union[str, Any] 							=       [
           [math.inf for j in range(0					,  _lowerCamelCase    )] for i in range(0					,  _lowerCamelCase    )
       ]  # adjacency matrix for weight
       a						:List[Any] 							=       [
           [math.inf for j in range(0					,  _lowerCamelCase    )] for i in range(0					,  _lowerCamelCase    )
       ]  # dp[i][j] stores minimum distance from i to j




 def        SCREAMING_SNAKE_CASE__				(		self					,  _lowerCamelCase					,  _lowerCamelCase					,  _lowerCamelCase    ):
       a						:Tuple 							=       w




 def        SCREAMING_SNAKE_CASE__				(		self    ):
       for k in range(0					,  self.n    ):
             for i in range(0					,  self.n    ):
                   for j in range(0					,  self.n    ):
                         a						:Union[str, Any] 							=       min(self.dp[i][j]					,  self.dp[i][k] + self.dp[k][j]    )




 def        SCREAMING_SNAKE_CASE__				(		self					,  _lowerCamelCase					,  _lowerCamelCase    ):
       return self.dp[u][v]


if __name__ == "__main__":
     snake_case				:    str       				=     Graph(5)
     graph.add_edge(0, 2, 9)
     graph.add_edge(0, 4, 10)
     graph.add_edge(1, 3, 5)
     graph.add_edge(2, 3, 7)
     graph.add_edge(3, 0, 10)
     graph.add_edge(3, 1, 2)
     graph.add_edge(3, 2, 1)
     graph.add_edge(3, 4, 6)
     graph.add_edge(4, 1, 3)
     graph.add_edge(4, 2, 4)
     graph.add_edge(4, 3, 9)
     graph.floyd_warshall()
     graph.show_min(1, 4)
     graph.show_min(0, 3)





