code: 
  
  
  
  
  
  
  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 				__SCREAMING_SNAKE_CASE   (			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							,						):
              lowercase			:   int					   =		parent
              lowercase			:   List[Any]					   =		batch_size
              lowercase			:   Dict					   =		image_size
              lowercase			:   Any					   =		num_channels
              lowercase			:   Dict					   =		embeddings_size
              lowercase			:   Union[str, Any]					   =		hidden_sizes
              lowercase			:   Dict					   =		depths
              lowercase			:   Optional[int]					   =		is_training
              lowercase			:   Tuple					   =		use_labels
              lowercase			:   Union[str, Any]					   =		hidden_act
              lowercase			:   Any					   =		num_labels
              lowercase			:   int					   =		scope
              lowercase			:   Any					   =		len(_lowerCAmelCase		)
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   Tuple					   =		floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]		)
  
              lowercase			:   Tuple					   =		self.get_config()
  
              return config, pixel_values
  
  
        def        __lowerCamelCase			(							self		):
              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__		):
              lowercase			:   List[Any]					   =		FlaxResNetModel(config=_lowerCAmelCase		)
              lowercase			:   Dict					   =		model(_lowerCAmelCase		)
  
              # 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__		):
              lowercase			:   Optional[Any]					   =		self.num_labels
              lowercase			:   Optional[Any]					   =		FlaxResNetForImageClassification(config=_lowerCAmelCase		)
              lowercase			:   Optional[Any]					   =		model(_lowerCAmelCase		)
              self.parent.assertEqual(result.logits.shape							,						(self.batch_size, self.num_labels)		)
  
  
  
  
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   str					   =		self.prepare_config_and_inputs()
              lowercase			:   Union[str, Any]					   =		config_and_inputs
              lowercase			:   List[str]					   =		{"""pixel_values""": pixel_values}
              return config, inputs_dict
  
  
  
  
  
  
  
  @require_flax
  class 				__SCREAMING_SNAKE_CASE   (			__lowerCamelCase  ,						unittest.TestCase   ):
        A				:							List[Any]    							=     (FlaxResNetModel, FlaxResNetForImageClassification) if is_flax_available() else ()
  
        A				:							int    							=     False
        A				:							Any    							=     False
        A				:							List[Any]    							=     False
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   Optional[Any]					   =		FlaxResNetModelTester(self		)
              lowercase			:   Optional[int]					   =		ConfigTester(self							,						config_class=_lowerCAmelCase							,						has_text_modality=_lowerCAmelCase		)
  
  
        def        __lowerCamelCase			(							self		):
              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		):
              return
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   Optional[Any]					   =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_model(*_lowerCAmelCase		)
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   List[str]					   =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_image_classification(*_lowerCAmelCase		)
  
  
        @unittest.skip(reason='''ResNet does not use inputs_embeds'''		)
        def        __lowerCamelCase			(							self		):
              pass
  
  
        @unittest.skip(reason='''ResNet does not support input and output embeddings'''		)
        def        __lowerCamelCase			(							self		):
              pass
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   List[Any]					   =		self.model_tester.prepare_config_and_inputs_for_common()
  
              for model_class in self.all_model_classes:
                    lowercase			:   Any					   =		model_class(_lowerCAmelCase		)
                    lowercase			:   str					   =		inspect.signature(model.__call__		)
                    # signature.parameters is an OrderedDict => so arg_names order is deterministic
                    lowercase			:   Tuple					   =		[*signature.parameters.keys()]
  
                    lowercase			:   Optional[Any]					   =		["""pixel_values"""]
                    self.assertListEqual(arg_names[:1]							,						_lowerCAmelCase		)
  
  
        def        __lowerCamelCase			(							self		):
              def check_hidden_states_output(SCREAMING_SNAKE_CASE__							,						SCREAMING_SNAKE_CASE__							,						SCREAMING_SNAKE_CASE__		):
                    lowercase			:   Union[str, Any]					   =		model_class(_lowerCAmelCase		)
  
                    lowercase			:   List[str]					   =		model(**self._prepare_for_class(_lowerCAmelCase							,						_lowerCAmelCase		)		)
  
                    lowercase			:   str					   =		outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states
  
                    lowercase			:   str					   =		self.model_tester.num_stages
                    self.assertEqual(len(_lowerCAmelCase		)							,						expected_num_stages + 1		)
  
  
        @unittest.skip(reason='''ResNet does not use feedforward chunking'''		)
        def        __lowerCamelCase			(							self		):
              pass
  
  
  
  
  
  
        def        __lowerCamelCase			(							self		):
              lowercase			:   Tuple					   =		self.model_tester.prepare_config_and_inputs_for_common()
  
              for model_class in self.all_model_classes:
                    with self.subTest(model_class.__name__		):
                          lowercase			:   List[Any]					   =		self._prepare_for_class(_lowerCAmelCase							,						_lowerCAmelCase		)
                          lowercase			:   Union[str, Any]					   =		model_class(_lowerCAmelCase		)
  
                          @jax.jit
                          def model_jitted(SCREAMING_SNAKE_CASE__							,						**SCREAMING_SNAKE_CASE__		):
                                return model(pixel_values=_lowerCAmelCase							,						**_lowerCAmelCase		)
  
                          with self.subTest('''JIT Enabled'''		):
                                lowercase			:   Union[str, Any]					   =		model_jitted(**_lowerCAmelCase		).to_tuple()
  
                          with self.subTest('''JIT Disabled'''		):
                                with jax.disable_jit():
                                      lowercase			:   Any					   =		model_jitted(**_lowerCAmelCase		).to_tuple()
  
                          self.assertEqual(len(_lowerCAmelCase		)							,						len(_lowerCAmelCase		)		)
                          for jitted_output, output in zip(_lowerCAmelCase							,						_lowerCAmelCase		):
                                self.assertEqual(jitted_output.shape							,						output.shape		)
  
  
  
  
  
  def 			__lowercase	(						)    ->Tuple:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   Tuple					   =		Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''     )
        return image
  
  
  
  
  
  
  
  @require_flax
  class 				__SCREAMING_SNAKE_CASE   (			unittest.TestCase   ):
  
  
        @cached_property
        def        __lowerCamelCase			(							self		):
              return AutoImageProcessor.from_pretrained('''microsoft/resnet-50'''		) if is_vision_available() else None
  
  
  
  
  
  
        @slow
        def        __lowerCamelCase			(							self		):
              lowercase			:   Optional[Any]					   =		FlaxResNetForImageClassification.from_pretrained('''microsoft/resnet-50'''		)
  
              lowercase			:   Tuple					   =		self.default_image_processor
              lowercase			:   Any					   =		prepare_img()
              lowercase			:   Union[str, Any]					   =		image_processor(images=_lowerCAmelCase							,						return_tensors='''np'''		)
  
              lowercase			:   Any					   =		model(**_lowerCAmelCase		)
  
              # verify the logits
              lowercase			:   Tuple					   =		(1, 1000)
              self.assertEqual(outputs.logits.shape							,						_lowerCAmelCase		)
  
              lowercase			:   Tuple					   =		jnp.array([-11.1069, -9.7877, -8.3777]		)
  
              self.assertTrue(jnp.allclose(outputs.logits[0, :3]							,						_lowerCAmelCase							,						atol=1E-4		)		)
  
  
