code: from dataclasses import dataclass
  from enum import Enum
  from typing import List, Optional, Union
  
  import numpy as np
  import PIL
  from PIL import Image
  
  from ...utils import BaseOutput, is_torch_available, is_transformers_available
  
  @dataclass
  class 				_lowercase						(    UpperCAmelCase__ ):
  
  
  
  
  
  
      '''simple docstring'''
      SCREAMING_SNAKE_CASE:							Optional[int]        =						{
          'sld_warmup_steps': 15,
          'sld_guidance_scale': 20,
          'sld_threshold': 0.0,
          'sld_momentum_scale': 0.0,
          'sld_mom_beta': 0.0,
      }
      SCREAMING_SNAKE_CASE:							List[Any]        =						{
          'sld_warmup_steps': 10,
          'sld_guidance_scale': 1000,
          'sld_threshold': 0.0_1,
          'sld_momentum_scale': 0.3,
          'sld_mom_beta': 0.4,
      }
      SCREAMING_SNAKE_CASE:							Dict        =						{
          'sld_warmup_steps': 7,
          'sld_guidance_scale': 2000,
          'sld_threshold': 0.0_2_5,
          'sld_momentum_scale': 0.5,
          'sld_mom_beta': 0.7,
      }
      SCREAMING_SNAKE_CASE:							Optional[int]        =						{
          'sld_warmup_steps': 0,
          'sld_guidance_scale': 5000,
          'sld_threshold': 1.0,
          'sld_momentum_scale': 0.5,
          'sld_mom_beta': 0.7,
      }
  
  
  
  
  
  @dataclass
  class 				_lowercase						(    UpperCAmelCase__ ):
  
  
  
  
  
  
      '''simple docstring'''
      SCREAMING_SNAKE_CASE:							Union[List[PIL.Image.Image], np.ndarray]
      SCREAMING_SNAKE_CASE:							Optional[List[bool]]
      SCREAMING_SNAKE_CASE:							Optional[Union[List[PIL.Image.Image], np.ndarray]]
      SCREAMING_SNAKE_CASE:							Optional[str]
  
  
  if is_transformers_available() and is_torch_available():
   from .pipeline_stable_diffusion_safe import StableDiffusionPipelineSafe
   from .safety_checker import SafeStableDiffusionSafetyChecker
style_context: from ctypes import c_float, sizeof
  from enum import Enum
  from typing import TYPE_CHECKING, Optional, Union
  
  
  if TYPE_CHECKING:
   from .. import AutoFeatureExtractor, AutoProcessor, AutoTokenizer  # tests_ignore
  
  class 				_lowercase						(    UpperCAmelCase__ ):
  
  
  
  
  
  
      '''simple docstring'''
      SCREAMING_SNAKE_CASE:							Union[str, Any]        =						c_float
  
  
  
  
      @property
      def     _a						(						self   ):
         return sizeof(self.value   )
  
  
  
  
  
  def 		snake_case__  (		lowercase       ,							lowercase       ,							lowercase = 0				):
     # < 0 is possible if using a dynamic axis
     if dimension <= 0:
        lowerCAmelCase_:       int         =  fixed_dimension
  
     dimension -= num_token_to_add
     return dimension
  def 		snake_case__  (		lowercase       ,							lowercase				):
     return num_parameters * dtype.size
  
  
  
  
  
  
  
  def 		snake_case__  (		lowercase				):
     from .. import AutoFeatureExtractor, AutoProcessor, AutoTokenizer  # tests_ignore
  
     try:
        return AutoProcessor.from_pretrained(lowercase				)
     except (ValueError, OSError, KeyError):
        lowerCAmelCase_     ,  lowerCAmelCase_:       int         =  None, None
        try:
           lowerCAmelCase_:       Dict         =  AutoTokenizer.from_pretrained(lowercase				)
        except (OSError, KeyError):
           pass
        try:
           lowerCAmelCase_:       Optional[int]         =  AutoFeatureExtractor.from_pretrained(lowercase				)
        except (OSError, KeyError):
           pass
  
        if tokenizer is not None and feature_extractor is not None:
           raise ValueError(
               F'''Couldn\'t auto-detect preprocessor for {model_name}. Found both a tokenizer and a feature extractor.'''				)
        elif tokenizer is None and feature_extractor is None:
           return None
        elif tokenizer is not None:
           return tokenizer
        else:
           return feature_extractor