


import unittest

from transformers import MobileBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import (
      MODEL_FOR_PRETRAINING_MAPPING,
      MobileBertForMaskedLM,
      MobileBertForMultipleChoice,
      MobileBertForNextSentencePrediction,
      MobileBertForPreTraining,
      MobileBertForQuestionAnswering,
      MobileBertForSequenceClassification,
      MobileBertForTokenClassification,
      MobileBertModel,
  )







class   __lowerCAmelCase			:





   def __init__( self					,			snake_case					,			snake_case=13					,			snake_case=7					,			snake_case=True					,			snake_case=True					,			snake_case=True					,			snake_case=True					,			snake_case=99					,			snake_case=64					,			snake_case=32					,			snake_case=5					,			snake_case=4					,			snake_case=37					,			snake_case="gelu"					,			snake_case=0.1					,			snake_case=0.1					,			snake_case=512					,			snake_case=16					,			snake_case=2					,			snake_case=0.02					,			snake_case=3					,			snake_case=4					,			snake_case=None					,			)				->  Dict:
      """simple docstring"""





      a__	:						Optional[Any]      		=  parent
      a__	:						int      		=  batch_size
      a__	:						Optional[int]      		=  seq_length
      a__	:						Optional[int]      		=  is_training
      a__	:						Dict      		=  use_input_mask
      a__	:						Optional[Any]      		=  use_token_type_ids
      a__	:						str      		=  use_labels
      a__	:						Optional[int]      		=  vocab_size
      a__	:						Optional[Any]      		=  hidden_size
      a__	:						Optional[int]      		=  embedding_size
      a__	:						Union[str, Any]      		=  num_hidden_layers
      a__	:						Any      		=  num_attention_heads
      a__	:						Optional[Any]      		=  intermediate_size
      a__	:						Tuple      		=  hidden_act
      a__	:						List[str]      		=  hidden_dropout_prob
      a__	:						Any      		=  attention_probs_dropout_prob
      a__	:						Optional[int]      		=  max_position_embeddings
      a__	:						Any      		=  type_vocab_size
      a__	:						List[str]      		=  type_sequence_label_size
      a__	:						Any      		=  initializer_range
      a__	:						Tuple      		=  num_labels
      a__	:						str      		=  num_choices
      a__	:						Optional[int]      		=  scope





   def 	_snake_case ( self      )				->  Union[str, Any]:
      """simple docstring"""





      a__	:						int      		=  ids_tensor([self.batch_size, self.seq_length]					,			self.vocab_size      )

      a__	:						Any      		=  None
      if self.use_input_mask:
         a__	:						Any      		=  random_attention_mask([self.batch_size, self.seq_length]      )

      a__	:						Tuple      		=  None
      if self.use_token_type_ids:
         a__	:						List[Any]      		=  ids_tensor([self.batch_size, self.seq_length]					,			self.type_vocab_size      )

      a__	:						Union[str, Any]      		=  None
      a__	:						Optional[Any]      		=  None
      a__	:						str      		=  None
      if self.use_labels:
         a__	:						List[Any]      		=  ids_tensor([self.batch_size]					,			self.type_sequence_label_size      )
         a__	:						Optional[int]      		=  ids_tensor([self.batch_size, self.seq_length]					,			self.num_labels      )
         a__	:						Tuple      		=  ids_tensor([self.batch_size]					,			self.num_choices      )

      a__	:						str      		=  self.get_config()

      return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels





   def 	_snake_case ( self      )				->  Dict:
      """simple docstring"""





      return MobileBertConfig(
          vocab_size=self.vocab_size					,			hidden_size=self.hidden_size					,			num_hidden_layers=self.num_hidden_layers					,			num_attention_heads=self.num_attention_heads					,			intermediate_size=self.intermediate_size					,			embedding_size=self.embedding_size					,			hidden_act=self.hidden_act					,			hidden_dropout_prob=self.hidden_dropout_prob					,			attention_probs_dropout_prob=self.attention_probs_dropout_prob					,			max_position_embeddings=self.max_position_embeddings					,			type_vocab_size=self.type_vocab_size					,			is_decoder=UpperCamelCase__					,			initializer_range=self.initializer_range					,			)





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  int:
      """simple docstring"""





      a__	:						Any      		=  MobileBertModel(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Optional[int]      		=  model(UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__      )
      a__	:						int      		=  model(UpperCamelCase__					,			token_type_ids=UpperCamelCase__      )
      a__	:						Tuple      		=  model(UpperCamelCase__      )

      self.parent.assertEqual(result.last_hidden_state.shape					,			(self.batch_size, self.seq_length, self.hidden_size)      )
      self.parent.assertEqual(result.pooler_output.shape					,			(self.batch_size, self.hidden_size)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  Optional[int]:
      """simple docstring"""





      a__	:						List[Any]      		=  MobileBertForMaskedLM(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Optional[Any]      		=  model(UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			labels=UpperCamelCase__      )
      self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.seq_length, self.vocab_size)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  int:
      """simple docstring"""





      a__	:						Union[str, Any]      		=  MobileBertForNextSentencePrediction(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Union[str, Any]      		=  model(
          UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			labels=UpperCamelCase__					,			)
      self.parent.assertEqual(result.logits.shape					,			(self.batch_size, 2)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  Union[str, Any]:
      """simple docstring"""





      a__	:						Tuple      		=  MobileBertForPreTraining(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						str      		=  model(
          UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			labels=UpperCamelCase__					,			next_sentence_label=UpperCamelCase__					,			)
      self.parent.assertEqual(result.prediction_logits.shape					,			(self.batch_size, self.seq_length, self.vocab_size)      )
      self.parent.assertEqual(result.seq_relationship_logits.shape					,			(self.batch_size, 2)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  List[Any]:
      """simple docstring"""





      a__	:						Any      		=  MobileBertForQuestionAnswering(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Tuple      		=  model(
          UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			start_positions=UpperCamelCase__					,			end_positions=UpperCamelCase__					,			)
      self.parent.assertEqual(result.start_logits.shape					,			(self.batch_size, self.seq_length)      )
      self.parent.assertEqual(result.end_logits.shape					,			(self.batch_size, self.seq_length)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  Optional[Any]:
      """simple docstring"""





      a__	:						Optional[int]      		=  self.num_labels
      a__	:						Dict      		=  MobileBertForSequenceClassification(UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Dict      		=  model(UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			labels=UpperCamelCase__      )
      self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.num_labels)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  List[str]:
      """simple docstring"""





      a__	:						Optional[Any]      		=  self.num_labels
      a__	:						Tuple      		=  MobileBertForTokenClassification(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Union[str, Any]      		=  model(UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			labels=UpperCamelCase__      )
      self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.seq_length, self.num_labels)      )





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case      )				->  List[str]:
      """simple docstring"""





      a__	:						int      		=  self.num_choices
      a__	:						str      		=  MobileBertForMultipleChoice(config=UpperCamelCase__      )
      model.to(UpperCamelCase__      )
      model.eval()
      a__	:						Optional[Any]      		=  input_ids.unsqueeze(1      ).expand(-1					,			self.num_choices					,			-1      ).contiguous()
      a__	:						Optional[int]      		=  token_type_ids.unsqueeze(1      ).expand(-1					,			self.num_choices					,			-1      ).contiguous()
      a__	:						List[str]      		=  input_mask.unsqueeze(1      ).expand(-1					,			self.num_choices					,			-1      ).contiguous()
      a__	:						str      		=  model(
          UpperCamelCase__					,			attention_mask=UpperCamelCase__					,			token_type_ids=UpperCamelCase__					,			labels=UpperCamelCase__					,			)
      self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.num_choices)      )





   def 	_snake_case ( self      )				->  Any:
      """simple docstring"""





      a__	:						List[str]      		=  self.prepare_config_and_inputs()
      (
          (
          a__ 
      )		,     (
          a__ 
      )		,     (
          a__ 
      )		,     (
          a__ 
      )		,     (
          a__ 
      )		,     (
          a__ 
      )		,     (
          a__ 
      )		,      
      )	:						List[str]      		=  config_and_inputs
      a__	:						Dict      		=  {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
      return config, inputs_dict







@require_torch
class   __lowerCAmelCase			(					lowercase_		,lowercase_		,unittest.TestCase  ):
   _UpperCamelCase :						List[Any]     		=				(
       (
           MobileBertModel,
           MobileBertForMaskedLM,
           MobileBertForMultipleChoice,
           MobileBertForNextSentencePrediction,
           MobileBertForPreTraining,
           MobileBertForQuestionAnswering,
           MobileBertForSequenceClassification,
           MobileBertForTokenClassification,
       )
       if is_torch_available()
       else ()
   )
   _UpperCamelCase :						int     		=				(
       {
           '''feature-extraction''': MobileBertModel,
           '''fill-mask''': MobileBertForMaskedLM,
           '''question-answering''': MobileBertForQuestionAnswering,
           '''text-classification''': MobileBertForSequenceClassification,
           '''token-classification''': MobileBertForTokenClassification,
           '''zero-shot''': MobileBertForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   _UpperCamelCase :						List[str]     		=				True





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case=False      )				->  int:
      """simple docstring"""





      a__	:						List[str]      		=  super()._prepare_for_class(UpperCamelCase__					,			UpperCamelCase__					,			return_labels=UpperCamelCase__      )

      if return_labels:
         if model_class in get_values(UpperCamelCase__      ):
            a__	:						List[Any]      		=  torch.zeros(
                (self.model_tester.batch_size, self.model_tester.seq_length)					,			dtype=torch.long					,			device=UpperCamelCase__      )
            a__	:						Optional[int]      		=  torch.zeros(
                self.model_tester.batch_size					,			dtype=torch.long					,			device=UpperCamelCase__      )
      return inputs_dict





   def 	_snake_case ( self      )				->  Any:
      """simple docstring"""





      a__	:						Any      		=  MobileBertModelTester(self      )
      a__	:						List[str]      		=  ConfigTester(self					,			config_class=UpperCamelCase__					,			hidden_size=37      )





   def 	_snake_case ( self      )				->  Tuple:
      """simple docstring"""





      self.config_tester.run_common_tests()





   def 	_snake_case ( self      )				->  int:
      """simple docstring"""





      a__	:						Optional[Any]      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_model(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  Optional[Any]:
      """simple docstring"""





      a__	:						Optional[int]      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_masked_lm(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  Union[str, Any]:
      """simple docstring"""





      a__	:						Tuple      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_multiple_choice(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  Optional[int]:
      """simple docstring"""





      a__	:						Dict      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_next_sequence_prediction(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  Optional[Any]:
      """simple docstring"""





      a__	:						Dict      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_pretraining(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  Union[str, Any]:
      """simple docstring"""





      a__	:						str      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_question_answering(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  List[Any]:
      """simple docstring"""





      a__	:						List[Any]      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_sequence_classification(*UpperCamelCase__      )





   def 	_snake_case ( self      )				->  List[str]:
      """simple docstring"""





      a__	:						List[str]      		=  self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_mobilebert_for_token_classification(*UpperCamelCase__      )







def       _A  (      lowerCamelCase   ):
   return torch.tensor(
       lowerCamelCase							, dtype=torch.long							, device=lowerCamelCase							, )


SCREAMING_SNAKE_CASE__       :			int			      =						1e-3







@require_torch
@require_sentencepiece
@require_tokenizers
class   __lowerCAmelCase			(					unittest.TestCase  ):





   @slow
   def 	_snake_case ( self      )				->  List[Any]:
      """simple docstring"""





      a__	:						Any      		=  MobileBertModel.from_pretrained("google/mobilebert-uncased"      ).to(UpperCamelCase__      )
      a__	:						Dict      		=  _long_tensor([[101, 7_110, 1_005, 1_056, 2_023, 11_333, 17_413, 1_029, 102]]      )
      with torch.no_grad():
         a__	:						int      		=  model(UpperCamelCase__      )[0]
      a__	:						Tuple      		=  torch.Size((1, 9, 512)      )
      self.assertEqual(output.shape					,			UpperCamelCase__      )
      a__	:						int      		=  torch.tensor(
          [
              [
                  [-2.473_6526E07, 8.269_1656E04, 1.652_1838E05],
                  [-5.754_1704E-01, 3.905_6022E00, 4.401_1507E00],
                  [2.604_7359E00, 1.567_7652E00, -1.732_4188E-01],
              ]
          ]					,			device=UpperCamelCase__					,			)

      # MobileBERT results range from 10e0 to 10e8. Even a 0.0000001% difference with a value of 10e8 results in a
      # ~1 difference, it's therefore not a good idea to measure using addition.
      # Here, we instead divide the expected result with the result in order to obtain ~1. We then check that the
      # result is held between bounds: 1 - TOLERANCE < expected_result / result < 1 + TOLERANCE
      a__	:						Union[str, Any]      		=  torch.all((expected_slice / output[..., :3, :3]) >= 1 - TOLERANCE      )
      a__	:						int      		=  torch.all((expected_slice / output[..., :3, :3]) <= 1 + TOLERANCE      )

      self.assertTrue(lower_bound and upper_bound      )








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


SCREAMING_SNAKE_CASE__       :			Dict			      =						"""CompVis/stable-diffusion-v1-1"""
SCREAMING_SNAKE_CASE__       :			Dict			      =						"""CompVis/stable-diffusion-v1-2"""
SCREAMING_SNAKE_CASE__       :			Tuple			      =						"""CompVis/stable-diffusion-v1-3"""
SCREAMING_SNAKE_CASE__       :			str			      =						"""CompVis/stable-diffusion-v1-4"""







class   __lowerCAmelCase			(					_UpperCamelCase  ):





   def __init__( self					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case					,			snake_case = True					,			)				->  Any:
      """simple docstring"""





      super()._init_()

      a__	:						Union[str, Any]      		=  StableDiffusionPipeline.from_pretrained(snake_case      )
      a__	:						Optional[Any]      		=  StableDiffusionPipeline.from_pretrained(snake_case      )
      a__	:						Optional[Any]      		=  StableDiffusionPipeline.from_pretrained(snake_case      )
      a__	:						int      		=  StableDiffusionPipeline(
          vae=snake_case					,			text_encoder=snake_case					,			tokenizer=snake_case					,			unet=snake_case					,			scheduler=snake_case					,			safety_checker=snake_case					,			feature_extractor=snake_case					,			requires_safety_checker=snake_case					,			)

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





   @property
   def 	_snake_case ( self      )				->  Dict[str, Any]:
      """simple docstring"""





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





   def 	_snake_case ( self					,			snake_case = "auto"      )				->  Optional[Any]:
      """simple docstring"""





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





   def 	_snake_case ( self      )				->  Tuple:
      """simple docstring"""





      self.enable_attention_slicing(snake_case      )





   @torch.no_grad()
   def 	_snake_case ( self					,			snake_case					,			snake_case = 512					,			snake_case = 512					,			snake_case = 50					,			snake_case = 7.5					,			snake_case = None					,			snake_case = 1					,			snake_case = 0.0					,			snake_case = None					,			snake_case = None					,			snake_case = "pil"					,			snake_case = True					,			snake_case = None					,			snake_case = 1					,			**snake_case					,			)				->  Optional[int]:
      """simple docstring"""





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





   @torch.no_grad()
   def 	_snake_case ( self					,			snake_case					,			snake_case = 512					,			snake_case = 512					,			snake_case = 50					,			snake_case = 7.5					,			snake_case = None					,			snake_case = 1					,			snake_case = 0.0					,			snake_case = None					,			snake_case = None					,			snake_case = "pil"					,			snake_case = True					,			snake_case = None					,			snake_case = 1					,			**snake_case					,			)				->  Dict:
      """simple docstring"""





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





   @torch.no_grad()
   def 	_snake_case ( self					,			snake_case					,			snake_case = 512					,			snake_case = 512					,			snake_case = 50					,			snake_case = 7.5					,			snake_case = None					,			snake_case = 1					,			snake_case = 0.0					,			snake_case = None					,			snake_case = None					,			snake_case = "pil"					,			snake_case = True					,			snake_case = None					,			snake_case = 1					,			**snake_case					,			)				->  Union[str, Any]:
      """simple docstring"""





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





   @torch.no_grad()
   def 	_snake_case ( self					,			snake_case					,			snake_case = 512					,			snake_case = 512					,			snake_case = 50					,			snake_case = 7.5					,			snake_case = None					,			snake_case = 1					,			snake_case = 0.0					,			snake_case = None					,			snake_case = None					,			snake_case = "pil"					,			snake_case = True					,			snake_case = None					,			snake_case = 1					,			**snake_case					,			)				->  Dict:
      """simple docstring"""





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





   @torch.no_grad()
   def 	_snake_case ( self					,			snake_case					,			snake_case = 512					,			snake_case = 512					,			snake_case = 50					,			snake_case = 7.5					,			snake_case = None					,			snake_case = 1					,			snake_case = 0.0					,			snake_case = None					,			snake_case = None					,			snake_case = "pil"					,			snake_case = True					,			snake_case = None					,			snake_case = 1					,			**snake_case					,			)				->  Dict:
      """simple docstring"""





      a__	:						Any      		=  "cuda" if torch.cuda.is_available() else "cpu"
      self.to(snake_case      )

      # 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
      a__	:						Any      		=  self.textaimg_sda_a(
          prompt=snake_case					,			height=snake_case					,			width=snake_case					,			num_inference_steps=snake_case					,			guidance_scale=snake_case					,			negative_prompt=snake_case					,			num_images_per_prompt=snake_case					,			eta=snake_case					,			generator=snake_case					,			latents=snake_case					,			output_type=snake_case					,			return_dict=snake_case					,			callback=snake_case					,			callback_steps=snake_case					,			**snake_case					,			)

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

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

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

      # 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]]      )

