





"""simple docstring"""





import os
import unittest

from transformers import ElectraTokenizerFast
from transformers.models.electra.tokenization_electra import (
    VOCAB_FILES_NAMES,
    BasicTokenizer,
    ElectraTokenizer,
    WordpieceTokenizer,
    _is_control,
    _is_punctuation,
    _is_whitespace,
)
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin, filter_non_english





@require_tokenizers
class 							_lowerCamelCase   (							_a	,      unittest.TestCase			):
						UpperCAmelCase_			=      ElectraTokenizer
						UpperCAmelCase_			=      ElectraTokenizerFast
						UpperCAmelCase_			=      True
						UpperCAmelCase_			=      True
						UpperCAmelCase_			=      filter_non_english


						def      snake_case_ (self		)			-> Any:
								super().setUp()

								UpperCamelCase =						[
								    "[UNK]",
								    "[CLS]",
								    "[SEP]",
								    "[PAD]",
								    "[MASK]",
								    "want",
								    "##want",
								    "##ed",
								    "wa",
								    "un",
								    "runn",
								    "##ing",
								    ",",
								    "low",
								    "lowest",
								]
								UpperCamelCase =						os.path.join(self.tmpdirname ,				VOCAB_FILES_NAMES["vocab_file"]		)
								with open(self.vocab_file ,				"w" ,				encoding="utf-8"		) as vocab_writer:
										vocab_writer.write("".join([x + "\n" for x in vocab_tokens]		)		)


						def      snake_case_ (self ,				__a		)			-> Optional[Any]:
								UpperCamelCase =						"UNwant\u00E9d,running"
								UpperCamelCase =						"unwanted, running"
								return input_text, output_text


						def      snake_case_ (self		)			-> str:
								UpperCamelCase =						self.tokenizer_class(self.vocab_file		)

								UpperCamelCase =						tokenizer.tokenize("UNwant\u00E9d,running"		)
								self.assertListEqual(__a ,				["un", "##want", "##ed", ",", "runn", "##ing"]		)
								self.assertListEqual(tokenizer.convert_tokens_to_ids(__a		) ,				[9, 6, 7, 12, 10, 11]		)


						def      snake_case_ (self		)			-> Optional[Any]:
								if not self.test_rust_tokenizer:
										return

								UpperCamelCase =						self.get_tokenizer()
								UpperCamelCase =						self.get_rust_tokenizer()

								UpperCamelCase =						"UNwant\u00E9d,running"

								UpperCamelCase =						tokenizer.tokenize(__a		)
								UpperCamelCase =						rust_tokenizer.tokenize(__a		)
								self.assertListEqual(__a ,				__a		)

								UpperCamelCase =						tokenizer.encode(__a ,				add_special_tokens=__a		)
								UpperCamelCase =						rust_tokenizer.encode(__a ,				add_special_tokens=__a		)
								self.assertListEqual(__a ,				__a		)

								UpperCamelCase =						self.get_rust_tokenizer()
								UpperCamelCase =						tokenizer.encode(__a		)
								UpperCamelCase =						rust_tokenizer.encode(__a		)
								self.assertListEqual(__a ,				__a		)

								# With lower casing
								UpperCamelCase =						self.get_tokenizer(do_lower_case=__a		)
								UpperCamelCase =						self.get_rust_tokenizer(do_lower_case=__a		)

								UpperCamelCase =						"UNwant\u00E9d,running"

								UpperCamelCase =						tokenizer.tokenize(__a		)
								UpperCamelCase =						rust_tokenizer.tokenize(__a		)
								self.assertListEqual(__a ,				__a		)

								UpperCamelCase =						tokenizer.encode(__a ,				add_special_tokens=__a		)
								UpperCamelCase =						rust_tokenizer.encode(__a ,				add_special_tokens=__a		)
								self.assertListEqual(__a ,				__a		)

								UpperCamelCase =						self.get_rust_tokenizer()
								UpperCamelCase =						tokenizer.encode(__a		)
								UpperCamelCase =						rust_tokenizer.encode(__a		)
								self.assertListEqual(__a ,				__a		)


						def      snake_case_ (self		)			-> str:
								UpperCamelCase =						BasicTokenizer()

								self.assertListEqual(tokenizer.tokenize("ah\u535A\u63A8zz"		) ,				["ah", "\u535A", "\u63A8", "zz"]		)


						def      snake_case_ (self		)			-> List[Any]:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHeLLo!how  \n Are yoU?  "		) ,				["hello", "!", "how", "are", "you", "?"]		)
								self.assertListEqual(tokenizer.tokenize("H\u00E9llo"		) ,				["hello"]		)


						def      snake_case_ (self		)			-> Optional[Any]:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a ,				strip_accents=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "		) ,				["hällo", "!", "how", "are", "you", "?"]		)
								self.assertListEqual(tokenizer.tokenize("H\u00E9llo"		) ,				["h\u00E9llo"]		)


						def      snake_case_ (self		)			-> Optional[Any]:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a ,				strip_accents=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "		) ,				["hallo", "!", "how", "are", "you", "?"]		)
								self.assertListEqual(tokenizer.tokenize("H\u00E9llo"		) ,				["hello"]		)


						def      snake_case_ (self		)			-> Any:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "		) ,				["hallo", "!", "how", "are", "you", "?"]		)
								self.assertListEqual(tokenizer.tokenize("H\u00E9llo"		) ,				["hello"]		)


						def      snake_case_ (self		)			-> Optional[Any]:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHeLLo!how  \n Are yoU?  "		) ,				["HeLLo", "!", "how", "Are", "yoU", "?"]		)


						def      snake_case_ (self		)			-> Optional[int]:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a ,				strip_accents=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "		) ,				["HäLLo", "!", "how", "Are", "yoU", "?"]		)


						def      snake_case_ (self		)			-> List[str]:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a ,				strip_accents=__a		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "		) ,				["HaLLo", "!", "how", "Are", "yoU", "?"]		)


						def      snake_case_ (self		)			-> Any:
								UpperCamelCase =						BasicTokenizer(do_lower_case=__a ,				never_split=["[UNK]"]		)

								self.assertListEqual(
								    tokenizer.tokenize(" \tHeLLo!how  \n Are yoU? [UNK]"		) ,				["HeLLo", "!", "how", "Are", "yoU", "?", "[UNK]"]		)


						def      snake_case_ (self		)			-> int:
								UpperCamelCase =						["[UNK]", "[CLS]", "[SEP]", "want", "##want", "##ed", "wa", "un", "runn", "##ing"]

								UpperCamelCase =						{}
								for i, token in enumerate(__a		):
										UpperCamelCase =						i
								UpperCamelCase =						WordpieceTokenizer(vocab=__a ,				unk_token="[UNK]"		)

								self.assertListEqual(tokenizer.tokenize(""		) ,				[]		)

								self.assertListEqual(tokenizer.tokenize("unwanted running"		) ,				["un", "##want", "##ed", "runn", "##ing"]		)

								self.assertListEqual(tokenizer.tokenize("unwantedX running"		) ,				["[UNK]", "runn", "##ing"]		)


						def      snake_case_ (self		)			-> Tuple:
								self.assertTrue(_is_whitespace(" "		)		)
								self.assertTrue(_is_whitespace("\t"		)		)
								self.assertTrue(_is_whitespace("\r"		)		)
								self.assertTrue(_is_whitespace("\n"		)		)
								self.assertTrue(_is_whitespace("\u00A0"		)		)

								self.assertFalse(_is_whitespace("A"		)		)
								self.assertFalse(_is_whitespace("-"		)		)


						def      snake_case_ (self		)			-> Optional[Any]:
								self.assertTrue(_is_control("\u0005"		)		)

								self.assertFalse(_is_control("A"		)		)
								self.assertFalse(_is_control(" "		)		)
								self.assertFalse(_is_control("\t"		)		)
								self.assertFalse(_is_control("\r"		)		)


						def      snake_case_ (self		)			-> Union[str, Any]:
								self.assertTrue(_is_punctuation("-"		)		)
								self.assertTrue(_is_punctuation("$"		)		)
								self.assertTrue(_is_punctuation("`"		)		)
								self.assertTrue(_is_punctuation("."		)		)

								self.assertFalse(_is_punctuation("A"		)		)
								self.assertFalse(_is_punctuation(" "		)		)


						def      snake_case_ (self		)			-> Tuple:
								UpperCamelCase =						self.get_tokenizer()
								UpperCamelCase =						self.get_rust_tokenizer()

								# Example taken from the issue https://github.com/huggingface/tokenizers/issues/340
								self.assertListEqual([tokenizer.tokenize(__a		) for t in ["Test", "\xad", "test"]] ,				[["[UNK]"], [], ["[UNK]"]]		)

								self.assertListEqual(
								    [rust_tokenizer.tokenize(__a		) for t in ["Test", "\xad", "test"]] ,				[["[UNK]"], [], ["[UNK]"]]		)


						@slow
						def      snake_case_ (self		)			-> int:
								UpperCamelCase =						self.tokenizer_class.from_pretrained("google/electra-base-discriminator"		)

								UpperCamelCase =						tokenizer.encode("sequence builders" ,				add_special_tokens=__a		)
								UpperCamelCase =						tokenizer.encode("multi-sequence build" ,				add_special_tokens=__a		)

								UpperCamelCase =						tokenizer.build_inputs_with_special_tokens(__a		)
								UpperCamelCase =						tokenizer.build_inputs_with_special_tokens(__a ,				__a		)

								assert encoded_sentence == [1_01] + text + [1_02]
								assert encoded_pair == [1_01] + text + [1_02] + text_a + [1_02]


						def      snake_case_ (self		)			-> List[str]:
								for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
										with self.subTest(F"{tokenizer.__class__.__name__} ({pretrained_name})"		):
												UpperCamelCase =						self.rust_tokenizer_class.from_pretrained(__a ,				**__a		)

												UpperCamelCase =						F"A, naïve {tokenizer_r.mask_token} AllenNLP sentence."
												UpperCamelCase =						tokenizer_r.encode_plus(
												    __a ,				return_attention_mask=__a ,				return_token_type_ids=__a ,				return_offsets_mapping=__a ,				add_special_tokens=__a ,				)

												UpperCamelCase =						tokenizer_r.do_lower_case if hasattr(__a ,				"do_lower_case"		) else False
												UpperCamelCase =						(
												    [
												        ((0, 0), tokenizer_r.cls_token),
												        ((0, 1), "A"),
												        ((1, 2), ","),
												        ((3, 5), "na"),
												        ((5, 6), "##ï"),
												        ((6, 8), "##ve"),
												        ((9, 15), tokenizer_r.mask_token),
												        ((16, 21), "Allen"),
												        ((21, 23), "##NL"),
												        ((23, 24), "##P"),
												        ((25, 33), "sentence"),
												        ((33, 34), "."),
												        ((0, 0), tokenizer_r.sep_token),
												    ]
												    if not do_lower_case
												    else [
												        ((0, 0), tokenizer_r.cls_token),
												        ((0, 1), "a"),
												        ((1, 2), ","),
												        ((3, 8), "naive"),
												        ((9, 15), tokenizer_r.mask_token),
												        ((16, 21), "allen"),
												        ((21, 23), "##nl"),
												        ((23, 24), "##p"),
												        ((25, 33), "sentence"),
												        ((33, 34), "."),
												        ((0, 0), tokenizer_r.sep_token),
												    ]
												)

												self.assertEqual(
												    [e[1] for e in expected_results] ,				tokenizer_r.convert_ids_to_tokens(tokens["input_ids"]		)		)
												self.assertEqual([e[0] for e in expected_results] ,				tokens["offset_mapping"]		)




						def      snake_case_ (self		)			-> List[str]:
								UpperCamelCase =						["的", "人", "有"]
								UpperCamelCase =						"".join(__a		)
								for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
										with self.subTest(F"{tokenizer.__class__.__name__} ({pretrained_name})"		):
												UpperCamelCase =						True
												UpperCamelCase =						self.tokenizer_class.from_pretrained(__a ,				**__a		)
												UpperCamelCase =						self.rust_tokenizer_class.from_pretrained(__a ,				**__a		)

												UpperCamelCase =						tokenizer_p.encode(__a ,				add_special_tokens=__a		)
												UpperCamelCase =						tokenizer_r.encode(__a ,				add_special_tokens=__a		)

												UpperCamelCase =						tokenizer_r.convert_ids_to_tokens(__a		)
												UpperCamelCase =						tokenizer_p.convert_ids_to_tokens(__a		)

												# it is expected that each Chinese character is not preceded by "##"
												self.assertListEqual(__a ,				__a		)
												self.assertListEqual(__a ,				__a		)

												UpperCamelCase =						False
												UpperCamelCase =						self.rust_tokenizer_class.from_pretrained(__a ,				**__a		)
												UpperCamelCase =						self.tokenizer_class.from_pretrained(__a ,				**__a		)

												UpperCamelCase =						tokenizer_r.encode(__a ,				add_special_tokens=__a		)
												UpperCamelCase =						tokenizer_p.encode(__a ,				add_special_tokens=__a		)

												UpperCamelCase =						tokenizer_r.convert_ids_to_tokens(__a		)
												UpperCamelCase =						tokenizer_p.convert_ids_to_tokens(__a		)

												# it is expected that only the first Chinese character is not preceded by "##".
												UpperCamelCase =						[
												    F"##{token}" if idx != 0 else token for idx, token in enumerate(__a		)
												]
												self.assertListEqual(__a ,				__a		)
												self.assertListEqual(__a ,				__a		)













