code: 
  
  
  
  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      UpperCAmelCase_						(     unittest.TestCase ):
  
        '''simple docstring'''
  
  
  
  
        def __init__(					self   ,							_A   ,							_A=7   ,							_A=3   ,							_A=18   ,							_A=30   ,							_A=400   ,							_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]   ,							):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      size if size is not None else {'shortest_edge': 20}
               __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								=      crop_pct
               __SCREAMING_SNAKE_CASE								=      do_normalize
               __SCREAMING_SNAKE_CASE								=      image_mean
               __SCREAMING_SNAKE_CASE								=      image_std
  
  
  
  
  
  
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''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,
                   "crop_pct": self.crop_pct,
               }
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class      UpperCAmelCase_						(     UpperCamelCase_					,					unittest.TestCase ):
  
        '''simple docstring'''
  
  
  
  
        UpperCamelCase__    :				Union[str, Any]       						=						ConvNextImageProcessor if is_vision_available() else None
  
  
  
  
  
  
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      ConvNextImageProcessingTester(self	)
  
  
  
  
  
  
        @property
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      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  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      self.image_processing_class.from_dict(self.image_processor_dict	)
               self.assertEqual(image_processor.size   ,							{'shortest_edge': 20}	)
  
               __SCREAMING_SNAKE_CASE								=      self.image_processing_class.from_dict(self.image_processor_dict   ,							size=42	)
               self.assertEqual(image_processor.size   ,							{'shortest_edge': 42}	)
  
  
  
  
  
  
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               pass
  
  
  
  
  
  
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      self.image_processing_class(**self.image_processor_dict	)
               # create random PIL images
               __SCREAMING_SNAKE_CASE								=      prepare_image_inputs(self.image_processor_tester   ,							equal_resolution=_A	)
               for image in image_inputs:
                      self.assertIsInstance(_A   ,							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.size['shortest_edge'],
                       self.image_processor_tester.size['shortest_edge'],
                   )   ,							)
  
               # Test batched
               __SCREAMING_SNAKE_CASE								=      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  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      self.image_processing_class(**self.image_processor_dict	)
               # create random numpy tensors
               __SCREAMING_SNAKE_CASE								=      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
               __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.size['shortest_edge'],
                       self.image_processor_tester.size['shortest_edge'],
                   )   ,							)
  
               # Test batched
               __SCREAMING_SNAKE_CASE								=      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  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      self.image_processing_class(**self.image_processor_dict	)
               # create random PyTorch tensors
               __SCREAMING_SNAKE_CASE								=      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
               __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.size['shortest_edge'],
                       self.image_processor_tester.size['shortest_edge'],
                   )   ,							)
  
               # Test batched
               __SCREAMING_SNAKE_CASE								=      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 __future__ import annotations
  
  from collections.abc import Iterable
  from dataclasses import dataclass
  from typing import Any
  
  class      UpperCAmelCase_						:
  
  						'''simple docstring'''
  
  
  
  
  						UpperCamelCase__    :				List[str]       						=						('''_front''', '''_back''', '''_len''')
  
  						@dataclass
  						class      UpperCAmelCase_						:
  
  												'''simple docstring'''
  
  
  
  
  												UpperCamelCase__    :				Any       						=						None
  												UpperCamelCase__    :				Deque._Node | None       						=						None
  												UpperCamelCase__    :				Deque._Node | None       						=						None
  
  
  
  
  
  
  
  						class      UpperCAmelCase_						:
  
  												'''simple docstring'''
  
  
  
  
  												UpperCamelCase__    :				Optional[int]       						=						('''_cur''',)
  
  
  
  
  
  
  												def __init__(					self   ,							_A	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			__SCREAMING_SNAKE_CASE								=      cur
  
  
  
  
  
  
  												def __iter__(					self	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			return self
  
  
  
  
  
  
  												def  _A			(					self	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			if self._cur is None:
  																										# finished iterating
  																										raise StopIteration
  																			__SCREAMING_SNAKE_CASE								=      self._cur.val
  																			__SCREAMING_SNAKE_CASE								=      self._cur.next_node
  
  																			return val
  
  
  
  
  
  
  
  						def __init__(					self   ,							_A = None	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      0
  
  													if iterable is not None:
  																				# append every value to the deque
  																				for val in iterable:
  																											self.append(_A	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      self._Node(_A   ,							_A   ,							_A	)
  													if self.is_empty():
  																				# front = back
  																				__SCREAMING_SNAKE_CASE								=      __SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      1
  													else:
  																				# connect nodes
  																				__SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      self._back
  																				__SCREAMING_SNAKE_CASE								=      node  # assign new back to the new node
  
  																				self._len += 1
  
  																				# make sure there were no errors
  																				assert not self.is_empty(), "Error on appending value."
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      self._Node(_A   ,							_A   ,							_A	)
  													if self.is_empty():
  																				# front = back
  																				__SCREAMING_SNAKE_CASE								=      __SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      1
  													else:
  																				# connect nodes
  																				__SCREAMING_SNAKE_CASE								=      self._front
  																				__SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      node  # assign new front to the new node
  
  																				self._len += 1
  
  																				# make sure there were no errors
  																				assert not self.is_empty(), "Error on appending value."
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													for val in iterable:
  																				self.append(_A	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													for val in iterable:
  																				self.appendleft(_A	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													assert not self.is_empty(), "Deque is empty."
  
  													__SCREAMING_SNAKE_CASE								=      self._back
  													__SCREAMING_SNAKE_CASE								=      self._back.prev_node  # set new back
  													# drop the last node - python will deallocate memory automatically
  													__SCREAMING_SNAKE_CASE								=      None
  
  													self._len -= 1
  
  													return topop.val
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													assert not self.is_empty(), "Deque is empty."
  
  													__SCREAMING_SNAKE_CASE								=      self._front
  													__SCREAMING_SNAKE_CASE								=      self._front.next_node  # set new front and drop the first node
  													__SCREAMING_SNAKE_CASE								=      None
  
  													self._len -= 1
  
  													return topop.val
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._front is None
  
  
  
  
  
  
  						def __len__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._len
  
  
  
  
  
  
  						def __eq__(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if not isinstance(_A   ,							_A	):
  																				return NotImplemented
  
  													__SCREAMING_SNAKE_CASE								=      self._front
  													__SCREAMING_SNAKE_CASE								=      other._front
  
  													# if the length of the dequeues are not the same, they are not equal
  													if len(self	) != len(_A	):
  																				return False
  
  													while me is not None and oth is not None:
  																				# compare every value
  																				if me.val != oth.val:
  																											return False
  																				__SCREAMING_SNAKE_CASE								=      me.next_node
  																				__SCREAMING_SNAKE_CASE								=      oth.next_node
  
  													return True
  
  
  
  
  
  
  						def __iter__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return Deque._Iterator(self._front	)
  
  
  
  
  
  
  						def __repr__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      []
  													__SCREAMING_SNAKE_CASE								=      self._front
  													while aux is not None:
  																				# append the values in a list to display
  																				values_list.append(aux.val	)
  																				__SCREAMING_SNAKE_CASE								=      aux.next_node
  
  													return f"""[{", ".join(repr(_A	) for val in values_list	)}]"""
  
  
  if __name__ == "__main__":
  			import doctest
  
  			doctest.testmod()
  
  
  
  
  
  
  