
"""simple docstring"""




import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible





class  snake_case     (							unittest.TestCase   ):

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''safety_checker/pytorch_model.bin''',
									    '''safety_checker/model.safetensors''',
									    '''vae/diffusion_pytorch_model.bin''',
									    '''vae/diffusion_pytorch_model.safetensors''',
									    '''text_encoder/pytorch_model.bin''',
									    '''text_encoder/model.safetensors''',
									    '''unet/diffusion_pytorch_model.bin''',
									    '''unet/diffusion_pytorch_model.safetensors''',
									]
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''unet/diffusion_pytorch_model.bin''',
									    '''unet/diffusion_pytorch_model.safetensors''',
									]
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''safety_checker/pytorch_model.bin''',
									    '''safety_checker/model.safetensors''',
									    '''vae/diffusion_pytorch_model.bin''',
									    '''vae/diffusion_pytorch_model.safetensors''',
									    '''text_encoder/pytorch_model.bin''',
									    '''text_encoder/model.safetensors''',
									    '''unet/diffusion_pytorch_model.bin''',
									    # Removed: 'unet/diffusion_pytorch_model.safetensors',
									]
									self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''text_encoder/pytorch_model.bin''',
									    '''text_encoder/model.safetensors''',
									]
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''safety_checker/pytorch_model.bin''',
									    '''safety_checker/model.safetensors''',
									    '''vae/diffusion_pytorch_model.bin''',
									    '''vae/diffusion_pytorch_model.safetensors''',
									    '''text_encoder/pytorch_model.bin''',
									    # Removed: 'text_encoder/model.safetensors',
									    '''unet/diffusion_pytorch_model.bin''',
									    '''unet/diffusion_pytorch_model.safetensors''',
									]
									self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''safety_checker/pytorch_model.fp16.bin''',
									    '''safety_checker/model.fp16.safetensors''',
									    '''vae/diffusion_pytorch_model.fp16.bin''',
									    '''vae/diffusion_pytorch_model.fp16.safetensors''',
									    '''text_encoder/pytorch_model.fp16.bin''',
									    '''text_encoder/model.fp16.safetensors''',
									    '''unet/diffusion_pytorch_model.fp16.bin''',
									    '''unet/diffusion_pytorch_model.fp16.safetensors''',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''unet/diffusion_pytorch_model.fp16.bin''',
									    '''unet/diffusion_pytorch_model.fp16.safetensors''',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''unet/diffusion_pytorch_model.bin''',
									    '''unet/diffusion_pytorch_model.safetensors''',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''safety_checker/pytorch_model.fp16.bin''',
									    '''safety_checker/model.fp16.safetensors''',
									    '''vae/diffusion_pytorch_model.fp16.bin''',
									    '''vae/diffusion_pytorch_model.fp16.safetensors''',
									    '''text_encoder/pytorch_model.fp16.bin''',
									    '''text_encoder/model.fp16.safetensors''',
									    '''unet/diffusion_pytorch_model.fp16.bin''',
									    # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''text_encoder/pytorch_model.fp16.bin''',
									    '''text_encoder/model.fp16.safetensors''',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''text_encoder/pytorch_model.bin''',
									    '''text_encoder/model.safetensors''',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )







							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = [
									    '''safety_checker/pytorch_model.fp16.bin''',
									    '''safety_checker/model.fp16.safetensors''',
									    '''vae/diffusion_pytorch_model.fp16.bin''',
									    '''vae/diffusion_pytorch_model.fp16.safetensors''',
									    '''text_encoder/pytorch_model.fp16.bin''',
									    # 'text_encoder/model.fp16.safetensors',
									    '''unet/diffusion_pytorch_model.fp16.bin''',
									    '''unet/diffusion_pytorch_model.fp16.safetensors''',
									]
									SCREAMING_SNAKE_CASE_						 = '''fp16'''
									self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_       ,       variant=SCREAMING_SNAKE_CASE_    )    )

"""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  snake_case     (							__lowercase       ,			unittest.TestCase   ):
							UpperCAmelCase__						     =      CTRLTokenizer
							UpperCAmelCase__						     =      False
							UpperCAmelCase__						     =      False

							def _lowercase					(self    ):

									"""simple docstring"""







									super().setUp()

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

									SCREAMING_SNAKE_CASE_						 = os.path.join(self.tmpdirname       ,       VOCAB_FILES_NAMES['''vocab_file''']    )
									SCREAMING_SNAKE_CASE_						 = 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(SCREAMING_SNAKE_CASE_    ) + '''\n'''    )
									with open(self.merges_file       ,       '''w'''       ,       encoding='''utf-8'''    ) as fp:
											fp.write('''\n'''.join(SCREAMING_SNAKE_CASE_    )    )

							def _lowercase					(self       ,       **SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







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

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = '''adapt react readapt apt'''
									SCREAMING_SNAKE_CASE_						 = '''adapt react readapt apt'''
									return input_text, output_text







							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = CTRLTokenizer(self.vocab_file       ,       self.merges_file       ,       **self.special_tokens_map    )
									SCREAMING_SNAKE_CASE_						 = '''adapt react readapt apt'''
									SCREAMING_SNAKE_CASE_						 = '''adapt re@@ a@@ c@@ t re@@ adapt apt'''.split()
									SCREAMING_SNAKE_CASE_						 = tokenizer.tokenize(SCREAMING_SNAKE_CASE_    )
									self.assertListEqual(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = tokens + [tokenizer.unk_token]

									SCREAMING_SNAKE_CASE_						 = [0, 1, 2, 4, 5, 1, 0, 3, 6]
									self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )