




"""simple docstring"""






import gc
import unittest

import numpy as np
import torch

from diffusers import StableDiffusionKDiffusionPipeline
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()




@slow
@require_torch_gpu
class   a__			(       unittest.TestCase  ):





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




											"""simple docstring"""







											super().tearDown()
											gc.collect()
											torch.cuda.empty_cache()





						def       __UpperCamelCase     (							self      :	List[str])						->       Any:




											"""simple docstring"""







											_lowerCAmelCase:List[Any]									=  StableDiffusionKDiffusionPipeline.from_pretrained('''CompVis/stable-diffusion-v1-4''')
											_lowerCAmelCase:Union[str, Any]									=  sd_pipe.to(lowerCAmelCase_)
											sd_pipe.set_progress_bar_config(disable=lowerCAmelCase_)

											sd_pipe.set_scheduler('''sample_euler''')

											_lowerCAmelCase:List[Any]									=  '''A painting of a squirrel eating a burger'''
											_lowerCAmelCase:List[Any]									=  torch.manual_seed(0)
											_lowerCAmelCase:int									=  sd_pipe([prompt]     ,generator=lowerCAmelCase_     ,guidance_scale=9.0     ,num_inference_steps=20     ,output_type='''np''')

											_lowerCAmelCase:Tuple									=  output.images

											_lowerCAmelCase:Any									=  image[0, -3:, -3:, -1]

											assert image.shape == (1, 512, 512, 3)
											_lowerCAmelCase:Tuple									=  np.array([0.0447, 0.0492, 0.0468, 0.0408, 0.0383, 0.0408, 0.0354, 0.0380, 0.0339])

											assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2





						def       __UpperCamelCase     (							self      :	Dict)						->       int:




											"""simple docstring"""







											_lowerCAmelCase:List[str]									=  StableDiffusionKDiffusionPipeline.from_pretrained('''stabilityai/stable-diffusion-2-1-base''')
											_lowerCAmelCase:Union[str, Any]									=  sd_pipe.to(lowerCAmelCase_)
											sd_pipe.set_progress_bar_config(disable=lowerCAmelCase_)

											sd_pipe.set_scheduler('''sample_euler''')

											_lowerCAmelCase:List[str]									=  '''A painting of a squirrel eating a burger'''
											_lowerCAmelCase:Any									=  torch.manual_seed(0)
											_lowerCAmelCase:str									=  sd_pipe([prompt]     ,generator=lowerCAmelCase_     ,guidance_scale=9.0     ,num_inference_steps=20     ,output_type='''np''')

											_lowerCAmelCase:List[str]									=  output.images

											_lowerCAmelCase:Any									=  image[0, -3:, -3:, -1]

											assert image.shape == (1, 512, 512, 3)
											_lowerCAmelCase:Tuple									=  np.array([0.1237, 0.1320, 0.1438, 0.1359, 0.1390, 0.1132, 0.1277, 0.1175, 0.1112])

											assert np.abs(image_slice.flatten() - expected_slice).max() < 5E-1







						def       __UpperCamelCase     (							self      :	str)						->       Any:




											"""simple docstring"""







											_lowerCAmelCase:Tuple									=  StableDiffusionKDiffusionPipeline.from_pretrained('''stabilityai/stable-diffusion-2-1-base''')
											_lowerCAmelCase:Optional[Any]									=  sd_pipe.to(lowerCAmelCase_)
											sd_pipe.set_progress_bar_config(disable=lowerCAmelCase_)

											sd_pipe.set_scheduler('''sample_dpmpp_2m''')

											_lowerCAmelCase:Optional[Any]									=  '''A painting of a squirrel eating a burger'''
											_lowerCAmelCase:List[str]									=  torch.manual_seed(0)
											_lowerCAmelCase:Any									=  sd_pipe(
											    [prompt]     ,generator=lowerCAmelCase_     ,guidance_scale=7.5     ,num_inference_steps=15     ,output_type='''np'''     ,use_karras_sigmas=lowerCAmelCase_     ,)

											_lowerCAmelCase:Any									=  output.images

											_lowerCAmelCase:Optional[int]									=  image[0, -3:, -3:, -1]

											assert image.shape == (1, 512, 512, 3)
											_lowerCAmelCase:str									=  np.array(
											    [0.11381689, 0.12112921, 0.1389457, 0.12549606, 0.1244964, 0.10831517, 0.11562866, 0.10867816, 0.10499048])

											assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2












"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase__						=			logging.get_logger(__name__)

UpperCamelCase__						=			{
    '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json''',
}




class   a__			(       UpperCamelCase_  ):
						snake_case__             = '''roc_bert'''





						def __init__(							self      :	Union[str, Any]     ,a__      :	Union[str, Any]=3_0522     ,a__      :	List[Any]=768     ,a__      :	Tuple=12     ,a__      :	Optional[int]=12     ,a__      :	Any=3072     ,a__      :	Optional[int]="gelu"     ,a__      :	Union[str, Any]=0.1     ,a__      :	List[str]=0.1     ,a__      :	Dict=512     ,a__      :	int=2     ,a__      :	Dict=0.02     ,a__      :	Dict=1E-12     ,a__      :	int=True     ,a__      :	Optional[int]=0     ,a__      :	Union[str, Any]="absolute"     ,a__      :	List[Any]=None     ,a__      :	str=True     ,a__      :	str=True     ,a__      :	List[str]=768     ,a__      :	Optional[int]=910     ,a__      :	Any=512     ,a__      :	str=2_4858     ,a__      :	List[str]=True     ,**a__      :	str     ,)						->       List[str]:




											"""simple docstring"""







											_lowerCAmelCase:Tuple									=  vocab_size
											_lowerCAmelCase:Any									=  max_position_embeddings
											_lowerCAmelCase:Union[str, Any]									=  hidden_size
											_lowerCAmelCase:Optional[Any]									=  num_hidden_layers
											_lowerCAmelCase:int									=  num_attention_heads
											_lowerCAmelCase:int									=  intermediate_size
											_lowerCAmelCase:Union[str, Any]									=  hidden_act
											_lowerCAmelCase:Any									=  hidden_dropout_prob
											_lowerCAmelCase:List[Any]									=  attention_probs_dropout_prob
											_lowerCAmelCase:List[Any]									=  initializer_range
											_lowerCAmelCase:Dict									=  type_vocab_size
											_lowerCAmelCase:Dict									=  layer_norm_eps
											_lowerCAmelCase:str									=  use_cache
											_lowerCAmelCase:Any									=  enable_pronunciation
											_lowerCAmelCase:List[str]									=  enable_shape
											_lowerCAmelCase:Optional[int]									=  pronunciation_embed_dim
											_lowerCAmelCase:Union[str, Any]									=  pronunciation_vocab_size
											_lowerCAmelCase:str									=  shape_embed_dim
											_lowerCAmelCase:List[Any]									=  shape_vocab_size
											_lowerCAmelCase:str									=  concat_input
											_lowerCAmelCase:Optional[int]									=  position_embedding_type
											_lowerCAmelCase:Any									=  classifier_dropout
											super().__init__(pad_token_id=a__     ,**a__)






