
"""simple docstring"""


class   __a  :






       def __init__(  self :							Dict       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							Union[str, Any]=None       ,      UpperCAmelCase_ :							List[str]=None			)->  List[str]:







              """simple docstring"""
              UpperCamelCase					 =		data
              UpperCamelCase					 =		previous
              UpperCamelCase					 =		next_node






       def __str__(  self :							Tuple			)->  str:







              """simple docstring"""
              return f"{self.data}"






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]			)->  int:







              """simple docstring"""
              return self.data






       def 	_SCREAMING_SNAKE_CASE       (  self :							Dict			)->  Dict:







              """simple docstring"""
              return self.next






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]			)->  int:







              """simple docstring"""
              return self.previous





class   __a  :






       def __init__(  self :							Union[str, Any]       ,      UpperCAmelCase_ :							List[str]			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		head






       def __iter__(  self :							Optional[int]			)->  Optional[int]:







              """simple docstring"""
              return self






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  List[str]:







              """simple docstring"""
              if not self.current:
                     raise StopIteration
              else:
                     UpperCamelCase					 =		self.current.get_data()
                     UpperCamelCase					 =		self.current.get_next()
                     return value





class   __a  :






       def __init__(  self :							Optional[Any]			)->  List[str]:







              """simple docstring"""
              UpperCamelCase					 =		None  # First node in list
              UpperCamelCase					 =		None  # Last node in list






       def __str__(  self :							Union[str, Any]			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		self.head
              UpperCamelCase					 =		[]
              while current is not None:
                     nodes.append(current.get_data()			)
                     UpperCamelCase					 =		current.get_next()
              return " ".join(str(UpperCAmelCase_			) for node in nodes			)






       def __contains__(  self :							Tuple       ,      UpperCAmelCase_ :							int			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		self.head
              while current:
                     if current.get_data() == value:
                            return True
                     UpperCamelCase					 =		current.get_next()
              return False






       def __iter__(  self :							Any			)->  Union[str, Any]:







              """simple docstring"""
              return LinkedListIterator(self.head			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							str			)->  Union[str, Any]:







              """simple docstring"""
              if self.head:
                     return self.head.get_data()
              return None






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]			)->  Optional[Any]:







              """simple docstring"""
              if self.tail:
                     return self.tail.get_data()
              return None






       def 	_SCREAMING_SNAKE_CASE       (  self :							str       ,      UpperCAmelCase_ :							Node			)->  None:







              """simple docstring"""
              if self.head is None:
                     UpperCamelCase					 =		node
                     UpperCamelCase					 =		node
              else:
                     self.insert_before_node(self.head       ,      UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Tuple       ,      UpperCAmelCase_ :							Node			)->  None:







              """simple docstring"""
              if self.head is None:
                     self.set_head(UpperCAmelCase_			)
              else:
                     self.insert_after_node(self.tail       ,      UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[Any]       ,      UpperCAmelCase_ :							int			)->  None:







              """simple docstring"""
              UpperCamelCase					 =		Node(UpperCAmelCase_			)
              if self.head is None:
                     self.set_head(UpperCAmelCase_			)
              else:
                     self.set_tail(UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							int       ,      UpperCAmelCase_ :							Node       ,      UpperCAmelCase_ :							Node			)->  None:







              """simple docstring"""
              UpperCamelCase					 =		node
              UpperCamelCase					 =		node.previous

              if node.get_previous() is None:
                     UpperCamelCase					 =		node_to_insert
              else:
                     UpperCamelCase					 =		node_to_insert

              UpperCamelCase					 =		node_to_insert






       def 	_SCREAMING_SNAKE_CASE       (  self :							Any       ,      UpperCAmelCase_ :							Node       ,      UpperCAmelCase_ :							Node			)->  None:







              """simple docstring"""
              UpperCamelCase					 =		node
              UpperCamelCase					 =		node.next

              if node.get_next() is None:
                     UpperCamelCase					 =		node_to_insert
              else:
                     UpperCamelCase					 =		node_to_insert

              UpperCamelCase					 =		node_to_insert






       def 	_SCREAMING_SNAKE_CASE       (  self :							Any       ,      UpperCAmelCase_ :							int       ,      UpperCAmelCase_ :							int			)->  None:







              """simple docstring"""
              UpperCamelCase					 =		1
              UpperCamelCase					 =		Node(UpperCAmelCase_			)
              UpperCamelCase					 =		self.head
              while node:
                     if current_position == position:
                            self.insert_before_node(UpperCAmelCase_       ,      UpperCAmelCase_			)
                            return
                     current_position += 1
                     UpperCamelCase					 =		node.next
              self.insert_after_node(self.tail       ,      UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Any       ,      UpperCAmelCase_ :							int			)->  Node:







              """simple docstring"""
              UpperCamelCase					 =		self.head
              while node:
                     if node.get_data() == item:
                            return node
                     UpperCamelCase					 =		node.get_next()
              raise Exception("Node not found"			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Tuple       ,      UpperCAmelCase_ :							int			)->  Dict:







              """simple docstring"""
              if (node := self.get_node(UpperCAmelCase_			)) is not None:
                     if node == self.head:
                            UpperCamelCase					 =		self.head.get_next()

                     if node == self.tail:
                            UpperCamelCase					 =		self.tail.get_previous()

                     self.remove_node_pointers(UpperCAmelCase_			)






       @staticmethod
       def 	_SCREAMING_SNAKE_CASE       (  UpperCAmelCase_ :							Node			)->  None:







              """simple docstring"""
              if node.get_next():
                     UpperCamelCase					 =		node.previous

              if node.get_previous():
                     UpperCamelCase					 =		node.next

              UpperCamelCase					 =		None
              UpperCamelCase					 =		None






       def 	_SCREAMING_SNAKE_CASE       (  self :							Any			)->  Union[str, Any]:







              """simple docstring"""
              return self.head is None





def 	lowerCamelCase__			(							)->							None:







       """simple docstring"""


if __name__ == "__main__":
      import doctest

      doctest.testmod()







"""simple docstring"""


import os
import unittest

from transformers import FunnelTokenizer, FunnelTokenizerFast
from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin



@require_tokenizers
class   __a  (      _lowerCAmelCase    ,     unittest.TestCase	):
       UpperCamelCase_		:					str   =			FunnelTokenizer
       UpperCamelCase_		:					Any   =			FunnelTokenizerFast
       UpperCamelCase_		:					Union[str, Any]   =			True
       UpperCamelCase_		:					Tuple   =			True






       def 	_SCREAMING_SNAKE_CASE       (  self :							Tuple			)->  Optional[int]:







              """simple docstring"""
              super().setUp()

              UpperCamelCase					 =		[
                  "<unk>",
                  "<cls>",
                  "<sep>",
                  "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 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]       ,      **UpperCAmelCase_ :							Optional[Any]			)->  str:







              """simple docstring"""
              return FunnelTokenizer.from_pretrained(self.tmpdirname       ,      **UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Dict       ,      **UpperCAmelCase_ :							Any			)->  Union[str, Any]:







              """simple docstring"""
              return FunnelTokenizerFast.from_pretrained(self.tmpdirname       ,      **UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Dict       ,      UpperCAmelCase_ :							Tuple			)->  str:







              """simple docstring"""
              UpperCamelCase					 =		"UNwant\u00E9d,running"
              UpperCamelCase					 =		"unwanted, running"
              return input_text, output_text






       def 	_SCREAMING_SNAKE_CASE       (  self :							str			)->  List[str]:







              """simple docstring"""
              UpperCamelCase					 =		self.tokenizer_class(self.vocab_file			)

              UpperCamelCase					 =		tokenizer.tokenize("UNwant\u00E9d,running"			)
              self.assertListEqual(UpperCAmelCase_       ,      ["un", "##want", "##ed", ",", "runn", "##ing"]			)
              self.assertListEqual(tokenizer.convert_tokens_to_ids(UpperCAmelCase_			)       ,      [7, 4, 5, 10, 8, 9]			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  Optional[int]:







              """simple docstring"""
              UpperCamelCase					 =		self.get_tokenizers(do_lower_case=UpperCAmelCase_			)
              for tokenizer in tokenizers:
                     UpperCamelCase					 =		tokenizer("UNwant\u00E9d,running"			)
                     UpperCamelCase					 =		len(inputs["input_ids"]			) - 1
                     self.assertListEqual(inputs["token_type_ids"]       ,      [2] + [0] * sentence_len			)

                     UpperCamelCase					 =		tokenizer("UNwant\u00E9d,running"       ,      "UNwant\u00E9d,running"			)
                     self.assertListEqual(inputs["token_type_ids"]       ,      [2] + [0] * sentence_len + [1] * sentence_len			)





