




'''simple docstring'''





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


a		:  str   			=			logging.get_logger(__name__)  # pylint: disable=invalid-name




class     UpperCamelCase					(  snake_case__					):
  a    :List[str]      					=				['safety_checker', 'feature_extractor']



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







      '''simple docstring'''


      super().__init__()
      if hasattr(scheduler.config		,    """steps_offset"""   ) and scheduler.config.steps_offset != 1:
          _a							:       Tuple       					=			(
              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   )
          _a							:       List[str]       					=			dict(scheduler.config   )
          _a							:       Optional[Any]       					=			1
          _a							:       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 						a_       ( self   ):







      '''simple docstring'''


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



  def 						a_       ( self		,    __lowerCAmelCase = "auto"   ):







      '''simple docstring'''


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



  def 						a_       ( self   ):







      '''simple docstring'''


      self.enable_attention_slicing(__lowerCAmelCase   )



  @torch.no_grad()
  def 						a_       ( self		,    __lowerCAmelCase		,    __lowerCAmelCase		,    __lowerCAmelCase		,    __lowerCAmelCase = 0.8		,    __lowerCAmelCase = 50		,    __lowerCAmelCase = 7.5		,    __lowerCAmelCase = None		,    __lowerCAmelCase = 1		,    __lowerCAmelCase = 0.0		,    __lowerCAmelCase = None		,    __lowerCAmelCase = "pil"		,    __lowerCAmelCase = True		,    __lowerCAmelCase = None		,    __lowerCAmelCase = 1		,    ):







      '''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 						a_       ( self		,    __lowerCAmelCase		,    __lowerCAmelCase		,    __lowerCAmelCase = 0.8		,    __lowerCAmelCase = 50		,    __lowerCAmelCase = 7.5		,    __lowerCAmelCase = None		,    __lowerCAmelCase = 1		,    __lowerCAmelCase = 0.0		,    __lowerCAmelCase = None		,    __lowerCAmelCase = "pil"		,    __lowerCAmelCase = True		,    __lowerCAmelCase = None		,    __lowerCAmelCase = 1		,    **__lowerCAmelCase		,    ):







      '''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 						a_       ( self		,    __lowerCAmelCase		,    __lowerCAmelCase = 512		,    __lowerCAmelCase = 512		,    __lowerCAmelCase = 50		,    __lowerCAmelCase = 7.5		,    __lowerCAmelCase = None		,    __lowerCAmelCase = 1		,    __lowerCAmelCase = 0.0		,    __lowerCAmelCase = None		,    __lowerCAmelCase = None		,    __lowerCAmelCase = "pil"		,    __lowerCAmelCase = True		,    __lowerCAmelCase = None		,    __lowerCAmelCase = 1		,    ):







      '''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		,    )








'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
    is_vision_available,
)


a		:  Dict   			=			{
    '''configuration_mobilevitv2''': [
        '''MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''MobileViTV2Config''',
        '''MobileViTV2OnnxConfig''',
    ],
}


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  a		:  List[str]   			=			[
      '''MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''MobileViTV2ForImageClassification''',
      '''MobileViTV2ForSemanticSegmentation''',
      '''MobileViTV2Model''',
      '''MobileViTV2PreTrainedModel''',
  ]

if TYPE_CHECKING:
  from .configuration_mobilevitva import (
      MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
      MobileViTVaConfig,
      MobileViTVaOnnxConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_mobilevitva import (
        MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST,
        MobileViTVaForImageClassification,
        MobileViTVaForSemanticSegmentation,
        MobileViTVaModel,
        MobileViTVaPreTrainedModel,
    )

else:
  import sys

  a		:  Dict   			=			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


