code: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import unittest
  
  from transformers.image_processing_utils import get_size_dict
  class 						__lowerCAmelCase   (			unittest.TestCase       ):
  
  
  
  
  
  
  
  		'''simple docstring'''
  
  
  		def 					UpperCamelCase__   (      self:		str					):
  					# Test a dict with the wrong keys raises an error
  					UpperCamelCase_     ={"wrong_key": 224}
  					with self.assertRaises(UpperCamelCase_					):
  								get_size_dict(UpperCamelCase_					)
  
  					UpperCamelCase_     ={"height": 224}
  					with self.assertRaises(UpperCamelCase_					):
  								get_size_dict(UpperCamelCase_					)
  
  					UpperCamelCase_     ={"width": 224, "shortest_edge": 224}
  					with self.assertRaises(UpperCamelCase_					):
  								get_size_dict(UpperCamelCase_					)
  
  					# Test a dict with the correct keys is returned as is
  					UpperCamelCase_     ={"height": 224, "width": 224}
  					UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
  					self.assertEqual(UpperCamelCase_				,			UpperCamelCase_					)
  
  					UpperCamelCase_     ={"shortest_edge": 224}
  					UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
  					self.assertEqual(UpperCamelCase_				,			{"shortest_edge": 224}					)
  
  					UpperCamelCase_     ={"longest_edge": 224, "shortest_edge": 224}
  					UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
  					self.assertEqual(UpperCamelCase_				,			{"longest_edge": 224, "shortest_edge": 224}					)
  
  					# Test a single int value which  represents (size, size)
  					UpperCamelCase_     =get_size_dict(224					)
  					self.assertEqual(UpperCamelCase_				,			{"height": 224, "width": 224}					)
  
  					# Test a single int value which represents the shortest edge
  					UpperCamelCase_     =get_size_dict(224				,			default_to_square=UpperCamelCase_					)
  					self.assertEqual(UpperCamelCase_				,			{"shortest_edge": 224}					)
  
  					# Test a tuple of ints which represents (height, width)
  					UpperCamelCase_     =get_size_dict((150, 200)					)
  					self.assertEqual(UpperCamelCase_				,			{"height": 150, "width": 200}					)
  
  					# Test a tuple of ints which represents (width, height)
  					UpperCamelCase_     =get_size_dict((150, 200)				,			height_width_order=UpperCamelCase_					)
  					self.assertEqual(UpperCamelCase_				,			{"height": 200, "width": 150}					)
  
  					# Test an int representing the shortest edge and max_size which represents the longest edge
  					UpperCamelCase_     =get_size_dict(224				,			max_size=256				,			default_to_square=UpperCamelCase_					)
  					self.assertEqual(UpperCamelCase_				,			{"shortest_edge": 224, "longest_edge": 256}					)
  
  					# Test int with default_to_square=True and max_size fails
  					with self.assertRaises(UpperCamelCase_					):
  								get_size_dict(224				,			max_size=256				,			default_to_square=UpperCamelCase_					)
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import unittest
  from dataclasses import dataclass
  from typing import List, Union
  
  import numpy as np
  import PIL.Image
  
  from diffusers.utils.outputs import BaseOutput
  @dataclass
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    Union[List[PIL.Image.Image], np.ndarray]
  
  
  
  
  class 						__lowerCAmelCase   (			unittest.TestCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    def 					UpperCamelCase__   (      self:		Tuple					):
       UpperCamelCase_     =CustomOutput(images=np.random.rand(1				,			3				,			4				,			4					)					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			np.ndarray					)
       assert outputs.images.shape == (1, 3, 4, 4)
       assert isinstance(outputs["images"]				,			np.ndarray					)
       assert outputs["images"].shape == (1, 3, 4, 4)
       assert isinstance(outputs[0]				,			np.ndarray					)
       assert outputs[0].shape == (1, 3, 4, 4)
  
       # test with a non-tensor attribute
       UpperCamelCase_     =CustomOutput(images=[PIL.Image.new("RGB"				,			(4, 4)					)]					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			UpperCamelCase_					)
       assert isinstance(outputs.images[0]				,			PIL.Image.Image					)
       assert isinstance(outputs["images"]				,			UpperCamelCase_					)
       assert isinstance(outputs["images"][0]				,			PIL.Image.Image					)
       assert isinstance(outputs[0]				,			UpperCamelCase_					)
       assert isinstance(outputs[0][0]				,			PIL.Image.Image					)
  
  
  
  
  
    def 					UpperCamelCase__   (      self:		Optional[int]					):
       # test output reinitialization with a `dict` for compatibility with `accelerate`
       UpperCamelCase_     =CustomOutput({"images": np.random.rand(1				,			3				,			4				,			4					)}					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			np.ndarray					)
       assert outputs.images.shape == (1, 3, 4, 4)
       assert isinstance(outputs["images"]				,			np.ndarray					)
       assert outputs["images"].shape == (1, 3, 4, 4)
       assert isinstance(outputs[0]				,			np.ndarray					)
       assert outputs[0].shape == (1, 3, 4, 4)
  
       # test with a non-tensor attribute
       UpperCamelCase_     =CustomOutput({"images": [PIL.Image.new("RGB"				,			(4, 4)					)]}					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			UpperCamelCase_					)
       assert isinstance(outputs.images[0]				,			PIL.Image.Image					)
       assert isinstance(outputs["images"]				,			UpperCamelCase_					)
       assert isinstance(outputs["images"][0]				,			PIL.Image.Image					)
       assert isinstance(outputs[0]				,			UpperCamelCase_					)
       assert isinstance(outputs[0][0]				,			PIL.Image.Image					)
  