'''simple docstring'''

import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
      import jax
      import jax.numpy as jnp

      from transformers.modeling_flax_pytorch_utils import (
          convert_pytorch_state_dict_to_flax,
          load_flax_weights_in_pytorch_model,
      )
      from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
      import torch




class    lowerCamelCase__  :



   def __init__(    self					,      lowerCAmelCase__					,      lowerCAmelCase__=14					,      lowerCAmelCase__=7					,      lowerCAmelCase__=True					,      lowerCAmelCase__=True					,      lowerCAmelCase__=False					,      lowerCAmelCase__=True					,      lowerCAmelCase__=99					,      lowerCAmelCase__=32					,      lowerCAmelCase__=5					,      lowerCAmelCase__=4					,      lowerCAmelCase__=37					,      lowerCAmelCase__="gelu"					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=0.1					,      lowerCAmelCase__=512					,      lowerCAmelCase__=0.02					,      )				->     Tuple:
        """simple docstring"""





        _UpperCamelCase  :int       =parent
        _UpperCamelCase  :int       =batch_size
        _UpperCamelCase  :str       =seq_length
        _UpperCamelCase  :int       =is_training
        _UpperCamelCase  :Dict       =use_input_mask
        _UpperCamelCase  :List[str]       =use_token_type_ids
        _UpperCamelCase  :int       =use_labels
        _UpperCamelCase  :Tuple       =vocab_size
        _UpperCamelCase  :Optional[Any]       =hidden_size
        _UpperCamelCase  :str       =num_hidden_layers
        _UpperCamelCase  :List[str]       =num_attention_heads
        _UpperCamelCase  :List[str]       =intermediate_size
        _UpperCamelCase  :Any       =hidden_act
        _UpperCamelCase  :Optional[Any]       =hidden_dropout_prob
        _UpperCamelCase  :int       =attention_probs_dropout_prob
        _UpperCamelCase  :str       =max_position_embeddings
        _UpperCamelCase  :Any       =initializer_range
        _UpperCamelCase  :Optional[Any]       =None
        _UpperCamelCase  :Optional[Any]       =vocab_size - 1
        _UpperCamelCase  :Optional[Any]       =vocab_size - 1
        _UpperCamelCase  :Tuple       =vocab_size - 1



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





        _UpperCamelCase  :Dict       =ids_tensor([self.batch_size, self.seq_length]					,      self.vocab_size     )

        _UpperCamelCase  :Optional[int]       =None
        if self.use_input_mask:
             _UpperCamelCase  :List[Any]       =random_attention_mask([self.batch_size, self.seq_length]     )

        _UpperCamelCase  :Optional[Any]       =GPTaConfig(
            vocab_size=self.vocab_size					,      n_embd=self.hidden_size					,      n_layer=self.num_hidden_layers					,      n_head=self.num_attention_heads					,      n_positions=self.max_position_embeddings					,      use_cache=lowerCAmelCase__					,      bos_token_id=self.bos_token_id					,      eos_token_id=self.eos_token_id					,      pad_token_id=self.pad_token_id					,      )

        return (config, input_ids, input_mask)



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





        _UpperCamelCase  :Any       =self.prepare_config_and_inputs()
        _UpperCamelCase       ,      _UpperCamelCase       ,      _UpperCamelCase  :Any       =config_and_inputs
        _UpperCamelCase  :Union[str, Any]       ={"""input_ids""": input_ids, """attention_mask""": attention_mask}
        return config, inputs_dict



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





        _UpperCamelCase       ,      _UpperCamelCase       ,      _UpperCamelCase  :List[str]       =self.prepare_config_and_inputs()

        _UpperCamelCase  :int       =floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
        _UpperCamelCase  :Union[str, Any]       =ids_tensor([self.batch_size, self.seq_length]					,      vocab_size=2     )

        return (
            config,
            input_ids,
            attention_mask,
            encoder_hidden_states,
            encoder_attention_mask,
        )



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





        _UpperCamelCase  :List[str]       =20
        _UpperCamelCase  :Union[str, Any]       =model_class_name(lowerCAmelCase__     )

        _UpperCamelCase  :List[str]       =model.init_cache(input_ids.shape[0]					,      lowerCAmelCase__     )
        _UpperCamelCase  :Any       =jnp.ones((input_ids.shape[0], max_decoder_length)					,      dtype="""i4"""     )

        _UpperCamelCase  :Any       =jnp.broadcast_to(
            jnp.arange(input_ids.shape[-1] - 1     )[None, :]					,      (input_ids.shape[0], input_ids.shape[-1] - 1)     )
        _UpperCamelCase  :Tuple       =model(
            input_ids[:, :-1]					,      attention_mask=lowerCAmelCase__					,      past_key_values=lowerCAmelCase__					,      position_ids=lowerCAmelCase__					,      )

        _UpperCamelCase  :str       =jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]					,      dtype="""i4"""     )
        _UpperCamelCase  :List[str]       =model(
            input_ids[:, -1:]					,      attention_mask=lowerCAmelCase__					,      past_key_values=outputs_cache.past_key_values					,      position_ids=lowerCAmelCase__					,      )

        _UpperCamelCase  :int       =model(lowerCAmelCase__     )

        _UpperCamelCase  :Dict       =np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])     )     )
        self.parent.assertTrue(diff < 1e-3					,      msg=f'''Max diff is {diff}'''     )




   def  _UpperCamelCase		(    self					,      lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )				->     Any:
        """simple docstring"""





        _UpperCamelCase  :Dict       =20
        _UpperCamelCase  :List[str]       =model_class_name(lowerCAmelCase__     )

        _UpperCamelCase  :Union[str, Any]       =jnp.concatenate(
            [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])     )]					,      axis=-1					,      )

        _UpperCamelCase  :int       =model.init_cache(input_ids.shape[0]					,      lowerCAmelCase__     )
        _UpperCamelCase  :List[Any]       =jnp.broadcast_to(
            jnp.arange(input_ids.shape[-1] - 1     )[None, :]					,      (input_ids.shape[0], input_ids.shape[-1] - 1)     )

        _UpperCamelCase  :Dict       =model(
            input_ids[:, :-1]					,      attention_mask=lowerCAmelCase__					,      past_key_values=lowerCAmelCase__					,      position_ids=lowerCAmelCase__					,      )
        _UpperCamelCase  :Any       =jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]					,      dtype="""i4"""     )
        _UpperCamelCase  :str       =model(
            input_ids[:, -1:]					,      past_key_values=outputs_cache.past_key_values					,      attention_mask=lowerCAmelCase__					,      position_ids=lowerCAmelCase__					,      )

        _UpperCamelCase  :Tuple       =model(lowerCAmelCase__					,      attention_mask=lowerCAmelCase__     )

        _UpperCamelCase  :int       =np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])     )     )
        self.parent.assertTrue(diff < 1e-3					,      msg=f'''Max diff is {diff}'''     )




