





'''simple docstring'''






import json
import os
import unittest

from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer

from ...test_tokenization_common import TokenizerTesterMixin




class  _A (					__lowercase						,					unittest.TestCase		):
		lowercase__:   Optional[Any]				     =   CTRLTokenizer
		lowercase__:   Dict				     =   False
		lowercase__:   List[Any]				     =   False

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


					"""simple docstring"""

					super().setUp()

					# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
					__snake_case					:      Any							      =     ["""adapt""", """re@@""", """a@@""", """apt""", """c@@""", """t""", """<unk>"""]
					__snake_case					:      Optional[Any]							      =     dict(zip(__magic_name__  ,      range(len(__magic_name__			)			)			)			)
					__snake_case					:      Optional[Any]							      =     ["""#version: 0.2""", """a p""", """ap t</w>""", """r e""", """a d""", """ad apt</w>""", """"""]
					__snake_case					:      int							      =     {"""unk_token""": """<unk>"""}

					__snake_case					:      List[str]							      =     os.path.join(self.tmpdirname  ,      VOCAB_FILES_NAMES["""vocab_file"""]			)
					__snake_case					:      Tuple							      =     os.path.join(self.tmpdirname  ,      VOCAB_FILES_NAMES["""merges_file"""]			)
					with open(self.vocab_file  ,      """w"""  ,      encoding="""utf-8"""			) as fp:
								fp.write(json.dumps(__magic_name__			) + """\n"""			)
					with open(self.merges_file  ,      """w"""  ,      encoding="""utf-8"""			) as fp:
								fp.write("""\n""".join(__magic_name__			)			)

		def 	lowercase__     (   self					:   Union[str, Any]  ,      **__magic_name__					:   List[Any]			)					->    Optional[Any]:


					"""simple docstring"""

					kwargs.update(self.special_tokens_map			)
					return CTRLTokenizer.from_pretrained(self.tmpdirname  ,      **__magic_name__			)

		def 	lowercase__     (   self					:   Tuple  ,      __magic_name__					:   Tuple			)					->    List[Any]:


					"""simple docstring"""

					__snake_case					:      Tuple							      =     """adapt react readapt apt"""
					__snake_case					:      Tuple							      =     """adapt react readapt apt"""
					return input_text, output_text

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


					"""simple docstring"""

					__snake_case					:      int							      =     CTRLTokenizer(self.vocab_file  ,      self.merges_file  ,      **self.special_tokens_map			)
					__snake_case					:      str							      =     """adapt react readapt apt"""
					__snake_case					:      List[str]							      =     """adapt re@@ a@@ c@@ t re@@ adapt apt""".split()
					__snake_case					:      List[str]							      =     tokenizer.tokenize(__magic_name__			)
					self.assertListEqual(__magic_name__  ,      __magic_name__			)

					__snake_case					:      Union[str, Any]							      =     tokens + [tokenizer.unk_token]

					__snake_case					:      Union[str, Any]							      =     [0, 1, 2, 4, 5, 1, 0, 3, 6]
					self.assertListEqual(tokenizer.convert_tokens_to_ids(__magic_name__			)  ,      __magic_name__			)









'''simple docstring'''






import os

from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home


__UpperCamelCase					    =	HUGGINGFACE_HUB_CACHE


__UpperCamelCase					    =	"config.json"
__UpperCamelCase					    =	"diffusion_pytorch_model.bin"
__UpperCamelCase					    =	"diffusion_flax_model.msgpack"
__UpperCamelCase					    =	"model.onnx"
__UpperCamelCase					    =	"diffusion_pytorch_model.safetensors"
__UpperCamelCase					    =	"weights.pb"
__UpperCamelCase					    =	"https://huggingface.co"
__UpperCamelCase					    =	default_cache_path
__UpperCamelCase					    =	"diffusers_modules"
__UpperCamelCase					    =	os.getenv("HF_MODULES_CACHE", os.path.join(hf_cache_home, "modules"))
__UpperCamelCase					    =	["fp16", "non-ema"]
__UpperCamelCase					    =	".self_attn"


