code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  import unittest
  
  import numpy as np
  
  from transformers.testing_utils import require_torch, require_vision
  from transformers.utils import is_torch_available, is_vision_available
  
  from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs
  
  
  if is_torch_available():
   import torch
  
  if is_vision_available():
   from PIL import Image
  
   from transformers import ConvNextImageProcessor
  
  
  class 		_SCREAMING_SNAKE_CASE    (	unittest.TestCase    ):
  
  
       def __init__(     self       ,				A_       ,				A_=7       ,				A_=3       ,				A_=18       ,				A_=30       ,				A_=4_00       ,				A_=True       ,				A_=None       ,				A_=0.8_7_5       ,				A_=True       ,				A_=[0.5, 0.5, 0.5]       ,				A_=[0.5, 0.5, 0.5]       ,				):
         _UpperCAmelCase		:       Union[str, Any]       =    size if size is not None else {'''shortest_edge''': 20}
         _UpperCAmelCase		:       str       =    parent
         _UpperCAmelCase		:       Dict       =    batch_size
         _UpperCAmelCase		:       Union[str, Any]       =    num_channels
         _UpperCAmelCase		:       int       =    image_size
         _UpperCAmelCase		:       Optional[int]       =    min_resolution
         _UpperCAmelCase		:       Tuple       =    max_resolution
         _UpperCAmelCase		:       List[str]       =    do_resize
         _UpperCAmelCase		:       Optional[int]       =    size
         _UpperCAmelCase		:       Any       =    crop_pct
         _UpperCAmelCase		:       Tuple       =    do_normalize
         _UpperCAmelCase		:       Union[str, Any]       =    image_mean
         _UpperCAmelCase		:       Optional[int]       =    image_std
  
  
  
  
       def 					__snake_case(     self						):
         return {
             "image_mean": self.image_mean,
             "image_std": self.image_std,
             "do_normalize": self.do_normalize,
             "do_resize": self.do_resize,
             "size": self.size,
             "crop_pct": self.crop_pct,
         }
  
  
  @require_torch
  @require_vision
  class 		_SCREAMING_SNAKE_CASE    (	A_       ,  unittest.TestCase    ):
       __SCREAMING_SNAKE_CASE    				=						ConvNextImageProcessor if is_vision_available() else None
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Optional[int]       =    ConvNextImageProcessingTester(self						)
  
  
       @property
       def 					__snake_case(     self						):
         return self.image_processor_tester.prepare_image_processor_dict()
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       int       =    self.image_processing_class(**self.image_processor_dict						)
         self.assertTrue(hasattr(A_       ,				"""do_resize"""						)						)
         self.assertTrue(hasattr(A_       ,				"""size"""						)						)
         self.assertTrue(hasattr(A_       ,				"""crop_pct"""						)						)
         self.assertTrue(hasattr(A_       ,				"""do_normalize"""						)						)
         self.assertTrue(hasattr(A_       ,				"""image_mean"""						)						)
         self.assertTrue(hasattr(A_       ,				"""image_std"""						)						)
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Optional[Any]       =    self.image_processing_class.from_dict(self.image_processor_dict						)
         self.assertEqual(image_processor.size       ,				{"""shortest_edge""": 20}						)
  
         _UpperCAmelCase		:       List[Any]       =    self.image_processing_class.from_dict(self.image_processor_dict       ,				size=42						)
         self.assertEqual(image_processor.size       ,				{"""shortest_edge""": 42}						)
  
  
       def 					__snake_case(     self						):
         pass
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Optional[Any]       =    self.image_processing_class(**self.image_processor_dict						)
         # create random PIL images
         _UpperCAmelCase		:       Union[str, Any]       =    prepare_image_inputs(self.image_processor_tester       ,				equal_resolution=A_						)
         for image in image_inputs:
           self.assertIsInstance(A_       ,				Image.Image						)
  
         # Test not batched input
         _UpperCAmelCase		:       Any       =    image_processing(image_inputs[0]       ,				return_tensors="""pt"""						).pixel_values
         self.assertEqual(
             encoded_images.shape       ,				(
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""shortest_edge"""],
                 self.image_processor_tester.size["""shortest_edge"""],
             )       ,				)
  
         # Test batched
         _UpperCAmelCase		:       Union[str, Any]       =    image_processing(A_       ,				return_tensors="""pt"""						).pixel_values
         self.assertEqual(
             encoded_images.shape       ,				(
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""shortest_edge"""],
                 self.image_processor_tester.size["""shortest_edge"""],
             )       ,				)
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Optional[int]       =    self.image_processing_class(**self.image_processor_dict						)
         # create random numpy tensors
         _UpperCAmelCase		:       Any       =    prepare_image_inputs(self.image_processor_tester       ,				equal_resolution=A_       ,				numpify=A_						)
         for image in image_inputs:
           self.assertIsInstance(A_       ,				np.ndarray						)
  
         # Test not batched input
         _UpperCAmelCase		:       Tuple       =    image_processing(image_inputs[0]       ,				return_tensors="""pt"""						).pixel_values
         self.assertEqual(
             encoded_images.shape       ,				(
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""shortest_edge"""],
                 self.image_processor_tester.size["""shortest_edge"""],
             )       ,				)
  
         # Test batched
         _UpperCAmelCase		:       Optional[Any]       =    image_processing(A_       ,				return_tensors="""pt"""						).pixel_values
         self.assertEqual(
             encoded_images.shape       ,				(
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""shortest_edge"""],
                 self.image_processor_tester.size["""shortest_edge"""],
             )       ,				)
  
  
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Dict       =    self.image_processing_class(**self.image_processor_dict						)
         # create random PyTorch tensors
         _UpperCAmelCase		:       Tuple       =    prepare_image_inputs(self.image_processor_tester       ,				equal_resolution=A_       ,				torchify=A_						)
         for image in image_inputs:
           self.assertIsInstance(A_       ,				torch.Tensor						)
  
         # Test not batched input
         _UpperCAmelCase		:       Optional[int]       =    image_processing(image_inputs[0]       ,				return_tensors="""pt"""						).pixel_values
         self.assertEqual(
             encoded_images.shape       ,				(
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""shortest_edge"""],
                 self.image_processor_tester.size["""shortest_edge"""],
             )       ,				)
  
         # Test batched
         _UpperCAmelCase		:       Union[str, Any]       =    image_processing(A_       ,				return_tensors="""pt"""						).pixel_values
         self.assertEqual(
             encoded_images.shape       ,				(
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""shortest_edge"""],
                 self.image_processor_tester.size["""shortest_edge"""],
             )       ,				)
  
  
  
  
  
  
