






'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


a_					=	logging.get_logger(__name__)

a_					=	{
    'facebook/xlm-roberta-xl': 'https://huggingface.co/facebook/xlm-roberta-xl/resolve/main/config.json',
    'facebook/xlm-roberta-xxl': 'https://huggingface.co/facebook/xlm-roberta-xxl/resolve/main/config.json',
    # See all XLM-RoBERTa-XL models at https://huggingface.co/models?filter=xlm-roberta-xl
}






class        __SCREAMING_SNAKE_CASE (     lowerCamelCase			):
 snake_case_												=							"""xlm-roberta-xl"""




 def __init__( self		:							int   , __lowercase		:							Optional[Any]=25_08_80   , __lowercase		:							Optional[int]=25_60   , __lowercase		:							Union[str, Any]=36   , __lowercase		:							int=32   , __lowercase		:							Dict=1_02_40   , __lowercase		:							int="gelu"   , __lowercase		:							Dict=0.1   , __lowercase		:							Tuple=0.1   , __lowercase		:							Optional[int]=5_14   , __lowercase		:							Union[str, Any]=1   , __lowercase		:							Tuple=0.02   , __lowercase		:							int=1e-05   , __lowercase		:							Dict=1   , __lowercase		:							List[Any]=0   , __lowercase		:							Optional[Any]=2   , __lowercase		:							str="absolute"   , __lowercase		:							Union[str, Any]=True   , __lowercase		:							Tuple=None   , **__lowercase		:							Any   , )		->  List[Any]:
       super().__init__(pad_token_id=__lowercase   , bos_token_id=__lowercase   , eos_token_id=__lowercase   , **__lowercase )
       SCREAMING_SNAKE_CASE__       :			int													=vocab_size
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=hidden_size
       SCREAMING_SNAKE_CASE__       :			str													=num_hidden_layers
       SCREAMING_SNAKE_CASE__       :			Dict													=num_attention_heads
       SCREAMING_SNAKE_CASE__       :			List[str]													=hidden_act
       SCREAMING_SNAKE_CASE__       :			Any													=intermediate_size
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=hidden_dropout_prob
       SCREAMING_SNAKE_CASE__       :			Dict													=attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE__       :			List[Any]													=max_position_embeddings
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=type_vocab_size
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=initializer_range
       SCREAMING_SNAKE_CASE__       :			List[Any]													=layer_norm_eps
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=position_embedding_type
       SCREAMING_SNAKE_CASE__       :			str													=use_cache
       SCREAMING_SNAKE_CASE__       :			int													=classifier_dropout






class        __SCREAMING_SNAKE_CASE (     lowerCamelCase			):




 @property
 def        __magic_name__		( self		:							Union[str, Any] )		->  Mapping[str, Mapping[int, str]]:
       if self.task == "multiple-choice":
             SCREAMING_SNAKE_CASE__       :			Tuple													={0: '''batch''', 1: '''choice''', 2: '''sequence'''}
       else:
             SCREAMING_SNAKE_CASE__       :			Any													={0: '''batch''', 1: '''sequence'''}
       return OrderedDict(
           [
               ('''input_ids''', dynamic_axis),
               ('''attention_mask''', dynamic_axis),
           ] )







'''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        __SCREAMING_SNAKE_CASE (     unittest.TestCase			):




 def        __magic_name__		( self		:							List[str] )		->  Optional[Any]:
       # clean up the VRAM after each test
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()




 def        __magic_name__		( self		:							Union[str, Any] )		->  Dict:
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=StableDiffusionKDiffusionPipeline.from_pretrained('''CompVis/stable-diffusion-v1-4''' )
       SCREAMING_SNAKE_CASE__       :			str													=sd_pipe.to(__lowercase )
       sd_pipe.set_progress_bar_config(disable=__lowercase )

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

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

       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=output.images

       SCREAMING_SNAKE_CASE__       :			int													=image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       SCREAMING_SNAKE_CASE__       :			Any													=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        __magic_name__		( self		:							List[str] )		->  List[Any]:
       SCREAMING_SNAKE_CASE__       :			List[str]													=StableDiffusionKDiffusionPipeline.from_pretrained('''stabilityai/stable-diffusion-2-1-base''' )
       SCREAMING_SNAKE_CASE__       :			int													=sd_pipe.to(__lowercase )
       sd_pipe.set_progress_bar_config(disable=__lowercase )

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

       SCREAMING_SNAKE_CASE__       :			Any													='''A painting of a squirrel eating a burger'''
       SCREAMING_SNAKE_CASE__       :			Dict													=torch.manual_seed(0 )
       SCREAMING_SNAKE_CASE__       :			Tuple													=sd_pipe([prompt]   , generator=__lowercase   , guidance_scale=9.0   , num_inference_steps=20   , output_type='''np''' )

       SCREAMING_SNAKE_CASE__       :			Dict													=output.images

       SCREAMING_SNAKE_CASE__       :			Dict													=image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       SCREAMING_SNAKE_CASE__       :			List[str]													=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        __magic_name__		( self		:							List[str] )		->  List[Any]:
       SCREAMING_SNAKE_CASE__       :			Any													=StableDiffusionKDiffusionPipeline.from_pretrained('''stabilityai/stable-diffusion-2-1-base''' )
       SCREAMING_SNAKE_CASE__       :			Tuple													=sd_pipe.to(__lowercase )
       sd_pipe.set_progress_bar_config(disable=__lowercase )

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

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

       SCREAMING_SNAKE_CASE__       :			Optional[int]													=output.images

       SCREAMING_SNAKE_CASE__       :			Dict													=image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=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