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   a_  (unittest.TestCase    ):
  
  
  
  
         def __init__(     self   ,   snake_case_   ,   snake_case_=3   ,   snake_case_=3_2   ,   snake_case_=3   ,   snake_case_=1_0   ,   snake_case_=[1_0, 2_0, 3_0, 4_0]   ,   snake_case_=[1, 1, 2, 1]   ,   snake_case_=True   ,   snake_case_=True   ,   snake_case_="relu"   ,   snake_case_=3   ,   snake_case_=None   ,   ):
           _lowerCAmelCase       :  Tuple   				=					parent
           _lowerCAmelCase       :  List[str]   				=					batch_size
           _lowerCAmelCase       :  int   				=					image_size
           _lowerCAmelCase       :  Any   				=					num_channels
           _lowerCAmelCase       :  Any   				=					embeddings_size
           _lowerCAmelCase       :  List[str]   				=					hidden_sizes
           _lowerCAmelCase       :  Tuple   				=					depths
           _lowerCAmelCase       :  str   				=					is_training
           _lowerCAmelCase       :  Optional[int]   				=					use_labels
           _lowerCAmelCase       :  List[str]   				=					hidden_act
           _lowerCAmelCase       :  int   				=					num_labels
           _lowerCAmelCase       :  Optional[int]   				=					scope
           _lowerCAmelCase       :  Dict   				=					len(snake_case_  )
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  List[Any]   				=					floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )
  
           _lowerCAmelCase       :  Optional[int]   				=					self.get_config()
  
           return config, pixel_values
  
  
  
  
         def 							__UpperCamelCase       (     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 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_  ):
           _lowerCAmelCase       :  Union[str, Any]   				=					FlaxResNetModel(config=snake_case_  )
           _lowerCAmelCase       :  int   				=					model(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 // 3_2, self.image_size // 3_2)   ,   )
  
  
  
  
         def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_  ):
           _lowerCAmelCase       :  int   				=					self.num_labels
           _lowerCAmelCase       :  Any   				=					FlaxResNetForImageClassification(config=snake_case_  )
           _lowerCAmelCase       :  Any   				=					model(snake_case_  )
           self.parent.assertEqual(result.logits.shape   ,   (self.batch_size, self.num_labels)  )
  
  
  
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  Union[str, Any]   				=					self.prepare_config_and_inputs()
           _lowerCAmelCase				,					_lowerCAmelCase       :  List[str]   				=					config_and_inputs
           _lowerCAmelCase       :  List[Any]   				=					{"""pixel_values""": pixel_values}
           return config, inputs_dict
  
  
  
  @require_flax
  class   a_  (_a							,			unittest.TestCase    ):
         __lowerCAmelCase    :				Optional[int]    =      (FlaxResNetModel, FlaxResNetForImageClassification) if is_flax_available() else ()
  
         __lowerCAmelCase    :				Tuple    =      False
         __lowerCAmelCase    :				str    =      False
         __lowerCAmelCase    :				int    =      False
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  int   				=					FlaxResNetModelTester(self  )
           _lowerCAmelCase       :  Any   				=					ConfigTester(self   ,   config_class=snake_case_   ,   has_text_modality=snake_case_  )
  
  
  
  
         def 							__UpperCamelCase       (     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 							__UpperCamelCase       (     self  ):
           return
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  List[Any]   				=					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*snake_case_  )
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  Any   				=					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_image_classification(*snake_case_  )
  
  
  
  
         @unittest.skip(reason="""ResNet does not use inputs_embeds"""  )
         def 							__UpperCamelCase       (     self  ):
           pass
  
  
  
  
         @unittest.skip(reason="""ResNet does not support input and output embeddings"""  )
         def 							__UpperCamelCase       (     self  ):
           pass
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase				,					_lowerCAmelCase       :  Union[str, Any]   				=					self.model_tester.prepare_config_and_inputs_for_common()
  
           for model_class in self.all_model_classes:
             _lowerCAmelCase       :  Any   				=					model_class(snake_case_  )
             _lowerCAmelCase       :  int   				=					inspect.signature(model.__call__  )
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             _lowerCAmelCase       :  Optional[int]   				=					[*signature.parameters.keys()]
  
             _lowerCAmelCase       :  Any   				=					["""pixel_values"""]
             self.assertListEqual(arg_names[:1]   ,   snake_case_  )
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           def check_hidden_states_output(snake_case_   ,   snake_case_   ,   snake_case_  ):
             _lowerCAmelCase       :  Any   				=					model_class(snake_case_  )
  
             _lowerCAmelCase       :  Dict   				=					model(**self._prepare_for_class(snake_case_   ,   snake_case_  )  )
  
             _lowerCAmelCase       :  Optional[int]   				=					outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states
  
             _lowerCAmelCase       :  str   				=					self.model_tester.num_stages
             self.assertEqual(len(snake_case_  )   ,   expected_num_stages + 1  )
  
  
  
  
         @unittest.skip(reason="""ResNet does not use feedforward chunking"""  )
         def 							__UpperCamelCase       (     self  ):
           pass
  
  
  
  
  
  
  
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase				,					_lowerCAmelCase       :  Optional[Any]   				=					self.model_tester.prepare_config_and_inputs_for_common()
  
           for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__  ):
               _lowerCAmelCase       :  Any   				=					self._prepare_for_class(snake_case_   ,   snake_case_  )
               _lowerCAmelCase       :  int   				=					model_class(snake_case_  )
  
               @jax.jit
               def model_jitted(snake_case_   ,   **snake_case_  ):
                 return model(pixel_values=snake_case_   ,   **snake_case_  )
  
               with self.subTest("""JIT Enabled"""  ):
                 _lowerCAmelCase       :  int   				=					model_jitted(**snake_case_  ).to_tuple()
  
               with self.subTest("""JIT Disabled"""  ):
                 with jax.disable_jit():
                   _lowerCAmelCase       :  Dict   				=					model_jitted(**snake_case_  ).to_tuple()
  
               self.assertEqual(len(snake_case_  )   ,   len(snake_case_  )  )
               for jitted_output, output in zip(snake_case_   ,   snake_case_  ):
                 self.assertEqual(jitted_output.shape   ,   output.shape  )
  
  
  
  def 	_UpperCAmelCase				(  )    ->						Union[str, Any]:
    _lowerCAmelCase       :  Tuple   				=					Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""		)
    return image
  
  
  
  @require_flax
  class   a_  (unittest.TestCase    ):
  
  
  
  
         @cached_property
         def 							__UpperCamelCase       (     self  ):
           return AutoImageProcessor.from_pretrained("""microsoft/resnet-50"""  ) if is_vision_available() else None
  
  
  
  
  
  
  
         @slow
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  int   				=					FlaxResNetForImageClassification.from_pretrained("""microsoft/resnet-50"""  )
  
           _lowerCAmelCase       :  List[str]   				=					self.default_image_processor
           _lowerCAmelCase       :  str   				=					prepare_img()
           _lowerCAmelCase       :  int   				=					image_processor(images=snake_case_   ,   return_tensors="""np"""  )
  
           _lowerCAmelCase       :  Union[str, Any]   				=					model(**snake_case_  )
  
           # verify the logits
           _lowerCAmelCase       :  int   				=					(1, 1_0_0_0)
           self.assertEqual(outputs.logits.shape   ,   snake_case_  )
  
           _lowerCAmelCase       :  str   				=					jnp.array([-11.1069, -9.7877, -8.3777]  )
  
           self.assertTrue(jnp.allclose(outputs.logits[0, :3]   ,   snake_case_   ,   atol=1E-4  )  )
  
  
  
