






'''simple docstring'''

import tempfile
import unittest

from make_student import create_student_by_copying_alternating_layers

from transformers import AutoConfig
from transformers.file_utils import cached_property
from transformers.testing_utils import require_torch


UpperCamelCase							="sshleifer/bart-tiny-random"
UpperCamelCase							="patrickvonplaten/t5-tiny-random"




@require_torch
class     A    (      unittest.TestCase						):






 """simple docstring"""





 @cached_property
 def   _UpperCAmelCase       (							self ):
       return AutoConfig.from_pretrained(__lowerCAmelCase )
 def   _UpperCAmelCase       (							self ):
       UpperCamelCase_    ,			*UpperCamelCase_				:   Union[str, Any]					    =							create_student_by_copying_alternating_layers(__lowerCAmelCase			,     tempfile.mkdtemp()			,     e=1			,     d=1 )
       self.assertEqual(student.config.num_hidden_layers			,     1 )
 def   _UpperCAmelCase       (							self ):
       UpperCamelCase_    ,			*UpperCamelCase_				:   List[str]					    =							create_student_by_copying_alternating_layers(__lowerCAmelCase			,     tempfile.mkdtemp()			,     e=1			,     d=__lowerCAmelCase )
 def   _UpperCAmelCase       (							self ):
       UpperCamelCase_    ,			*UpperCamelCase_				:   List[str]					    =							create_student_by_copying_alternating_layers(__lowerCAmelCase			,     tempfile.mkdtemp()			,     e=1			,     d=__lowerCAmelCase )
       self.assertEqual(student.config.encoder_layers			,     1 )
       self.assertEqual(student.config.decoder_layers			,     self.teacher_config.encoder_layers )
 def   _UpperCAmelCase       (							self ):
       UpperCamelCase_    ,			*UpperCamelCase_				:   str					    =							create_student_by_copying_alternating_layers(__lowerCAmelCase			,     tempfile.mkdtemp()			,     e=1			,     d=1 )
       self.assertEqual(student.config.encoder_layers			,     1 )
       self.assertEqual(student.config.decoder_layers			,     1 )





 def   _UpperCAmelCase       (							self ):
       with self.assertRaises(__lowerCAmelCase ):
             create_student_by_copying_alternating_layers(__lowerCAmelCase			,     tempfile.mkdtemp()			,     e=__lowerCAmelCase			,     d=__lowerCAmelCase )














'''simple docstring'''

import torch

from diffusers import StableDiffusionPipeline


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

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

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






