code: 
  
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  import inspect
  import unittest
  
  from transformers import ResNetConfig, is_flax_available
  from transformers.testing_utils import require_flax, slow
  from transformers.utils import cached_property, is_vision_available
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor
  
  
  if is_flax_available():
  	import jax
  	import jax.numpy as jnp
  
  	from transformers.models.resnet.modeling_flax_resnet import FlaxResNetForImageClassification, FlaxResNetModel
  
  if is_vision_available():
  	from PIL import Image
  
  	from transformers import AutoImageProcessor
  
  
  
  
  
  class 					_UpperCAmelCase							(		unittest.TestCase     ):
  		def __init__(						self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE=3,__SCREAMING_SNAKE_CASE=32,__SCREAMING_SNAKE_CASE=3,__SCREAMING_SNAKE_CASE=10,__SCREAMING_SNAKE_CASE=[10, 20, 30, 40],__SCREAMING_SNAKE_CASE=[1, 1, 2, 1],__SCREAMING_SNAKE_CASE=True,__SCREAMING_SNAKE_CASE=True,__SCREAMING_SNAKE_CASE="relu",__SCREAMING_SNAKE_CASE=3,__SCREAMING_SNAKE_CASE=None,):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       parent
  					__lowerCAmelCase      		=       batch_size
  					__lowerCAmelCase      		=       image_size
  					__lowerCAmelCase      		=       num_channels
  					__lowerCAmelCase      		=       embeddings_size
  					__lowerCAmelCase      		=       hidden_sizes
  					__lowerCAmelCase      		=       depths
  					__lowerCAmelCase      		=       is_training
  					__lowerCAmelCase      		=       use_labels
  					__lowerCAmelCase      		=       hidden_act
  					__lowerCAmelCase      		=       num_labels
  					__lowerCAmelCase      		=       scope
  					__lowerCAmelCase      		=       len(__SCREAMING_SNAKE_CASE    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )
  
  					__lowerCAmelCase      		=       self.get_config()
  
  					return config, pixel_values
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					return ResNetConfig(
  					    num_channels=self.num_channels,embeddings_size=self.embeddings_size,hidden_sizes=self.hidden_sizes,depths=self.depths,hidden_act=self.hidden_act,num_labels=self.num_labels,image_size=self.image_size,)
  		def 						lowerCamelCase__    (						self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       FlaxResNetModel(config=__SCREAMING_SNAKE_CASE    )
  					__lowerCAmelCase      		=       model(__SCREAMING_SNAKE_CASE    )
  
  					# Output shape (b, c, h, w)
  					self.parent.assertEqual(
  					    result.last_hidden_state.shape,(self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32),)
  		def 						lowerCamelCase__    (						self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       self.num_labels
  					__lowerCAmelCase      		=       FlaxResNetForImageClassification(config=__SCREAMING_SNAKE_CASE    )
  					__lowerCAmelCase      		=       model(__SCREAMING_SNAKE_CASE    )
  					self.parent.assertEqual(result.logits.shape,(self.batch_size, self.num_labels)    )
  
  
  
  
  
  
  
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       self.prepare_config_and_inputs()
  					__lowerCAmelCase		, __lowerCAmelCase      		=       config_and_inputs
  					__lowerCAmelCase      		=       {"""pixel_values""": pixel_values}
  					return config, inputs_dict
  
  
  
  
  
  @require_flax
  class 					_UpperCAmelCase							(		lowerCAmelCase_			,      unittest.TestCase     ):
  		a     :     List[str]     						=(FlaxResNetModel, FlaxResNetForImageClassification) if is_flax_available() else ()
  
  		a     :     Dict     						=False
  		a     :     Dict     						=False
  		a     :     Optional[Any]     						=False
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       FlaxResNetModelTester(self    )
  					__lowerCAmelCase      		=       ConfigTester(self,config_class=__SCREAMING_SNAKE_CASE,has_text_modality=__SCREAMING_SNAKE_CASE    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					self.create_and_test_config_common_properties()
  					self.config_tester.create_and_test_config_to_json_string()
  					self.config_tester.create_and_test_config_to_json_file()
  					self.config_tester.create_and_test_config_from_and_save_pretrained()
  					self.config_tester.create_and_test_config_with_num_labels()
  					self.config_tester.check_config_can_be_init_without_params()
  					self.config_tester.check_config_arguments_init()
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					return
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       self.model_tester.prepare_config_and_inputs()
  					self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       self.model_tester.prepare_config_and_inputs()
  					self.model_tester.create_and_check_for_image_classification(*__SCREAMING_SNAKE_CASE    )
  		@unittest.skip(reason="""ResNet does not use inputs_embeds"""    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					pass
  		@unittest.skip(reason="""ResNet does not support input and output embeddings"""    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					pass
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase		, __lowerCAmelCase      		=       self.model_tester.prepare_config_and_inputs_for_common()
  
  					for model_class in self.all_model_classes:
  								__lowerCAmelCase      		=       model_class(__SCREAMING_SNAKE_CASE    )
  								__lowerCAmelCase      		=       inspect.signature(model.__call__    )
  								# signature.parameters is an OrderedDict => so arg_names order is deterministic
  								__lowerCAmelCase      		=       [*signature.parameters.keys()]
  
  								__lowerCAmelCase      		=       ["""pixel_values"""]
  								self.assertListEqual(arg_names[:1],__SCREAMING_SNAKE_CASE    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					def check_hidden_states_output(__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE    ):
  								__lowerCAmelCase      		=       model_class(__SCREAMING_SNAKE_CASE    )
  
  								__lowerCAmelCase      		=       model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE    )    )
  
  								__lowerCAmelCase      		=       outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states
  
  								__lowerCAmelCase      		=       self.model_tester.num_stages
  								self.assertEqual(len(__SCREAMING_SNAKE_CASE    ),expected_num_stages + 1    )
  		@unittest.skip(reason="""ResNet does not use feedforward chunking"""    )
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					pass
  
  
  
  
  
  
  
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase		, __lowerCAmelCase      		=       self.model_tester.prepare_config_and_inputs_for_common()
  
  					for model_class in self.all_model_classes:
  								with self.subTest(model_class.__name__    ):
  											__lowerCAmelCase      		=       self._prepare_for_class(__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE    )
  											__lowerCAmelCase      		=       model_class(__SCREAMING_SNAKE_CASE    )
  
  											@jax.jit
  											def model_jitted(__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE    ):
  														return model(pixel_values=__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE    )
  
  											with self.subTest("""JIT Enabled"""    ):
  														__lowerCAmelCase      		=       model_jitted(**__SCREAMING_SNAKE_CASE    ).to_tuple()
  
  											with self.subTest("""JIT Disabled"""    ):
  														with jax.disable_jit():
  																	__lowerCAmelCase      		=       model_jitted(**__SCREAMING_SNAKE_CASE    ).to_tuple()
  
  											self.assertEqual(len(__SCREAMING_SNAKE_CASE    ),len(__SCREAMING_SNAKE_CASE    )    )
  											for jitted_output, output in zip(__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE    ):
  														self.assertEqual(jitted_output.shape,output.shape    )
  
  
  
  
  
  def      _lowerCAmelCase		(		)      ->      List[str]:
  			__lowerCAmelCase      		=       Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""			)
  			return image
  
  
  
  
  
  
  
  @require_flax
  class 					_UpperCAmelCase							(		unittest.TestCase     ):
  		@cached_property
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					return AutoImageProcessor.from_pretrained("""microsoft/resnet-50"""    ) if is_vision_available() else None
  
  
  
  
  
  
  
  		@slow
  		def 						lowerCamelCase__    (						self    ):
  
  
  
  					'''simple docstring'''
  
  					__lowerCAmelCase      		=       FlaxResNetForImageClassification.from_pretrained("""microsoft/resnet-50"""    )
  
  					__lowerCAmelCase      		=       self.default_image_processor
  					__lowerCAmelCase      		=       prepare_img()
  					__lowerCAmelCase      		=       image_processor(images=__SCREAMING_SNAKE_CASE,return_tensors="""np"""    )
  
  					__lowerCAmelCase      		=       model(**__SCREAMING_SNAKE_CASE    )
  
  					# verify the logits
  					__lowerCAmelCase      		=       (1, 10_00)
  					self.assertEqual(outputs.logits.shape,__SCREAMING_SNAKE_CASE    )
  
  					__lowerCAmelCase      		=       jnp.array([-11.1069, -9.7877, -8.3777]    )
  
  					self.assertTrue(jnp.allclose(outputs.logits[0, :3],__SCREAMING_SNAKE_CASE,atol=1e-4    )    )
  
  
style_context: 
  
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  from cva import destroyAllWindows, imread, imshow, waitKey
  
  
  
  
  
  def      _lowerCAmelCase		(		lowercase      ,			lowercase			)      ->      int:
  			__lowerCAmelCase		, __lowerCAmelCase      		=       img.shape[0], img.shape[1]
  
  			def to_grayscale(lowercase      ,			lowercase      ,			lowercase			):
  						return 0.21_26 * red + 0.5_87 * green + 0.1_14 * blue
  
  			def normalize(lowercase			):
  						return min(lowercase      ,			255			)
  
  			for i in range(lowercase			):
  						for j in range(lowercase			):
  									__lowerCAmelCase      		=       int(to_grayscale(*img[i][j]			)			)
  									__lowerCAmelCase      		=       [
  									    normalize(lowercase			),
  									    normalize(greyscale + factor			),
  									    normalize(greyscale + 2 * factor			),
  									]
  
  			return img
  
  
  if __name__ == "__main__":
  	# read original image
  	_a      :				Any											=					{
  	    percentage: imread("""image_data/lena.jpg""", 1) for percentage in (1_0, 2_0, 3_0, 4_0)
  	}
  
  	for percentage, img in images.items():
  		make_sepia(img, percentage)
  
  	for percentage, img in images.items():
  		imshow(f'Original image with sepia (factor: {percentage})', img)
  
  	waitKey(0)
  	destroyAllWindows()
  
  