



import json
import os
import unittest

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

from ...test_tokenization_common import TokenizerTesterMixin



class  __lowerCAmelCase     (	lowerCAmelCase__  ,	unittest.TestCase   ):
 lowerCAmelCase__       					=  CTRLTokenizer
 lowerCAmelCase__       					=  False
 lowerCAmelCase__       					=  False




 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    super().setUp()

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

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




 def        lowerCamelCase      (						self	,				**__UpperCAmelCase				):



    '''simple docstring'''
    kwargs.update(self.special_tokens_map				)
    return CTRLTokenizer.from_pretrained(self.tmpdirname	,				**__UpperCAmelCase				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    '''adapt react readapt apt'''
    __lowerCamelCase													=    '''adapt react readapt apt'''
    return input_text, output_text




 def        lowerCamelCase      (						self				):



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

    __lowerCamelCase													=    tokens + [tokenizer.unk_token]

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











import torch

from diffusers import StableDiffusionPipeline


a_			=					"""path-to-your-trained-model"""
a_			=					StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""")

a_			=					"""A photo of sks dog in a bucket"""
a_			=					pipe(prompt, num_inference_steps=50, guidance_scale=7.5).images[0]

image.save("""dog-bucket.png""")






