



"""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    UpperCamelCase     :




	"""simple docstring"""
	SCREAMING_SNAKE_CASE_				:    str







class    UpperCamelCase     (			unittest.TestCase    ):




	"""simple docstring"""






	def 					lowerCamelCase__ (			self					):
			_lowercase							:      str			=					get_tests_dir("""fixtures/test_sentencepiece.model"""					)
			_lowercase							:      int			=					get_tests_dir("""fixtures/test_sentencepiece_with_bytefallback.model"""					)

			_lowercase							:      Tuple			=					FakeOriginalTokenizer(vocab_file=UpperCAmelCase_					)

			with warnings.catch_warnings(record=UpperCAmelCase_					) as w:
					_lowercase							:      int			=					SpmConverter(UpperCAmelCase_					)
			self.assertEqual(len(UpperCAmelCase_					)							,0					)

			_lowercase							:      Any			=					FakeOriginalTokenizer(vocab_file=UpperCAmelCase_					)

			with warnings.catch_warnings(record=UpperCAmelCase_					) as w:
					_lowercase							:      Dict			=					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"""







import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import Mock, patch

import diffusers.utils.hub_utils





class    UpperCamelCase     (			unittest.TestCase    ):




	"""simple docstring"""






	@patch("""diffusers.utils.hub_utils.get_full_repo_name"""					)
	def 					lowerCamelCase__ (			self							,UpperCAmelCase_					):
			_lowercase							:      List[Any]			=					"""full_repo_name"""
			with TemporaryDirectory() as tmpdir:
					# Dummy args values
					_lowercase							:      Optional[Any]			=					Mock()
					_lowercase							:      int			=					tmpdir
					_lowercase							:      int			=					0
					_lowercase							:      Optional[Any]			=					"""hub_token"""
					_lowercase							:      Optional[Any]			=					"""dataset_name"""
					_lowercase							:      List[Any]			=					0.01
					_lowercase							:      Tuple			=					10_00_00
					_lowercase							:      Optional[Any]			=					1_00_00
					_lowercase							:      Optional[int]			=					0.01
					_lowercase							:      Tuple			=					0.02
					_lowercase							:      int			=					0.03
					_lowercase							:      Optional[int]			=					0.0005
					_lowercase							:      Tuple			=					0.000001
					_lowercase							:      int			=					1
					_lowercase							:      List[str]			=					10
					_lowercase							:      Optional[Any]			=					0.001
					_lowercase							:      int			=					0.1
					_lowercase							:      Optional[Any]			=					0.2
					_lowercase							:      Tuple			=					True

					# Model card mush be rendered and saved
					diffusers.utils.hub_utils.create_model_card(UpperCAmelCase_							,model_name="""model_name"""					)
					self.assertTrue((Path(UpperCAmelCase_					) / """README.md""").is_file()					)



