


"""simple docstring"""






import unittest
import warnings
from dataclasses import dataclass

from transformers.convert_slow_tokenizer import SpmConverter
from transformers.testing_utils import get_tests_dir


@dataclass
class       lowerCamelCase_		:





				"""simple docstring"""







				_lowerCAmelCase   :   str


class       lowerCamelCase_		(      unittest.TestCase ):





				"""simple docstring"""







				def 	lowerCAmelCase__		(    self  ):
								SCREAMING_SNAKE_CASE__  				=					get_tests_dir("fixtures/test_sentencepiece.model"  )
								SCREAMING_SNAKE_CASE__  				=					get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.model"  )

								SCREAMING_SNAKE_CASE__  				=					FakeOriginalTokenizer(vocab_file=UpperCAmelCase__  )

								with warnings.catch_warnings(record=UpperCAmelCase__  ) as w:
												SCREAMING_SNAKE_CASE__  				=					SpmConverter(UpperCAmelCase__  )
								self.assertEqual(len(UpperCAmelCase__  )							,		0  )

								SCREAMING_SNAKE_CASE__  				=					FakeOriginalTokenizer(vocab_file=UpperCAmelCase__  )

								with warnings.catch_warnings(record=UpperCAmelCase__  ) as w:
												SCREAMING_SNAKE_CASE__  				=					SpmConverter(UpperCAmelCase__  )
								self.assertEqual(len(UpperCAmelCase__  )							,		1  )

								self.assertIn(
								    "The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option"
								    " which is not implemented in the fast tokenizers."							,		str(w[0].message  )							,		)




"""simple docstring"""






def __lowercase  (   lowerCamelCase_	:   str	):
				SCREAMING_SNAKE_CASE__  				=					str(lowerCamelCase_	).strip()
				if not oct_string:
								raise ValueError("Empty string was passed to the function"	)
				SCREAMING_SNAKE_CASE__  				=					oct_string[0] == "-"
				if is_negative:
								SCREAMING_SNAKE_CASE__  				=					oct_string[1:]
				if not oct_string.isdigit() or not all(0 <= int(lowerCamelCase_	) <= 7 for char in oct_string	):
								raise ValueError("Non-octal value was passed to the function"	)
				SCREAMING_SNAKE_CASE__  				=					0
				for char in oct_string:
								SCREAMING_SNAKE_CASE__  				=					8 * decimal_number + int(lowerCamelCase_	)
				if is_negative:
								SCREAMING_SNAKE_CASE__  				=					-decimal_number
				return decimal_number


if __name__ == "__main__":
	from doctest import testmod

	testmod()
