





'''simple docstring'''

import gc
import random
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel
from diffusers.utils import floats_tensor, load_image, load_numpy, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow

from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()







class __a (   _UpperCAmelCase,   _UpperCAmelCase,   _UpperCAmelCase,   unittest.TestCase			):
   __UpperCamelCase   : Dict	      =	StableDiffusionInpaintPipeline
   __UpperCamelCase   : Any	      =	TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
   __UpperCamelCase   : List[Any]	      =	TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
   __UpperCamelCase   : Optional[Any]	      =	frozenset(
       []			)  # TO-DO: update image_params once pipeline is refactored with VaeImageProcessor.preprocess
   __UpperCamelCase   : List[str]	      =	frozenset([]			)





   def      UpperCAmelCase__     (					self				:			Optional[Any]    ):

      '''simple docstring'''

      torch.manual_seed(0    )
      __SCREAMING_SNAKE_CASE      							=       UNetaDConditionModel(
          block_out_channels=(32, 64)				,layers_per_block=2				,sample_size=32				,in_channels=9				,out_channels=4				,down_block_types=("""DownBlock2D""", """CrossAttnDownBlock2D""")				,up_block_types=("""CrossAttnUpBlock2D""", """UpBlock2D""")				,cross_attention_dim=32				,attention_head_dim=(2, 4)				,use_linear_projection=__UpperCamelCase				,)
      __SCREAMING_SNAKE_CASE      							=       PNDMScheduler(skip_prk_steps=__UpperCamelCase    )
      torch.manual_seed(0    )
      __SCREAMING_SNAKE_CASE      							=       AutoencoderKL(
          block_out_channels=[32, 64]				,in_channels=3				,out_channels=3				,down_block_types=["""DownEncoderBlock2D""", """DownEncoderBlock2D"""]				,up_block_types=["""UpDecoderBlock2D""", """UpDecoderBlock2D"""]				,latent_channels=4				,sample_size=128				,)
      torch.manual_seed(0    )
      __SCREAMING_SNAKE_CASE      							=       CLIPTextConfig(
          bos_token_id=0				,eos_token_id=2				,hidden_size=32				,intermediate_size=37				,layer_norm_eps=1E-0_5				,num_attention_heads=4				,num_hidden_layers=5				,pad_token_id=1				,vocab_size=1000				,hidden_act="""gelu"""				,projection_dim=512				,)
      __SCREAMING_SNAKE_CASE      							=       CLIPTextModel(__UpperCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""    )

      __SCREAMING_SNAKE_CASE      							=       {
          """unet""": unet,
          """scheduler""": scheduler,
          """vae""": vae,
          """text_encoder""": text_encoder,
          """tokenizer""": tokenizer,
          """safety_checker""": None,
          """feature_extractor""": None,
      }
      return components





   def      UpperCAmelCase__     (					self				:			Tuple				,lowerCamelCase				:			List[Any]				,lowerCamelCase				:			Optional[int]=0    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       floats_tensor((1, 3, 32, 32)				,rng=random.Random(__UpperCamelCase    )    ).to(__UpperCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       image.cpu().permute(0				,2				,3				,1    )[0]
      __SCREAMING_SNAKE_CASE      							=       Image.fromarray(np.uinta(__UpperCamelCase    )    ).convert("""RGB"""    ).resize((64, 64)    )
      __SCREAMING_SNAKE_CASE      							=       Image.fromarray(np.uinta(image + 4    )    ).convert("""RGB"""    ).resize((64, 64)    )
      if str(__UpperCamelCase    ).startswith("""mps"""    ):
         __SCREAMING_SNAKE_CASE      							=       torch.manual_seed(__UpperCamelCase    )
      else:
         __SCREAMING_SNAKE_CASE      							=       torch.Generator(device=__UpperCamelCase    ).manual_seed(__UpperCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       {
          """prompt""": """A painting of a squirrel eating a burger""",
          """image""": init_image,
          """mask_image""": mask_image,
          """generator""": generator,
          """num_inference_steps""": 2,
          """guidance_scale""": 6.0,
          """output_type""": """numpy""",
      }
      return inputs





   def      UpperCAmelCase__     (					self				:			List[str]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       """cpu"""  # ensure determinism for the device-dependent torch.Generator
      __SCREAMING_SNAKE_CASE      							=       self.get_dummy_components()
      __SCREAMING_SNAKE_CASE      							=       StableDiffusionInpaintPipeline(**__UpperCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       sd_pipe.to(__UpperCamelCase    )
      sd_pipe.set_progress_bar_config(disable=__UpperCamelCase    )

      __SCREAMING_SNAKE_CASE      							=       self.get_dummy_inputs(__UpperCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       sd_pipe(**__UpperCamelCase    ).images
      __SCREAMING_SNAKE_CASE      							=       image[0, -3:, -3:, -1]

      assert image.shape == (1, 64, 64, 3)
      __SCREAMING_SNAKE_CASE      							=       np.array([0.4_727, 0.5_735, 0.3_941, 0.5_446, 0.5_926, 0.4_394, 0.5_062, 0.4_654, 0.4_476]    )

      assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-2





   def      UpperCAmelCase__     (					self				:			str    ):

      '''simple docstring'''

      super().test_inference_batch_single_identical(expected_max_diff=3E-3    )







@slow
@require_torch_gpu
class __a (   unittest.TestCase			):





   def      UpperCAmelCase__     (					self				:			Tuple    ):

      '''simple docstring'''

      super().tearDown()
      gc.collect()
      torch.cuda.empty_cache()





   def      UpperCAmelCase__     (					self				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       load_image(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
          """/sd2-inpaint/init_image.png"""    )
      __SCREAMING_SNAKE_CASE      							=       load_image(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png"""    )
      __SCREAMING_SNAKE_CASE      							=       load_numpy(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint"""
          """/yellow_cat_sitting_on_a_park_bench.npy"""    )

      __SCREAMING_SNAKE_CASE      							=       """stabilityai/stable-diffusion-2-inpainting"""
      __SCREAMING_SNAKE_CASE      							=       StableDiffusionInpaintPipeline.from_pretrained(__UpperCamelCase				,safety_checker=__UpperCamelCase    )
      pipe.to(__UpperCamelCase    )
      pipe.set_progress_bar_config(disable=__UpperCamelCase    )
      pipe.enable_attention_slicing()

      __SCREAMING_SNAKE_CASE      							=       """Face of a yellow cat, high resolution, sitting on a park bench"""

      __SCREAMING_SNAKE_CASE      							=       torch.manual_seed(0    )
      __SCREAMING_SNAKE_CASE      							=       pipe(
          prompt=__UpperCamelCase				,image=__UpperCamelCase				,mask_image=__UpperCamelCase				,generator=__UpperCamelCase				,output_type="""np"""				,)
      __SCREAMING_SNAKE_CASE      							=       output.images[0]

      assert image.shape == (512, 512, 3)
      assert np.abs(expected_image - image    ).max() < 9E-3





   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       load_image(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
          """/sd2-inpaint/init_image.png"""    )
      __SCREAMING_SNAKE_CASE      							=       load_image(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png"""    )
      __SCREAMING_SNAKE_CASE      							=       load_numpy(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint"""
          """/yellow_cat_sitting_on_a_park_bench_fp16.npy"""    )

      __SCREAMING_SNAKE_CASE      							=       """stabilityai/stable-diffusion-2-inpainting"""
      __SCREAMING_SNAKE_CASE      							=       StableDiffusionInpaintPipeline.from_pretrained(
          __UpperCamelCase				,torch_dtype=torch.floataa				,safety_checker=__UpperCamelCase				,)
      pipe.to(__UpperCamelCase    )
      pipe.set_progress_bar_config(disable=__UpperCamelCase    )
      pipe.enable_attention_slicing()

      __SCREAMING_SNAKE_CASE      							=       """Face of a yellow cat, high resolution, sitting on a park bench"""

      __SCREAMING_SNAKE_CASE      							=       torch.manual_seed(0    )
      __SCREAMING_SNAKE_CASE      							=       pipe(
          prompt=__UpperCamelCase				,image=__UpperCamelCase				,mask_image=__UpperCamelCase				,generator=__UpperCamelCase				,output_type="""np"""				,)
      __SCREAMING_SNAKE_CASE      							=       output.images[0]

      assert image.shape == (512, 512, 3)
      assert np.abs(expected_image - image    ).max() < 5E-1





   def      UpperCAmelCase__     (					self				:			str    ):

      '''simple docstring'''

      torch.cuda.empty_cache()
      torch.cuda.reset_max_memory_allocated()
      torch.cuda.reset_peak_memory_stats()

      __SCREAMING_SNAKE_CASE      							=       load_image(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
          """/sd2-inpaint/init_image.png"""    )
      __SCREAMING_SNAKE_CASE      							=       load_image(
          """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png"""    )

      __SCREAMING_SNAKE_CASE      							=       """stabilityai/stable-diffusion-2-inpainting"""
      __SCREAMING_SNAKE_CASE      							=       PNDMScheduler.from_pretrained(__UpperCamelCase				,subfolder="""scheduler"""    )
      __SCREAMING_SNAKE_CASE      							=       StableDiffusionInpaintPipeline.from_pretrained(
          __UpperCamelCase				,safety_checker=__UpperCamelCase				,scheduler=__UpperCamelCase				,torch_dtype=torch.floataa				,)
      pipe.to(__UpperCamelCase    )
      pipe.set_progress_bar_config(disable=__UpperCamelCase    )
      pipe.enable_attention_slicing(1    )
      pipe.enable_sequential_cpu_offload()

      __SCREAMING_SNAKE_CASE      							=       """Face of a yellow cat, high resolution, sitting on a park bench"""

      __SCREAMING_SNAKE_CASE      							=       torch.manual_seed(0    )
      __SCREAMING_SNAKE_CASE      							=       pipe(
          prompt=__UpperCamelCase				,image=__UpperCamelCase				,mask_image=__UpperCamelCase				,generator=__UpperCamelCase				,num_inference_steps=2				,output_type="""np"""				,)

      __SCREAMING_SNAKE_CASE      							=       torch.cuda.max_memory_allocated()
      # make sure that less than 2.65 GB is allocated
      assert mem_bytes < 2.65 * 10**9












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


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import ChineseCLIPImageProcessor







class __a (   unittest.TestCase			):





   def __init__(					self				:			List[Any]				,lowerCamelCase				:			List[Any]				,lowerCamelCase				:			List[str]=7				,lowerCamelCase				:			List[str]=3				,lowerCamelCase				:			List[str]=18				,lowerCamelCase				:			Any=30				,lowerCamelCase				:			Optional[Any]=400				,lowerCamelCase				:			Optional[Any]=True				,lowerCamelCase				:			Optional[Any]=None				,lowerCamelCase				:			Optional[int]=True				,lowerCamelCase				:			int=None				,lowerCamelCase				:			str=True				,lowerCamelCase				:			Dict=[0.48_145_466, 0.4_578_275, 0.40_821_073]				,lowerCamelCase				:			List[str]=[0.26_862_954, 0.26_130_258, 0.27_577_711]				,lowerCamelCase				:			Tuple=True				,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       size if size is not None else {"""height""": 224, """width""": 224}
      __SCREAMING_SNAKE_CASE      							=       crop_size if crop_size is not None else {"""height""": 18, """width""": 18}
      __SCREAMING_SNAKE_CASE      							=       parent
      __SCREAMING_SNAKE_CASE      							=       batch_size
      __SCREAMING_SNAKE_CASE      							=       num_channels
      __SCREAMING_SNAKE_CASE      							=       image_size
      __SCREAMING_SNAKE_CASE      							=       min_resolution
      __SCREAMING_SNAKE_CASE      							=       max_resolution
      __SCREAMING_SNAKE_CASE      							=       do_resize
      __SCREAMING_SNAKE_CASE      							=       size
      __SCREAMING_SNAKE_CASE      							=       do_center_crop
      __SCREAMING_SNAKE_CASE      							=       crop_size
      __SCREAMING_SNAKE_CASE      							=       do_normalize
      __SCREAMING_SNAKE_CASE      							=       image_mean
      __SCREAMING_SNAKE_CASE      							=       image_std
      __SCREAMING_SNAKE_CASE      							=       do_convert_rgb





   def      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''simple docstring'''

      return {
          "do_resize": self.do_resize,
          "size": self.size,
          "do_center_crop": self.do_center_crop,
          "crop_size": self.crop_size,
          "do_normalize": self.do_normalize,
          "image_mean": self.image_mean,
          "image_std": self.image_std,
          "do_convert_rgb": self.do_convert_rgb,
      }





   def      UpperCAmelCase__     (					self				:			int				,lowerCamelCase				:			Union[str, Any]=False				,lowerCamelCase				:			str=False				,lowerCamelCase				:			str=False    ):

      '''simple docstring'''

      assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

      if equal_resolution:
         __SCREAMING_SNAKE_CASE      							=       []
         for i in range(self.batch_size    ):
            image_inputs.append(
                np.random.randint(
                    255				,size=(self.num_channels, self.max_resolution, self.max_resolution)				,dtype=np.uinta    )    )
      else:
         __SCREAMING_SNAKE_CASE      							=       []
         for i in range(self.batch_size    ):
            __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       np.random.choice(np.arange(self.min_resolution				,self.max_resolution    )				,2    )
            image_inputs.append(np.random.randint(255				,size=(self.num_channels, width, height)				,dtype=np.uinta    )    )

      if not numpify and not torchify:
         # PIL expects the channel dimension as last dimension
         __SCREAMING_SNAKE_CASE      							=       [Image.fromarray(np.moveaxis(lowerCamelCase				,0				,-1    )    ) for x in image_inputs]

      if torchify:
         __SCREAMING_SNAKE_CASE      							=       [torch.from_numpy(lowerCamelCase    ) for x in image_inputs]

      return image_inputs







@require_torch
@require_vision
class __a (   _snake_case,   unittest.TestCase			):
   __UpperCamelCase   : int	      =	ChineseCLIPImageProcessor if is_vision_available() else None





   def      UpperCAmelCase__     (					self				:			Any    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       ChineseCLIPImageProcessingTester(self				,do_center_crop=lowerCamelCase    )





   @property
   def      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''simple docstring'''

      return self.image_processor_tester.prepare_image_processor_dict()





   def      UpperCAmelCase__     (					self				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class(**self.image_processor_dict    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_resize"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""size"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_center_crop"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""center_crop"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_normalize"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""image_mean"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""image_std"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_convert_rgb"""    )    )





   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class.from_dict(self.image_processor_dict    )
      self.assertEqual(image_processor.size				,{"""height""": 224, """width""": 224}    )
      self.assertEqual(image_processor.crop_size				,{"""height""": 18, """width""": 18}    )

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class.from_dict(self.image_processor_dict				,size=42				,crop_size=84    )
      self.assertEqual(image_processor.size				,{"""shortest_edge""": 42}    )
      self.assertEqual(image_processor.crop_size				,{"""height""": 84, """width""": 84}    )





   def      UpperCAmelCase__     (					self				:			Dict    ):

      '''simple docstring'''

      pass





   def      UpperCAmelCase__     (					self				:			List[str]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class(**self.image_processor_dict    )
      # create random PIL images
      __SCREAMING_SNAKE_CASE      							=       self.image_processor_tester.prepare_inputs(equal_resolution=lowerCamelCase    )
      for image in image_inputs:
         self.assertIsInstance(lowerCamelCase				,Image.Image    )

      # Test not batched input
      __SCREAMING_SNAKE_CASE      							=       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.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)

      # Test batched
      __SCREAMING_SNAKE_CASE      							=       image_processing(lowerCamelCase				,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.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)





   def      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class(**self.image_processor_dict    )
      # create random numpy tensors
      __SCREAMING_SNAKE_CASE      							=       self.image_processor_tester.prepare_inputs(equal_resolution=lowerCamelCase				,numpify=lowerCamelCase    )
      for image in image_inputs:
         self.assertIsInstance(lowerCamelCase				,np.ndarray    )

      # Test not batched input
      __SCREAMING_SNAKE_CASE      							=       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.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)

      # Test batched
      __SCREAMING_SNAKE_CASE      							=       image_processing(lowerCamelCase				,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.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)





   def      UpperCAmelCase__     (					self				:			str    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class(**self.image_processor_dict    )
      # create random PyTorch tensors
      __SCREAMING_SNAKE_CASE      							=       self.image_processor_tester.prepare_inputs(equal_resolution=lowerCamelCase				,torchify=lowerCamelCase    )
      for image in image_inputs:
         self.assertIsInstance(lowerCamelCase				,torch.Tensor    )

      # Test not batched input
      __SCREAMING_SNAKE_CASE      							=       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.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)

      # Test batched
      __SCREAMING_SNAKE_CASE      							=       image_processing(lowerCamelCase				,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.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)







@require_torch
@require_vision
class __a (   _snake_case,   unittest.TestCase			):
   __UpperCamelCase   : Optional[int]	      =	ChineseCLIPImageProcessor if is_vision_available() else None





   def      UpperCAmelCase__     (					self				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       ChineseCLIPImageProcessingTester(self				,num_channels=4				,do_center_crop=lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       3





   @property
   def      UpperCAmelCase__     (					self				:			Dict    ):

      '''simple docstring'''

      return self.image_processor_tester.prepare_image_processor_dict()





   def      UpperCAmelCase__     (					self				:			int    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class(**self.image_processor_dict    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_resize"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""size"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_center_crop"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""center_crop"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_normalize"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""image_mean"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""image_std"""    )    )
      self.assertTrue(hasattr(lowerCamelCase				,"""do_convert_rgb"""    )    )





   def      UpperCAmelCase__     (					self				:			Tuple    ):

      '''simple docstring'''

      pass





   def      UpperCAmelCase__     (					self				:			Union[str, Any]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.image_processing_class(**self.image_processor_dict    )
      # create random PIL images
      __SCREAMING_SNAKE_CASE      							=       self.image_processor_tester.prepare_inputs(equal_resolution=lowerCamelCase    )
      for image in image_inputs:
         self.assertIsInstance(lowerCamelCase				,Image.Image    )

      # Test not batched input
      __SCREAMING_SNAKE_CASE      							=       image_processing(image_inputs[0]				,return_tensors="""pt"""    ).pixel_values
      self.assertEqual(
          encoded_images.shape				,(
              1,
              self.expected_encoded_image_num_channels,
              self.image_processor_tester.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)

      # Test batched
      __SCREAMING_SNAKE_CASE      							=       image_processing(lowerCamelCase				,return_tensors="""pt"""    ).pixel_values
      self.assertEqual(
          encoded_images.shape				,(
              self.image_processor_tester.batch_size,
              self.expected_encoded_image_num_channels,
              self.image_processor_tester.crop_size["""height"""],
              self.image_processor_tester.crop_size["""width"""],
          )				,)