from collections import deque
def  __UpperCamelCase    (						snake_case      )    ->		List[str]:


   '''simple docstring'''







   return input(snake_case      ).strip().split(''' '''      )
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		dict[int, list[int]]:


   '''simple docstring'''







   __A    =  {}
   for i in range(snake_case      ):
      __A    =  []

   for e in range(snake_case      ):
      __A   ,		__A    =  (int(snake_case      ) for i in _input(F"Edge {e + 1}: <node1> <node2> "      ))
      graph[x].append(snake_case      )
   return graph
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		dict[int, list[int]]:


   '''simple docstring'''







   __A    =  {}
   for i in range(snake_case      ):
      __A    =  []

   for e in range(snake_case      ):
      __A   ,		__A    =  (int(snake_case      ) for i in _input(F"Edge {e + 1}: <node1> <node2> "      ))
      graph[x].append(snake_case      )
      graph[y].append(snake_case      )
   return graph
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		dict[int, list[tuple[int, int]]]:


   '''simple docstring'''







   __A    =  {}
   for i in range(snake_case      ):
      __A    =  []

   for e in range(snake_case      ):
      __A   ,		__A   ,		__A    =  (int(snake_case      ) for i in _input(F"Edge {e + 1}: <node1> <node2> <weight> "      ))
      graph[x].append((y, w)      )
      graph[y].append((x, w)      )
   return graph


