




'''simple docstring'''



from typing import Any, Callable, Dict, List, Optional, Union

import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker


UpperCamelCase_    	=				"CompVis/stable-diffusion-v1-1"
UpperCamelCase_    	=				"CompVis/stable-diffusion-v1-2"
UpperCamelCase_    	=				"CompVis/stable-diffusion-v1-3"
UpperCamelCase_    	=				"CompVis/stable-diffusion-v1-4"






class 							_a				(			SCREAMING_SNAKE_CASE ):





       '''simple docstring'''






       def __init__(      self,							A,							A,							A,							A,							A,							A,							A,							A = True,							):







             '''simple docstring'''







             super()._init_()

             SCREAMING_SNAKE_CASE   :      Optional[int]    					=						StableDiffusionPipeline.from_pretrained(A  )
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						StableDiffusionPipeline.from_pretrained(A  )
             SCREAMING_SNAKE_CASE   :      int    					=						StableDiffusionPipeline.from_pretrained(A  )
             SCREAMING_SNAKE_CASE   :      Tuple    					=						StableDiffusionPipeline(
                 vae=A,							text_encoder=A,							tokenizer=A,							unet=A,							scheduler=A,							safety_checker=A,							feature_extractor=A,							requires_safety_checker=A,							)

             self.register_modules(pipelinea=self.pipea,							pipelinea=self.pipea,							pipelinea=self.pipea,							pipelinea=self.pipea  )







       @property
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             return {k: getattr(self,							A  ) for k in self.config.keys() if not k.startswith('_'  )}







       def        UpperCamelCase_							(      self,							A = "auto"  ):







             '''simple docstring'''







             if slice_size == "auto":
                   # half the attention head size is usually a good trade-off between
                   # speed and memory
                   SCREAMING_SNAKE_CASE   :      List[str]    					=						self.unet.config.attention_head_dim // 2
             self.unet.set_attention_slice(A  )







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             self.enable_attention_slicing(A  )







       @torch.no_grad()
       def        UpperCamelCase_							(      self,							A,							A = 512,							A = 512,							A = 50,							A = 7.5,							A = None,							A = 1,							A = 0.0,							A = None,							A = None,							A = "pil",							A = True,							A = None,							A = 1,							**A,							):







             '''simple docstring'''







             return self.pipea(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)







       @torch.no_grad()
       def        UpperCamelCase_							(      self,							A,							A = 512,							A = 512,							A = 50,							A = 7.5,							A = None,							A = 1,							A = 0.0,							A = None,							A = None,							A = "pil",							A = True,							A = None,							A = 1,							**A,							):







             '''simple docstring'''







             return self.pipea(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)







       @torch.no_grad()
       def        UpperCamelCase_							(      self,							A,							A = 512,							A = 512,							A = 50,							A = 7.5,							A = None,							A = 1,							A = 0.0,							A = None,							A = None,							A = "pil",							A = True,							A = None,							A = 1,							**A,							):







             '''simple docstring'''







             return self.pipea(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)







       @torch.no_grad()
       def        UpperCamelCase_							(      self,							A,							A = 512,							A = 512,							A = 50,							A = 7.5,							A = None,							A = 1,							A = 0.0,							A = None,							A = None,							A = "pil",							A = True,							A = None,							A = 1,							**A,							):







             '''simple docstring'''







             return self.pipea(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)







       @torch.no_grad()
       def        UpperCamelCase_							(      self,							A,							A = 512,							A = 512,							A = 50,							A = 7.5,							A = None,							A = 1,							A = 0.0,							A = None,							A = None,							A = "pil",							A = True,							A = None,							A = 1,							**A,							):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						'cuda' if torch.cuda.is_available() else 'cpu'
             self.to(A  )

             # Checks if the height and width are divisible by 8 or not
             if height % 8 != 0 or width % 8 != 0:
                   raise ValueError(F"`height` and `width` must be divisible by 8 but are {height} and {width}."  )

             # Get first result from Stable Diffusion Checkpoint v1.1
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						self.textaimg_sda_a(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)

             # Get first result from Stable Diffusion Checkpoint v1.2
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						self.textaimg_sda_a(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)

             # Get first result from Stable Diffusion Checkpoint v1.3
             SCREAMING_SNAKE_CASE   :      Any    					=						self.textaimg_sda_a(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)

             # Get first result from Stable Diffusion Checkpoint v1.4
             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						self.textaimg_sda_a(
                 prompt=A,							height=A,							width=A,							num_inference_steps=A,							guidance_scale=A,							negative_prompt=A,							num_images_per_prompt=A,							eta=A,							generator=A,							latents=A,							output_type=A,							return_dict=A,							callback=A,							callback_steps=A,							**A,							)

             # Get all result images into a single list and pass it via StableDiffusionPipelineOutput for final result
             return StableDiffusionPipelineOutput([resa[0], resa[0], resa[0], resa[0]]  )








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        __lowerCAmelCase					(			__magic_name__					):

			"""simple docstring"""







			snake_case_  						=			'''xlm-roberta-xl'''


			def __init__( self     ,		lowerCamelCase__=250_880     ,		lowerCamelCase__=2_560     ,		lowerCamelCase__=36     ,		lowerCamelCase__=32     ,		lowerCamelCase__=10_240     ,		lowerCamelCase__="gelu"     ,		lowerCamelCase__=0.1     ,		lowerCamelCase__=0.1     ,		lowerCamelCase__=514     ,		lowerCamelCase__=1     ,		lowerCamelCase__=0.02     ,		lowerCamelCase__=1e-05     ,		lowerCamelCase__=1     ,		lowerCamelCase__=0     ,		lowerCamelCase__=2     ,		lowerCamelCase__="absolute"     ,		lowerCamelCase__=True     ,		lowerCamelCase__=None     ,		**lowerCamelCase__     ,		)       -> str:



							'''simple docstring'''
							super().__init__(pad_token_id=lowerCamelCase__     ,		bos_token_id=lowerCamelCase__     ,		eos_token_id=lowerCamelCase__     ,		**lowerCamelCase__				)
							__lowerCamelCase									=       vocab_size
							__lowerCamelCase									=       hidden_size
							__lowerCamelCase									=       num_hidden_layers
							__lowerCamelCase									=       num_attention_heads
							__lowerCamelCase									=       hidden_act
							__lowerCamelCase									=       intermediate_size
							__lowerCamelCase									=       hidden_dropout_prob
							__lowerCamelCase									=       attention_probs_dropout_prob
							__lowerCamelCase									=       max_position_embeddings
							__lowerCamelCase									=       type_vocab_size
							__lowerCamelCase									=       initializer_range
							__lowerCamelCase									=       layer_norm_eps
							__lowerCamelCase									=       position_embedding_type
							__lowerCamelCase									=       use_cache
							__lowerCamelCase									=       classifier_dropout







class        __lowerCAmelCase					(			__magic_name__					):

			"""simple docstring"""







			@property
			def  lowercase_       ( self				)       -> Mapping[str, Mapping[int, str]]:



							'''simple docstring'''
							if self.task == "multiple-choice":
											__lowerCamelCase									=       {0: 'batch', 1: 'choice', 2: 'sequence'}
							else:
											__lowerCamelCase									=       {0: 'batch', 1: 'sequence'}
							return OrderedDict(
							    [
							        ('input_ids', dynamic_axis),
							        ('attention_mask', dynamic_axis),
							    ]				)