@require_flax
class    lowerCamelCase__  (   __snake_case       ,				__snake_case       ,				unittest.TestCase     ):
   __UpperCAmelCase           =						(FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
   __UpperCAmelCase           =						(FlaxGPTaLMHeadModel,) if is_flax_available() else ()



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





        _UpperCamelCase  :int       =FlaxGPTaModelTester(self     )



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





        for model_class_name in self.all_model_classes:
             _UpperCamelCase       ,      _UpperCamelCase       ,      _UpperCamelCase  :Dict       =self.model_tester.prepare_config_and_inputs()
             self.model_tester.check_use_cache_forward(lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )



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





        for model_class_name in self.all_model_classes:
             _UpperCamelCase       ,      _UpperCamelCase       ,      _UpperCamelCase  :Dict       =self.model_tester.prepare_config_and_inputs()
             self.model_tester.check_use_cache_forward_with_attn_mask(
                 lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )



   @slow
   def  _UpperCamelCase		(    self     )				->     List[str]:
        """simple docstring"""





        _UpperCamelCase  :Optional[int]       =GPTaTokenizer.from_pretrained("""gpt2"""					,      pad_token="""</s>"""					,      padding_side="""left"""     )
        _UpperCamelCase  :Dict       =tokenizer(["""Hello this is a long string""", """Hey"""]					,      return_tensors="""np"""					,      padding=lowerCAmelCase__					,      truncation=lowerCAmelCase__     )

        _UpperCamelCase  :Dict       =FlaxGPTaLMHeadModel.from_pretrained("""gpt2"""     )
        _UpperCamelCase  :int       =False
        _UpperCamelCase  :Optional[int]       =model.config.eos_token_id

        _UpperCamelCase  :Any       =jax.jit(model.generate     )

        _UpperCamelCase  :Dict       =jit_generate(inputs["""input_ids"""]					,      attention_mask=inputs["""attention_mask"""]     ).sequences

        _UpperCamelCase  :Optional[int]       =tokenizer.batch_decode(lowerCAmelCase__					,      skip_special_tokens=lowerCAmelCase__     )

        _UpperCamelCase  :Optional[int]       =[
            """Hello this is a long string of words. I'm going to start with the first one.\n""",
            """Hey, I'm not sure if I'm going to be able to do""",
        ]

        self.assertListEqual(lowerCAmelCase__					,      lowerCAmelCase__     )



   @is_pt_flax_cross_test
   def  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :str       =self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__     ):
                  # prepare inputs
                  _UpperCamelCase  :Optional[Any]       =self._prepare_for_class(lowerCAmelCase__					,      lowerCAmelCase__     )
                  _UpperCamelCase  :Optional[int]       ={k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

                  # load corresponding PyTorch class
                  _UpperCamelCase  :Union[str, Any]       =model_class.__name__[4:]  # Skip the "Flax" at the beginning
                  _UpperCamelCase  :Dict       =getattr(lowerCAmelCase__					,      lowerCAmelCase__     )

                  _UpperCamelCase       ,      _UpperCamelCase  :List[Any]       =pt_inputs["""input_ids"""].shape
                  _UpperCamelCase  :List[str]       =np.random.randint(0					,      seq_length - 1					,      size=(batch_size,)     )
                  for batch_idx, start_index in enumerate(lowerCAmelCase__     ):
                       _UpperCamelCase  :Tuple       =0
                       _UpperCamelCase  :Dict       =1
                       _UpperCamelCase  :Tuple       =0
                       _UpperCamelCase  :str       =1
                  _UpperCamelCase  :Dict       =pt_model_class(lowerCAmelCase__     ).eval()
                  _UpperCamelCase  :int       =model_class(lowerCAmelCase__					,      dtype=jnp.floataa     )

                  _UpperCamelCase  :Any       =convert_pytorch_state_dict_to_flax(pt_model.state_dict()					,      lowerCAmelCase__     )
                  _UpperCamelCase  :List[str]       =fx_state

                  with torch.no_grad():
                       _UpperCamelCase  :Optional[int]       =pt_model(**lowerCAmelCase__     ).to_tuple()

                  _UpperCamelCase  :List[Any]       =fx_model(**lowerCAmelCase__     ).to_tuple()
                  self.assertEqual(len(lowerCAmelCase__     )					,      len(lowerCAmelCase__     )					,      """Output lengths differ between Flax and PyTorch"""     )
                  for fx_output, pt_output in zip(lowerCAmelCase__					,      lowerCAmelCase__     ):
                       self.assert_almost_equals(fx_output[:, -1]					,      pt_output[:, -1].numpy()					,      4e-2     )

                  with tempfile.TemporaryDirectory() as tmpdirname:
                       pt_model.save_pretrained(lowerCAmelCase__     )
                       _UpperCamelCase  :Any       =model_class.from_pretrained(lowerCAmelCase__					,      from_pt=lowerCAmelCase__     )

                  _UpperCamelCase  :Optional[int]       =fx_model_loaded(**lowerCAmelCase__     ).to_tuple()
                  self.assertEqual(
                      len(lowerCAmelCase__     )					,      len(lowerCAmelCase__     )					,      """Output lengths differ between Flax and PyTorch"""     )
                  for fx_output_loaded, pt_output in zip(lowerCAmelCase__					,      lowerCAmelCase__     ):
                       self.assert_almost_equals(fx_output_loaded[:, -1]					,      pt_output[:, -1].numpy()					,      4e-2     )



   @is_pt_flax_cross_test
   def  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :List[str]       =self.model_tester.prepare_config_and_inputs_for_common()
        for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__     ):
                  # prepare inputs
                  _UpperCamelCase  :Optional[int]       =self._prepare_for_class(lowerCAmelCase__					,      lowerCAmelCase__     )
                  _UpperCamelCase  :Tuple       ={k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

                  # load corresponding PyTorch class
                  _UpperCamelCase  :str       =model_class.__name__[4:]  # Skip the "Flax" at the beginning
                  _UpperCamelCase  :List[Any]       =getattr(lowerCAmelCase__					,      lowerCAmelCase__     )

                  _UpperCamelCase  :Union[str, Any]       =pt_model_class(lowerCAmelCase__     ).eval()
                  _UpperCamelCase  :Dict       =model_class(lowerCAmelCase__					,      dtype=jnp.floataa     )

                  _UpperCamelCase  :Optional[Any]       =load_flax_weights_in_pytorch_model(lowerCAmelCase__					,      fx_model.params     )
                  _UpperCamelCase       ,      _UpperCamelCase  :Optional[int]       =pt_inputs["""input_ids"""].shape
                  _UpperCamelCase  :Tuple       =np.random.randint(0					,      seq_length - 1					,      size=(batch_size,)     )
                  for batch_idx, start_index in enumerate(lowerCAmelCase__     ):
                       _UpperCamelCase  :List[Any]       =0
                       _UpperCamelCase  :Union[str, Any]       =1
                       _UpperCamelCase  :List[str]       =0
                       _UpperCamelCase  :List[Any]       =1

                  # make sure weights are tied in PyTorch
                  pt_model.tie_weights()

                  with torch.no_grad():
                       _UpperCamelCase  :Tuple       =pt_model(**lowerCAmelCase__     ).to_tuple()

                  _UpperCamelCase  :Tuple       =fx_model(**lowerCAmelCase__     ).to_tuple()
                  self.assertEqual(len(lowerCAmelCase__     )					,      len(lowerCAmelCase__     )					,      """Output lengths differ between Flax and PyTorch"""     )
                  for fx_output, pt_output in zip(lowerCAmelCase__					,      lowerCAmelCase__     ):
                       self.assert_almost_equals(fx_output[:, -1]					,      pt_output[:, -1].numpy()					,      4e-2     )

                  with tempfile.TemporaryDirectory() as tmpdirname:
                       fx_model.save_pretrained(lowerCAmelCase__     )
                       _UpperCamelCase  :Dict       =pt_model_class.from_pretrained(lowerCAmelCase__					,      from_flax=lowerCAmelCase__     )

                  with torch.no_grad():
                       _UpperCamelCase  :str       =pt_model_loaded(**lowerCAmelCase__     ).to_tuple()

                  self.assertEqual(
                      len(lowerCAmelCase__     )					,      len(lowerCAmelCase__     )					,      """Output lengths differ between Flax and PyTorch"""     )
                  for fx_output, pt_output in zip(lowerCAmelCase__					,      lowerCAmelCase__     ):
                       self.assert_almost_equals(fx_output[:, -1]					,      pt_output[:, -1].numpy()					,      4e-2     )




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





        for model_class_name in self.all_model_classes:
             _UpperCamelCase  :Optional[int]       =model_class_name.from_pretrained("""gpt2"""					,      from_pt=lowerCAmelCase__     )
             _UpperCamelCase  :Union[str, Any]       =model(np.ones((1, 1)     )     )
             self.assertIsNotNone(lowerCAmelCase__     )



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

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


__UpperCamelCase							:							Any    							=					logging.get_logger(__name__)  # pylint: disable=invalid-name

class    __magic_name__						(  __lowerCAmelCase):
     A:		Dict								=   ["safety_checker", "feature_extractor"]


     def __init__(   self				:  List[str]				,						lowerCamelCase__				:  AutoencoderKL				,						lowerCamelCase__				:  CLIPTextModel				,						lowerCamelCase__				:  CLIPTokenizer				,						lowerCamelCase__				:  UNetaDConditionModel				,						lowerCamelCase__				:  Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]				,						lowerCamelCase__				:  StableDiffusionSafetyChecker				,						lowerCamelCase__				:  CLIPImageProcessor				,						lowerCamelCase__				:  bool = True				,						)	->   Optional[Any]:





      '''simple docstring'''






      super().__init__()
      if hasattr(scheduler.config				,						'''steps_offset'''      ) and scheduler.config.steps_offset != 1:
       UpperCamelCase__       :     int 							= (
           F"The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`"
           F" should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure "
           '''to update the config accordingly as leaving `steps_offset` might led to incorrect results'''
           ''' in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,'''
           ''' it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`'''
           ''' file'''
       )
       deprecate('''steps_offset!=1'''				,						'''1.0.0'''				,						lowerCamelCase__				,						standard_warn=lowerCamelCase__      )
       UpperCamelCase__       :     int 							= dict(scheduler.config      )
       UpperCamelCase__       :     List[str] 							= 1
       UpperCamelCase__       :     List[str] 							= FrozenDict(lowerCamelCase__      )

      self.register_modules(
          vae=lowerCamelCase__				,						text_encoder=lowerCamelCase__				,						tokenizer=lowerCamelCase__				,						unet=lowerCamelCase__				,						scheduler=lowerCamelCase__				,						safety_checker=lowerCamelCase__				,						feature_extractor=lowerCamelCase__				,						)
      self.register_to_config(requires_safety_checker=lowerCamelCase__      )


     @property
     def   UpperCAmelCase__						(   self				:  str      )	->   Dict[str, Any]:





      '''simple docstring'''






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


     def   UpperCAmelCase__						(   self				:  str				,						lowerCamelCase__				:  Optional[Union[str, int]] = "auto"      )	->   str:





      '''simple docstring'''






      if slice_size == "auto":
       # half the attention head size is usually a good trade-off between
       # speed and memory
       UpperCamelCase__       :     Dict 							= self.unet.config.attention_head_dim // 2
      self.unet.set_attention_slice(lowerCamelCase__      )


     def   UpperCAmelCase__						(   self				:  int      )	->   Tuple:





      '''simple docstring'''






      self.enable_attention_slicing(lowerCamelCase__      )


     @torch.no_grad()
     def   UpperCAmelCase__						(   self				:  Optional[Any]				,						lowerCamelCase__				:  Union[str, List[str]]				,						lowerCamelCase__				:  Union[torch.FloatTensor, PIL.Image.Image]				,						lowerCamelCase__				:  Union[torch.FloatTensor, PIL.Image.Image]				,						lowerCamelCase__				:  float = 0.8				,						lowerCamelCase__				:  Optional[int] = 50				,						lowerCamelCase__				:  Optional[float] = 7.5				,						lowerCamelCase__				:  Optional[Union[str, List[str]]] = None				,						lowerCamelCase__				:  Optional[int] = 1				,						lowerCamelCase__				:  Optional[float] = 0.0				,						lowerCamelCase__				:  Optional[torch.Generator] = None				,						lowerCamelCase__				:  Optional[str] = "pil"				,						lowerCamelCase__				:  bool = True				,						lowerCamelCase__				:  Optional[Callable[[int, int, torch.FloatTensor], None]] = None				,						lowerCamelCase__				:  int = 1				,						)	->   Optional[Any]:





      '''simple docstring'''






      return StableDiffusionInpaintPipelineLegacy(**self.components      )(
          prompt=lowerCamelCase__				,						image=lowerCamelCase__				,						mask_image=lowerCamelCase__				,						strength=lowerCamelCase__				,						num_inference_steps=lowerCamelCase__				,						guidance_scale=lowerCamelCase__				,						negative_prompt=lowerCamelCase__				,						num_images_per_prompt=lowerCamelCase__				,						eta=lowerCamelCase__				,						generator=lowerCamelCase__				,						output_type=lowerCamelCase__				,						return_dict=lowerCamelCase__				,						callback=lowerCamelCase__				,						)


     @torch.no_grad()
     def   UpperCAmelCase__						(   self				:  Any				,						lowerCamelCase__				:  Union[str, List[str]]				,						lowerCamelCase__				:  Union[torch.FloatTensor, PIL.Image.Image]				,						lowerCamelCase__				:  float = 0.8				,						lowerCamelCase__				:  Optional[int] = 50				,						lowerCamelCase__				:  Optional[float] = 7.5				,						lowerCamelCase__				:  Optional[Union[str, List[str]]] = None				,						lowerCamelCase__				:  Optional[int] = 1				,						lowerCamelCase__				:  Optional[float] = 0.0				,						lowerCamelCase__				:  Optional[torch.Generator] = None				,						lowerCamelCase__				:  Optional[str] = "pil"				,						lowerCamelCase__				:  bool = True				,						lowerCamelCase__				:  Optional[Callable[[int, int, torch.FloatTensor], None]] = None				,						lowerCamelCase__				:  int = 1				,						**lowerCamelCase__				:  str				,						)	->   str:





      '''simple docstring'''






      return StableDiffusionImgaImgPipeline(**self.components      )(
          prompt=lowerCamelCase__				,						image=lowerCamelCase__				,						strength=lowerCamelCase__				,						num_inference_steps=lowerCamelCase__				,						guidance_scale=lowerCamelCase__				,						negative_prompt=lowerCamelCase__				,						num_images_per_prompt=lowerCamelCase__				,						eta=lowerCamelCase__				,						generator=lowerCamelCase__				,						output_type=lowerCamelCase__				,						return_dict=lowerCamelCase__				,						callback=lowerCamelCase__				,						callback_steps=lowerCamelCase__				,						)


     @torch.no_grad()
     def   UpperCAmelCase__						(   self				:  Optional[int]				,						lowerCamelCase__				:  Union[str, List[str]]				,						lowerCamelCase__				:  int = 512				,						lowerCamelCase__				:  int = 512				,						lowerCamelCase__				:  int = 50				,						lowerCamelCase__				:  float = 7.5				,						lowerCamelCase__				:  Optional[Union[str, List[str]]] = None				,						lowerCamelCase__				:  Optional[int] = 1				,						lowerCamelCase__				:  float = 0.0				,						lowerCamelCase__				:  Optional[torch.Generator] = None				,						lowerCamelCase__				:  Optional[torch.FloatTensor] = None				,						lowerCamelCase__				:  Optional[str] = "pil"				,						lowerCamelCase__				:  bool = True				,						lowerCamelCase__				:  Optional[Callable[[int, int, torch.FloatTensor], None]] = None				,						lowerCamelCase__				:  int = 1				,						)	->   Optional[Any]:





      '''simple docstring'''






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