style_context: 
  
  
  __a   				=      [
      [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
      [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
      [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
      [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
  ]
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )    ->bool:
  
  
  
  
  
  
  
        """simple docstring"""
  
        return 0 <= row < rows and 0 <= col < cols
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )    ->int:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   Optional[int]					   =		len(_UpperCamelCase     )
        lowercase			:   str					   =		len(mat[0]     )
        if is_safe(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     ) and (row, col) not in seen and mat[row][col] == 1:
              seen.add((row, col)     )
              return (
                  1
                  + depth_first_search(row + 1,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
                  + depth_first_search(row - 1,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
                  + depth_first_search(_UpperCamelCase,    col + 1,    _UpperCamelCase,    _UpperCamelCase     )
                  + depth_first_search(_UpperCamelCase,    col - 1,    _UpperCamelCase,    _UpperCamelCase     )
              )
        else:
              return 0
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase     )    ->int:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   set					   =		set()
  
        lowercase			:   Tuple					   =		0
        for row, line in enumerate(_UpperCamelCase     ):
              for col, item in enumerate(_UpperCamelCase     ):
                    if item == 1 and (row, col) not in seen:
                          # Maximizing the area
                          lowercase			:   Tuple					   =		max(_UpperCamelCase,    depth_first_search(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )     )
        return max_area
  
  
  if __name__ == "__main__":
    import doctest
  
    print(find_max_area(matrix))  # Output -> 6
    doctest.testmod()
  
  