if __name__ == "__main__":
    _UpperCamelCase       ,    _UpperCamelCase       :				List[Any]           =			(int(i) for i in _input("""Number of nodes and edges: """))

    _UpperCamelCase       :				int           =			int(
        _input(
            """Press 1 or 2 or 3 \n"""
            """1. Unweighted directed \n"""
            """2. Unweighted undirected \n"""
            """3. Weighted undirected \n"""
        )[0]
    )

    _UpperCamelCase       :				Optional[Any]           =			{
        1: initialize_unweighted_directed_graph,
        2: initialize_unweighted_undirected_graph,
        3: initialize_weighted_undirected_graph,
    }[graph_choice](n, m)
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		int:


   '''simple docstring'''







   __A   ,		__A    =  {s}, [s]
   print(snake_case      )
   while _s:
      __A    =  0
      for i in g[_s[-1]]:
         if i not in vis:
            _s.append(snake_case      )
            vis.add(snake_case      )
            __A    =  1
            print(snake_case      )
            break
      if not flag:
         _s.pop()
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		Dict:


   '''simple docstring'''







   __A   ,		__A    =  {s}, deque([s]      )
   print(snake_case      )
   while q:
      __A    =  q.popleft()
      for v in g[u]:
         if v not in vis:
            vis.add(snake_case      )
            q.append(snake_case      )
            print(snake_case      )
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		List[Any]:


   '''simple docstring'''







   __A   ,		__A   ,		__A    =  {s: 0}, set(), {s: 0}
   while True:
      if len(snake_case      ) == len(snake_case      ) - 1:
         break
      __A    =  1_0_0_0_0_0
      for i in dist:
         if i not in known and dist[i] < mini:
            __A    =  dist[i]
            __A    =  i
      known.add(snake_case      )
      for v in g[u]:
         if v[0] not in known and dist[u] + v[1] < dist.get(v[0]							,			1_0_0_0_0_0      ):
            __A    =  dist[u] + v[1]
            __A    =  u
   for i in dist:
      if i != s:
         print(dist[i]      )