style_context: 
  
  
  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 		_SCREAMING_SNAKE_CASE    (	A    ):
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 1_5,
           '''sld_guidance_scale''': 2_0,
           '''sld_threshold''': 0.0,
           '''sld_momentum_scale''': 0.0,
           '''sld_mom_beta''': 0.0,
       }
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 1_0,
           '''sld_guidance_scale''': 1_0_0_0,
           '''sld_threshold''': 0.01,
           '''sld_momentum_scale''': 0.3,
           '''sld_mom_beta''': 0.4,
       }
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 7,
           '''sld_guidance_scale''': 2_0_0_0,
           '''sld_threshold''': 0.025,
           '''sld_momentum_scale''': 0.5,
           '''sld_mom_beta''': 0.7,
       }
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 0,
           '''sld_guidance_scale''': 5_0_0_0,
           '''sld_threshold''': 1.0,
           '''sld_momentum_scale''': 0.5,
           '''sld_mom_beta''': 0.7,
       }
  
  
  @dataclass
  class 		_SCREAMING_SNAKE_CASE    (	A    ):
       __SCREAMING_SNAKE_CASE    				=						42
       __SCREAMING_SNAKE_CASE    				=						42
       __SCREAMING_SNAKE_CASE    				=						42
       __SCREAMING_SNAKE_CASE    				=						42
  
  
  if is_transformers_available() and is_torch_available():
   from .pipeline_stable_diffusion_safe import StableDiffusionPipelineSafe
   from .safety_checker import SafeStableDiffusionSafetyChecker
  
  
  
  
  
  