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







class 			__A					(			unittest.TestCase      ):
 def __init__( self      :     List[str]					, lowerCamelCase      :     Optional[Any]					, lowerCamelCase      :     int=13					, lowerCamelCase      :     List[Any]=3					, lowerCamelCase      :     int=18					, lowerCamelCase      :     List[Any]=30					, lowerCamelCase      :     Optional[int]=4_00					, lowerCamelCase      :     Any=True					, lowerCamelCase      :     int=None					, lowerCamelCase      :     Any=True					, lowerCamelCase      :     Optional[int]=[0.5, 0.5, 0.5]					, lowerCamelCase      :     List[Any]=[0.5, 0.5, 0.5]					, ):



   """simple docstring"""





   __A		:  Optional[int]       				=		size if size is not None else {"""height""": 18, """width""": 18}
   __A		:  Any       				=		parent
   __A		:  Dict       				=		batch_size
   __A		:  Dict       				=		num_channels
   __A		:  int       				=		image_size
   __A		:  Union[str, Any]       				=		min_resolution
   __A		:  int       				=		max_resolution
   __A		:  Tuple       				=		do_resize
   __A		:  str       				=		size
   __A		:  Optional[Any]       				=		do_normalize
   __A		:  List[str]       				=		image_mean
   __A		:  Optional[Any]       				=		image_std






 def 		lowercase_( self      :     Optional[Any]							):



   """simple docstring"""





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







@require_torch
@require_vision
class 			__A					(			_SCREAMING_SNAKE_CASE     ,    unittest.TestCase      ):
 lowerCamelCase												=EfficientNetImageProcessor if is_vision_available() else None
 def 		lowercase_( self      :     Optional[Any]							):



   """simple docstring"""





   __A		:  Tuple       				=		EfficientNetImageProcessorTester(self							)
 @property
 def 		lowercase_( self      :     Optional[int]							):



   """simple docstring"""





   return self.image_processor_tester.prepare_image_processor_dict()
 def 		lowercase_( self      :     Dict							):



   """simple docstring"""





   __A		:  Optional[int]       				=		self.image_processing_class(**self.image_processor_dict							)
   self.assertTrue(hasattr(lowerCamelCase					, """image_mean"""							)							)
   self.assertTrue(hasattr(lowerCamelCase					, """image_std"""							)							)
   self.assertTrue(hasattr(lowerCamelCase					, """do_normalize"""							)							)
   self.assertTrue(hasattr(lowerCamelCase					, """do_resize"""							)							)
   self.assertTrue(hasattr(lowerCamelCase					, """size"""							)							)
 def 		lowercase_( self      :     List[str]							):



   """simple docstring"""





   __A		:  Dict       				=		self.image_processing_class.from_dict(self.image_processor_dict							)
   self.assertEqual(image_processor.size					, {"""height""": 18, """width""": 18}							)

   __A		:  Optional[int]       				=		self.image_processing_class.from_dict(self.image_processor_dict					, size=42							)
   self.assertEqual(image_processor.size					, {"""height""": 42, """width""": 42}							)
 def 		lowercase_( self      :     Union[str, Any]							):



   """simple docstring"""





   __A		:  Optional[Any]       				=		self.image_processing_class(**self.image_processor_dict							)
   # create random PIL images
   __A		:  Tuple       				=		prepare_image_inputs(self.image_processor_tester					, equal_resolution=lowerCamelCase							)
   for image in image_inputs:
     self.assertIsInstance(lowerCamelCase					, Image.Image							)

   # Test not batched input
   __A		:  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["""height"""],
           self.image_processor_tester.size["""width"""],
       )					, )

   # Test batched
   __A		:  str       				=		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.size["""height"""],
           self.image_processor_tester.size["""width"""],
       )					, )
 def 		lowercase_( self      :     Dict							):



   """simple docstring"""





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

   # Test not batched input
   __A		:  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["""height"""],
           self.image_processor_tester.size["""width"""],
       )					, )

   # Test batched
   __A		:  Optional[int]       				=		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.size["""height"""],
           self.image_processor_tester.size["""width"""],
       )					, )






 def 		lowercase_( self      :     Optional[int]							):



   """simple docstring"""





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

   # Test not batched input
   __A		:  Union[str, 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["""height"""],
           self.image_processor_tester.size["""width"""],
       )					, )

   # Test batched
   __A		:  Any       				=		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.size["""height"""],
           self.image_processor_tester.size["""width"""],
       )					, )











'''simple docstring'''


from dataclasses import dataclass
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
# Copied from diffusers.pipelines.stable_diffusion.__init__.StableDiffusionPipelineOutput with Stable->Alt
class  _SCREAMING_SNAKE_CASE				(		SCREAMING_SNAKE_CASE						):


			'''simple docstring'''





			__a				:				Union[List[PIL.Image.Image], np.ndarray]
			__a				:				Optional[List[bool]]


if is_transformers_available() and is_torch_available():
					from .modeling_roberta_series import RobertaSeriesModelWithTransformation
					from .pipeline_alt_diffusion import AltDiffusionPipeline
					from .pipeline_alt_diffusion_imgaimg import AltDiffusionImgaImgPipeline