def  __UpperCamelCase    (						snake_case							,			snake_case=None							,			snake_case=None      )    ->		Any:


   '''simple docstring'''







   if q is None:
      __A    =  [1]
   if ind is None:
      __A    =  [0] * (len(snake_case      ) + 1)  # SInce oth Index is ignored
      for u in g:
         for v in g[u]:
            ind[v] += 1
      __A    =  deque()
      for i in g:
         if ind[i] == 0:
            q.append(snake_case      )
   if len(snake_case      ) == 0:
      return
   __A    =  q.popleft()
   print(snake_case      )
   for w in g[v]:
      ind[w] -= 1
      if ind[w] == 0:
         q.append(snake_case      )
   topo(snake_case							,			snake_case							,			snake_case      )
def  __UpperCamelCase    (						)    ->		Any:


   '''simple docstring'''







   __A    =  input().strip()
   __A    =  []
   for _ in range(snake_case      ):
      a.append(map(snake_case							,			input().strip().split()      )      )
   return a, n
def  __UpperCamelCase    (						snake_case      )    ->		List[Any]:


   '''simple docstring'''







   ((__A)   ,		(__A))    =  a_and_n
   __A    =  list(snake_case      )
   __A    =  [[0] * n for i in range(snake_case      )]
   for k in range(snake_case      ):
      for i in range(snake_case      ):
         for j in range(snake_case      ):
            if dist[i][j] > dist[i][k] + dist[k][j]:
               __A    =  dist[i][k] + dist[k][j]
               __A    =  k
   print(snake_case      )
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		Dict:


   '''simple docstring'''







   __A   ,		__A   ,		__A    =  {s: 0}, set(), {s: 0}
   while True:
      if len(snake_case      ) == len(snake_case      ) - 1:
         break
      __A    =  1_0_0_0_0_0
      for i in dist:
         if i not in known and dist[i] < mini:
            __A    =  dist[i]
            __A    =  i
      known.add(snake_case      )
      for v in g[u]:
         if v[0] not in known and v[1] < dist.get(v[0]							,			1_0_0_0_0_0      ):
            __A    =  v[1]
            __A    =  u
   return dist
def  __UpperCamelCase    (						)    ->		List[str]:


   '''simple docstring'''







   __A   ,		__A    =  map(snake_case							,			input().split(''' '''      )      )
   __A    =  []
   for _ in range(snake_case      ):
      edges.append(map(snake_case							,			input().split(''' '''      )      )      )
   return edges, n
def  __UpperCamelCase    (						snake_case      )    ->		int:


   '''simple docstring'''







   ((__A)   ,		(__A))    =  e_and_n
   e.sort(reverse=snake_case							,			key=lambda snake_case      : x[2]      )
   __A    =  [{i} for i in range(1							,			n + 1      )]
   while True:
      if len(snake_case      ) == 1:
         break
      print(snake_case      )
      __A    =  e.pop()
      for i in range(len(snake_case      )      ):
         if x[0] in s[i]:
            break
      for j in range(len(snake_case      )      ):
         if x[1] in s[j]:
            if i == j:
               break
            s[j].update(s[i]      )
            s.pop(snake_case      )
            break
def  __UpperCamelCase    (						snake_case      )    ->		Tuple:


   '''simple docstring'''







   __A    =  []
   for node in graph:
      if not graph[node]:
         isolated.append(snake_case      )
   return isolated

