




'''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 typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_lowerCamelCase      :						Any							=  {"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLNetConfig"""]}

try:
  if not is_sentencepiece_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase      :						int							=  ["""XLNetTokenizer"""]

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase      :						int							=  ["""XLNetTokenizerFast"""]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase      :						Union[str, Any]							=  [
      """XLNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """XLNetForMultipleChoice""",
      """XLNetForQuestionAnswering""",
      """XLNetForQuestionAnsweringSimple""",
      """XLNetForSequenceClassification""",
      """XLNetForTokenClassification""",
      """XLNetLMHeadModel""",
      """XLNetModel""",
      """XLNetPreTrainedModel""",
      """load_tf_weights_in_xlnet""",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase      :						Dict							=  [
      """TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """TFXLNetForMultipleChoice""",
      """TFXLNetForQuestionAnsweringSimple""",
      """TFXLNetForSequenceClassification""",
      """TFXLNetForTokenClassification""",
      """TFXLNetLMHeadModel""",
      """TFXLNetMainLayer""",
      """TFXLNetModel""",
      """TFXLNetPreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig

  try:
    if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_xlnet import XLNetTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_xlnet_fast import XLNetTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_xlnet import (
        XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        XLNetForMultipleChoice,
        XLNetForQuestionAnswering,
        XLNetForQuestionAnsweringSimple,
        XLNetForSequenceClassification,
        XLNetForTokenClassification,
        XLNetLMHeadModel,
        XLNetModel,
        XLNetPreTrainedModel,
        load_tf_weights_in_xlnet,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_xlnet import (
        TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFXLNetForMultipleChoice,
        TFXLNetForQuestionAnsweringSimple,
        TFXLNetForSequenceClassification,
        TFXLNetForTokenClassification,
        TFXLNetLMHeadModel,
        TFXLNetMainLayer,
        TFXLNetModel,
        TFXLNetPreTrainedModel,
    )

else:
  import sys

  _lowerCamelCase      :						int							=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


