



'''simple docstring'''

import unittest

from transformers import AlbertTokenizer, AlbertTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


__lowerCAmelCase						      =       get_tests_dir('''fixtures/spiece.model''')

@require_sentencepiece
@require_tokenizers
class      __magic_name__						(   _lowerCAmelCase      ,						unittest.TestCase       ):
							lowerCAmelCase	:   str           = AlbertTokenizer
							lowerCAmelCase	:   Tuple           = AlbertTokenizerFast
							lowerCAmelCase	:   Optional[Any]           = True
							lowerCAmelCase	:   Union[str, Any]           = True
							lowerCAmelCase	:   Union[str, Any]           = True







							def 							__lowercase      (							self :	Dict		):
									super().setUp()

									# We have a SentencePiece fixture for testing
									_a					:				Optional[Any]				=							AlbertTokenizer(_lowercase		)
									tokenizer.save_pretrained(self.tmpdirname		)







							def 							__lowercase      (							self :	Tuple     ,_UpperCAmelCase :	str		):
									_a					:				int				=							'this is a test'
									_a					:				str				=							'this is a test'
									return input_text, output_text







							def 							__lowercase      (							self :	Tuple		):
									_a					:				int				=							'<pad>'
									_a					:				Optional[int]				=							0

									self.assertEqual(self.get_tokenizer()._convert_token_to_id(_lowercase		)     ,_lowercase		)
									self.assertEqual(self.get_tokenizer()._convert_id_to_token(_lowercase		)     ,_lowercase		)







							def 							__lowercase      (							self :	str		):
									_a					:				int				=							list(self.get_tokenizer().get_vocab().keys()		)

									self.assertEqual(vocab_keys[0]     ,'<pad>'		)
									self.assertEqual(vocab_keys[1]     ,'<unk>'		)
									self.assertEqual(vocab_keys[-1]     ,'▁eloquent'		)
									self.assertEqual(len(_lowercase		)     ,30000		)







							def 							__lowercase      (							self :	Dict		):
									self.assertEqual(self.get_tokenizer().vocab_size     ,30000		)







							def 							__lowercase      (							self :	Dict		):
									if not self.test_rust_tokenizer:
											return

									_a					:				List[Any]				=							self.get_tokenizer()
									_a					:				Dict				=							self.get_rust_tokenizer()

									_a					:				int				=							'I was born in 92000, and this is falsé.'

									_a					:				Tuple				=							tokenizer.tokenize(_lowercase		)
									_a					:				str				=							rust_tokenizer.tokenize(_lowercase		)
									self.assertListEqual(_lowercase     ,_lowercase		)

									_a					:				str				=							tokenizer.encode(_lowercase     ,add_special_tokens=_lowercase		)
									_a					:				Dict				=							rust_tokenizer.encode(_lowercase     ,add_special_tokens=_lowercase		)
									self.assertListEqual(_lowercase     ,_lowercase		)

									_a					:				Dict				=							self.get_rust_tokenizer()
									_a					:				Dict				=							tokenizer.encode(_lowercase		)
									_a					:				Tuple				=							rust_tokenizer.encode(_lowercase		)
									self.assertListEqual(_lowercase     ,_lowercase		)







							def 							__lowercase      (							self :	Dict		):
									_a					:				List[str]				=							AlbertTokenizer(_lowercase     ,keep_accents=_lowercase		)

									_a					:				Optional[int]				=							tokenizer.tokenize('This is a test'		)
									self.assertListEqual(_lowercase     ,['▁this', '▁is', '▁a', '▁test']		)

									self.assertListEqual(tokenizer.convert_tokens_to_ids(_lowercase		)     ,[48, 25, 21, 1289]		)

									_a					:				int				=							tokenizer.tokenize('I was born in 92000, and this is falsé.'		)
									self.assertListEqual(
									    _lowercase     ,['▁i', '▁was', '▁born', '▁in', '▁9', '2000', ',', '▁and', '▁this', '▁is', '▁fal', 's', 'é', '.']		)
									_a					:				Union[str, Any]				=							tokenizer.convert_tokens_to_ids(_lowercase		)
									self.assertListEqual(_lowercase     ,[31, 23, 386, 19, 561, 3050, 15, 17, 48, 25, 8256, 18, 1, 9]		)

									_a					:				Tuple				=							tokenizer.convert_ids_to_tokens(_lowercase		)
									self.assertListEqual(
									    _lowercase     ,['▁i', '▁was', '▁born', '▁in', '▁9', '2000', ',', '▁and', '▁this', '▁is', '▁fal', 's', '<unk>', '.']     ,)







							def 							__lowercase      (							self :	int		):
									_a					:				Optional[Any]				=							AlbertTokenizer(_lowercase		)

									_a					:				List[Any]				=							tokenizer.encode('sequence builders'		)
									_a					:				Any				=							tokenizer.encode('multi-sequence build'		)

									_a					:				Optional[Any]				=							tokenizer.build_inputs_with_special_tokens(_lowercase		)
									_a					:				List[str]				=							tokenizer.build_inputs_with_special_tokens(_lowercase     ,_lowercase		)

									assert encoded_sentence == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]
									assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [
									    tokenizer.sep_token_id
									]







							@slow
							def 							__lowercase      (							self :	List[Any]		):
									# fmt: off
									_a					:				List[Any]				=							{'attention_mask': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], 'input_ids': [[2, 21970, 13, 5, 6092, 167, 28, 7103, 2153, 673, 8, 7028, 12051, 18, 17, 7103, 2153, 673, 8, 3515, 18684, 8, 4461, 6, 1927, 297, 8, 12060, 2607, 18, 13, 5, 4461, 15, 10538, 38, 8, 135, 15, 822, 58, 15, 993, 10363, 15, 1460, 8005, 4461, 15, 993, 255, 2328, 9, 9, 9, 6, 26, 1112, 816, 3260, 13, 5, 103, 2377, 6, 17, 1112, 816, 2782, 13, 5, 103, 10641, 6, 29, 84, 2512, 2430, 782, 18684, 2761, 19, 808, 2430, 2556, 17, 855, 1480, 9477, 4091, 128, 11712, 15, 7103, 2153, 673, 17, 24883, 9990, 9, 3], [2, 11502, 25, 1006, 20, 782, 8, 11809, 855, 1732, 19393, 18667, 37, 367, 21018, 69, 1854, 34, 11860, 19124, 27, 156, 225, 17, 193, 4141, 19, 65, 9124, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 14, 2231, 886, 2385, 17659, 84, 14, 16792, 1952, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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_lowercase     ,model_name='albert-base-v2'     ,revision='6b6560eaf5ff2e250b00c50f380c5389a9c2d82e'     ,)









'''simple docstring'''

from __future__ import annotations

from collections.abc import Iterator
from typing import Any

class      __magic_name__						:







							def __init__(							self :	Dict     ,_UpperCAmelCase :	Any		):
									_a					:				Any				=							data
									_a					:				Node | None				=							None

class      __magic_name__						:







							def __init__(							self :	Any		):
									_a					:				int				=							None
									_a					:				Optional[int]				=							None







							def __iter__(							self :	Optional[int]		):
									_a					:				List[Any]				=							self.head
									while self.head:
											yield node.data
											_a					:				str				=							node.next
											if node == self.head:
													break







							def __len__(							self :	Any		):
									return sum(1 for _ in self		)







							def __repr__(							self :	int		):
									return "->".join(str(_UpperCAmelCase		) for item in iter(self		)		)







							def 							__lowercase      (							self :	Optional[Any]     ,_UpperCAmelCase :	Any		):
									self.insert_nth(len(self		)     ,_UpperCAmelCase		)







							def 							__lowercase      (							self :	str     ,_UpperCAmelCase :	Any		):
									self.insert_nth(0     ,_UpperCAmelCase		)







							def 							__lowercase      (							self :	List[str]     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	Any		):
									if index < 0 or index > len(self		):
											raise IndexError('list index out of range.'		)
									_a					:				List[str]				=							Node(_UpperCAmelCase		)
									if self.head is None:
											_a					:				Tuple				=							new_node  # first node points itself
											_a					:				int				=							new_node
									elif index == 0:  # insert at head
											_a					:				Any				=							self.head
											_a					:				Tuple				=							new_node
									else:
											_a					:				Any				=							self.head
											for _ in range(index - 1		):
													_a					:				int				=							temp.next
											_a					:				Optional[int]				=							temp.next
											_a					:				int				=							new_node
											if index == len(self		) - 1:  # insert at tail
													_a					:				Optional[int]				=							new_node







							def 							__lowercase      (							self :	List[Any]		):
									return self.delete_nth(0		)







							def 							__lowercase      (							self :	Dict		):
									return self.delete_nth(len(self		) - 1		)







							def 							__lowercase      (							self :	Union[str, Any]     ,_UpperCAmelCase :	int = 0		):
									if not 0 <= index < len(self		):
											raise IndexError('list index out of range.'		)
									_a					:				Optional[int]				=							self.head
									if self.head == self.tail:  # just one node
											_a					:				Optional[int]				=							None
									elif index == 0:  # delete head node
											_a					:				Dict				=							self.tail.next.next
											_a					:				Dict				=							self.head.next
									else:
											_a					:				List[Any]				=							self.head
											for _ in range(index - 1		):
													_a					:				Union[str, Any]				=							temp.next
											_a					:				Optional[int]				=							temp.next
											_a					:				List[str]				=							temp.next.next
											if index == len(self		) - 1:  # delete at tail
													_a					:				int				=							temp
									return delete_node.data







							def 							__lowercase      (							self :	int		):
									return len(self		) == 0



def 					__lowerCamelCase					(				)      ->				None:
		_a					:				int				=							CircularLinkedList()
		assert len(lowerCAmelCase_  ) == 0
		assert circular_linked_list.is_empty() is True
		assert str(lowerCAmelCase_  ) == ""

		try:
				circular_linked_list.delete_front()
				raise AssertionError  # This should not happen
		except IndexError:
				assert True  # This should happen

		try:
				circular_linked_list.delete_tail()
				raise AssertionError  # This should not happen
		except IndexError:
				assert True  # This should happen

		try:
				circular_linked_list.delete_nth(-1  )
				raise AssertionError
		except IndexError:
				assert True

		try:
				circular_linked_list.delete_nth(0  )
				raise AssertionError
		except IndexError:
				assert True

		assert circular_linked_list.is_empty() is True
		for i in range(5  ):
				assert len(lowerCAmelCase_  ) == i
				circular_linked_list.insert_nth(lowerCAmelCase_						,      i + 1  )
		assert str(lowerCAmelCase_  ) == "->".join(str(lowerCAmelCase_  ) for i in range(1						,      6  )  )

		circular_linked_list.insert_tail(6  )
		assert str(lowerCAmelCase_  ) == "->".join(str(lowerCAmelCase_  ) for i in range(1						,      7  )  )
		circular_linked_list.insert_head(0  )
		assert str(lowerCAmelCase_  ) == "->".join(str(lowerCAmelCase_  ) for i in range(0						,      7  )  )

		assert circular_linked_list.delete_front() == 0
		assert circular_linked_list.delete_tail() == 6
		assert str(lowerCAmelCase_  ) == "->".join(str(lowerCAmelCase_  ) for i in range(1						,      6  )  )
		assert circular_linked_list.delete_nth(2  ) == 3

		circular_linked_list.insert_nth(2						,      3  )
		assert str(lowerCAmelCase_  ) == "->".join(str(lowerCAmelCase_  ) for i in range(1						,      6  )  )

		assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
							import doctest

							doctest.testmod()




