


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 	__a   (       UpperCAmelCase    ):
		_a			:						str    			=			{
		    'sld_warmup_steps': 15,
		    'sld_guidance_scale': 20,
		    'sld_threshold': 0.0,
		    'sld_momentum_scale': 0.0,
		    'sld_mom_beta': 0.0,
		}
		_a			:						Optional[int]    			=			{
		    'sld_warmup_steps': 10,
		    'sld_guidance_scale': 10_00,
		    'sld_threshold': 0.0_1,
		    'sld_momentum_scale': 0.3,
		    'sld_mom_beta': 0.4,
		}
		_a			:						List[str]    			=			{
		    'sld_warmup_steps': 7,
		    'sld_guidance_scale': 20_00,
		    'sld_threshold': 0.0_2_5,
		    'sld_momentum_scale': 0.5,
		    'sld_mom_beta': 0.7,
		}
		_a			:						Tuple    			=			{
		    'sld_warmup_steps': 0,
		    'sld_guidance_scale': 50_00,
		    'sld_threshold': 1.0,
		    'sld_momentum_scale': 0.5,
		    'sld_mom_beta': 0.7,
		}



@dataclass
class 	__a   (       UpperCAmelCase    ):
		_a			:						Union[str, Any]    			=			42
		_a			:						Optional[int]    			=			42
		_a			:						Dict    			=			42
		_a			:						Optional[Any]    			=			42


if is_transformers_available() and is_torch_available():
		from .pipeline_stable_diffusion_safe import StableDiffusionPipelineSafe
		from .safety_checker import SafeStableDiffusionSafetyChecker





import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding

class 	__a   (       UpperCAmelCase    ):
		_a			:						int    			=			['image_processor', 'tokenizer']
		_a			:						Union[str, Any]    			=			'AutoImageProcessor'
		_a			:						Optional[int]    			=			'AutoTokenizer'
		def __init__(    self    ,					_SCREAMING_SNAKE_CASE=None    ,					_SCREAMING_SNAKE_CASE=None    ,					**_SCREAMING_SNAKE_CASE		)				-> Tuple:




									"""simple docstring"""





									_UpperCAmelCase					=    None
									if "feature_extractor" in kwargs:
																warnings.warn(
																    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
																    ' instead.'    ,					_SCREAMING_SNAKE_CASE    ,					)
																_UpperCAmelCase					=    kwargs.pop('feature_extractor'		)

									_UpperCAmelCase					=    image_processor if image_processor is not None else feature_extractor
									if image_processor is None:
																raise ValueError('You have to specify an image_processor.'		)
									if tokenizer is None:
																raise ValueError('You have to specify a tokenizer.'		)

									super().__init__(_SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE		)
									_UpperCAmelCase					=    self.image_processor
		def __call__(    self    ,					_SCREAMING_SNAKE_CASE=None    ,					_SCREAMING_SNAKE_CASE=None    ,					_SCREAMING_SNAKE_CASE=None    ,					**_SCREAMING_SNAKE_CASE		)				-> Dict:




									"""simple docstring"""





									if text is None and images is None:
																raise ValueError('You have to specify either text or images. Both cannot be none.'		)

									if text is not None:
																_UpperCAmelCase					=    self.tokenizer(_SCREAMING_SNAKE_CASE    ,					return_tensors=_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)

									if images is not None:
																_UpperCAmelCase					=    self.image_processor(_SCREAMING_SNAKE_CASE    ,					return_tensors=_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)

									if text is not None and images is not None:
																_UpperCAmelCase					=    image_features.pixel_values
																return encoding
									elif text is not None:
																return encoding
									else:
																return BatchEncoding(data=dict(**_SCREAMING_SNAKE_CASE		)    ,					tensor_type=_SCREAMING_SNAKE_CASE		)
		def 			UpperCAmelCase__       (    self    ,					*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)				-> int:




									"""simple docstring"""





									return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)
		def 			UpperCAmelCase__       (    self    ,					*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)				-> Tuple:




									"""simple docstring"""





									return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE		)
		@property
		def 			UpperCAmelCase__       (    self		)				-> Optional[int]:




									"""simple docstring"""





									_UpperCAmelCase					=    self.tokenizer.model_input_names
									_UpperCAmelCase					=    self.image_processor.model_input_names
									return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)
		@property
		def 			UpperCAmelCase__       (    self		)				-> Any:




									"""simple docstring"""





									warnings.warn(
									    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'    ,					_SCREAMING_SNAKE_CASE    ,					)
									return self.image_processor_class






		@property
		def 			UpperCAmelCase__       (    self		)				-> Any:




									"""simple docstring"""





									warnings.warn(
									    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'    ,					_SCREAMING_SNAKE_CASE    ,					)
									return self.image_processor