style_context: 
  '''simple docstring'''
  
  from typing import TYPE_CHECKING
  
  from ...utils import (
      OptionalDependencyNotAvailable,
      _LazyModule,
      is_flax_available,
      is_tf_available,
      is_torch_available,
  )
  
  
  UpperCamelCase_     			=       {
      """configuration_gptsan_japanese""": ["""GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTSanJapaneseConfig"""],
      """tokenization_gptsan_japanese""": ["""GPTSanJapaneseTokenizer"""],
  }
  
  try:
       if not is_torch_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       UpperCamelCase_     			=       [
           """GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """GPTSanJapaneseForConditionalGeneration""",
           """GPTSanJapaneseModel""",
           """GPTSanJapanesePreTrainedModel""",
       ]
       UpperCamelCase_     			=       [
           """GPTSanJapaneseTokenizer""",
       ]
  
  
  if TYPE_CHECKING:
       from .configuration_gptsan_japanese import GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTSanJapaneseConfig
       from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer
  
       try:
            if not is_torch_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .modeling_gptsan_japanese import (
                GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
                GPTSanJapaneseForConditionalGeneration,
                GPTSanJapaneseModel,
                GPTSanJapanesePreTrainedModel,
            )
            from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer
  
  
  else:
       import sys
  
       UpperCamelCase_     			=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
  
  
  