code: 
  
  
  
  
  
  import inspect
  import unittest
  
  from transformers import EfficientNetConfig
  from transformers.testing_utils import is_pipeline_test, require_torch, require_vision, slow, torch_device
  from transformers.utils import cached_property, is_torch_available, is_vision_available
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_torch_available():
     import torch
  
     from transformers import EfficientNetForImageClassification, EfficientNetModel
     from transformers.models.efficientnet.modeling_efficientnet import EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST
  
  
  if is_vision_available():
     from PIL import Image
  
     from transformers import AutoImageProcessor
  
  class 				A    :
  
  
  
        def __init__(					self     ,  lowercase_     ,  lowercase_=13     ,  lowercase_=32     ,  lowercase_=3     ,  lowercase_=[3, 3, 5]     ,  lowercase_=[32, 16, 24]     ,  lowercase_=[16, 24, 40]     ,  lowercase_=[1, 1, 2]     ,  lowercase_=[1, 1, 2]     ,  lowercase_=[1, 6, 6]     ,  lowercase_=True     ,  lowercase_=True     ,  lowercase_=37     ,  lowercase_="gelu"     ,  lowercase_=10     ,  )      ->   List[Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[Any]     				=						parent
               _snake_case      :							Optional[int]     				=						batch_size
               _snake_case      :							List[Any]     				=						image_size
               _snake_case      :							Optional[int]     				=						num_channels
               _snake_case      :							Optional[Any]     				=						kernel_sizes
               _snake_case      :							List[str]     				=						in_channels
               _snake_case      :							Optional[Any]     				=						out_channels
               _snake_case      :							Any     				=						strides
               _snake_case      :							int     				=						num_block_repeats
               _snake_case      :							Dict     				=						expand_ratios
               _snake_case      :							Optional[int]     				=						is_training
               _snake_case      :							Optional[int]     				=						hidden_act
               _snake_case      :							int     				=						num_labels
               _snake_case      :							Tuple     				=						use_labels
  
  
  
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Any     				=						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)
  
               _snake_case      :							Optional[Any]     				=						None
               if self.use_labels:
                      _snake_case      :							Optional[Any]     				=						ids_tensor([self.batch_size]     ,  self.num_labels					)
  
               _snake_case      :							Optional[Any]     				=						self.get_config()
               return config, pixel_values, labels
  
  
  
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               return EfficientNetConfig(
                   num_channels=self.num_channels     ,  kernel_sizes=self.kernel_sizes     ,  in_channels=self.in_channels     ,  out_channels=self.out_channels     ,  strides=self.strides     ,  num_block_repeats=self.num_block_repeats     ,  expand_ratios=self.expand_ratios     ,  hidden_act=self.hidden_act     ,  num_labels=self.num_labels     ,  )
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_     ,  lowercase_					)      ->   int:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Union[str, Any]     				=						EfficientNetModel(config=lowercase_					)
               model.to(lowercase_					)
               model.eval()
               _snake_case      :							List[str]     				=						model(lowercase_					)
               # expected last hidden states: B, C, H // 4, W // 4
               self.parent.assertEqual(
                   result.last_hidden_state.shape     ,  (self.batch_size, config.hidden_dim, self.image_size // 4, self.image_size // 4)     ,  )
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_     ,  lowercase_					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Optional[int]     				=						EfficientNetForImageClassification(lowercase_					)
               model.to(lowercase_					)
               model.eval()
               _snake_case      :							Any     				=						model(lowercase_     ,  labels=lowercase_					)
               self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.num_labels)					)
  
  
  
        def    __a (					self					)      ->   int:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[str]     				=						self.prepare_config_and_inputs()
               _snake_case				,    _snake_case				,    _snake_case      :							int     				=						config_and_inputs
               _snake_case      :							Union[str, Any]     				=						{'''pixel_values''': pixel_values}
               return config, inputs_dict
  
  
  @require_torch
  class 				A    (__UpperCAmelCase       ,__UpperCAmelCase       ,unittest.TestCase				):
        _SCREAMING_SNAKE_CASE					=							(EfficientNetModel, EfficientNetForImageClassification) if is_torch_available() else ()
        _SCREAMING_SNAKE_CASE					=							(
            {"""feature-extraction""": EfficientNetModel, """image-classification""": EfficientNetForImageClassification}
            if is_torch_available()
            else {}
        )
  
        _SCREAMING_SNAKE_CASE					=							False
        _SCREAMING_SNAKE_CASE					=							False
        _SCREAMING_SNAKE_CASE					=							False
        _SCREAMING_SNAKE_CASE					=							False
        _SCREAMING_SNAKE_CASE					=							False
  
  
  
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Optional[int]     				=						EfficientNetModelTester(self					)
               _snake_case      :							List[str]     				=						ConfigTester(
                   self     ,  config_class=lowercase_     ,  has_text_modality=lowercase_     ,  hidden_size=37					)
  
  
  
        def    __a (					self					)      ->   Any:
  
  
  
               '''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    __a (					self					)      ->   Optional[Any]:
  
  
  
               '''simple docstring'''
  
               return
  
  
  
        @unittest.skip(reason='''EfficientNet does not use inputs_embeds'''					)
        def    __a (					self					)      ->   List[str]:
  
  
  
               '''simple docstring'''
  
               pass
  
  
  
        @unittest.skip(reason='''EfficientNet does not support input and output embeddings'''					)
        def    __a (					self					)      ->   List[Any]:
  
  
  
               '''simple docstring'''
  
               pass
  
  
  
        @unittest.skip(reason='''EfficientNet does not use feedforward chunking'''					)
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               pass
  
  
  
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               _snake_case				,    _snake_case      :							str     				=						self.model_tester.prepare_config_and_inputs_for_common()
  
               for model_class in self.all_model_classes:
                      _snake_case      :							Optional[int]     				=						model_class(lowercase_					)
                      _snake_case      :							Tuple     				=						inspect.signature(model.forward					)
                      # signature.parameters is an OrderedDict => so arg_names order is deterministic
                      _snake_case      :							List[Any]     				=						[*signature.parameters.keys()]
  
                      _snake_case      :							List[str]     				=						['''pixel_values''']
                      self.assertListEqual(arg_names[:1]     ,  lowercase_					)
  
  
  
        def    __a (					self					)      ->   Union[str, Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[Any]     				=						self.model_tester.prepare_config_and_inputs()
               self.model_tester.create_and_check_model(*lowercase_					)
  
  
  
        def    __a (					self					)      ->   Tuple:
  
  
  
               '''simple docstring'''
  
               def check_hidden_states_output(lowercase_     ,  lowercase_     ,  lowercase_					):
                      _snake_case      :							Tuple     				=						model_class(lowercase_					)
                      model.to(lowercase_					)
                      model.eval()
  
                      with torch.no_grad():
                             _snake_case      :							Tuple     				=						model(**self._prepare_for_class(lowercase_     ,  lowercase_					)					)
  
                      _snake_case      :							List[Any]     				=						outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states
                      _snake_case      :							str     				=						sum(config.num_block_repeats					) * 4
                      self.assertEqual(len(lowercase_					)     ,  lowercase_					)
  
                      # EfficientNet's feature maps are of shape (batch_size, num_channels, height, width)
                      self.assertListEqual(
                          list(hidden_states[0].shape[-2:]					)     ,  [self.model_tester.image_size // 2, self.model_tester.image_size // 2]     ,  )
  
               _snake_case				,    _snake_case      :							Tuple     				=						self.model_tester.prepare_config_and_inputs_for_common()
  
               for model_class in self.all_model_classes:
                      _snake_case      :							Dict     				=						True
                      check_hidden_states_output(lowercase_     ,  lowercase_     ,  lowercase_					)
  
                      # check that output_hidden_states also work using config
                      del inputs_dict["output_hidden_states"]
                      _snake_case      :							Union[str, Any]     				=						True
  
                      check_hidden_states_output(lowercase_     ,  lowercase_     ,  lowercase_					)
  
  
  
        def    __a (					self					)      ->   List[str]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Union[str, Any]     				=						self.model_tester.prepare_config_and_inputs()
               self.model_tester.create_and_check_for_image_classification(*lowercase_					)
  
  
  
        @unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''					)
        def    __a (					self					)      ->   str:
  
  
  
               '''simple docstring'''
  
               pass
  
  
  
        @slow
        def    __a (					self					)      ->   Optional[Any]:
  
  
  
               '''simple docstring'''
  
               for model_name in EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                      _snake_case      :							Tuple     				=						EfficientNetModel.from_pretrained(lowercase_					)
                      self.assertIsNotNone(lowercase_					)
  
  
  
        @is_pipeline_test
        @require_vision
        @slow
        def    __a (					self					)      ->   int:
  
  
  
               '''simple docstring'''
  
               super().test_pipeline_image_classification()
  
  
  
  
  def 						A_			(  )			->						Optional[Any]:
         _snake_case      :							Dict     				=						Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''  )
         return image
  
  @require_torch
  @require_vision
  class 				A    (unittest.TestCase				):
  
  
  
        @cached_property
        def    __a (					self					)      ->   Tuple:
  
  
  
               '''simple docstring'''
  
               return AutoImageProcessor.from_pretrained('''google/efficientnet-b7'''					) if is_vision_available() else None
  
  
  
        @slow
        def    __a (					self					)      ->   Any:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Optional[Any]     				=						EfficientNetForImageClassification.from_pretrained('''google/efficientnet-b7'''					).to(lowercase_					)
  
               _snake_case      :							List[Any]     				=						self.default_image_processor
               _snake_case      :							List[Any]     				=						prepare_img()
               _snake_case      :							List[str]     				=						image_processor(images=lowercase_     ,  return_tensors='''pt'''					).to(lowercase_					)
  
               # forward pass
               with torch.no_grad():
                      _snake_case      :							int     				=						model(**lowercase_					)
  
               # verify the logits
               _snake_case      :							Optional[Any]     				=						torch.Size((1, 1000)					)
               self.assertEqual(outputs.logits.shape     ,  lowercase_					)
  
               _snake_case      :							str     				=						torch.tensor([0.0001, 0.0002, 0.0002]					).to(lowercase_					)
               self.assertTrue(torch.allclose(outputs.logits[0, :3]     ,  lowercase_     ,  atol=1E-4					)					)
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  import numpy as np
  
  
  
  
  def 						A_			(  lowercase_  )			->						Optional[Any]:
         _snake_case      :							Union[str, Any]     				=						np.exp(lowercase_  )
  
         # Add up the all the exponentials
         _snake_case      :							List[str]     				=						np.sum(lowercase_  )
  
         # Divide every exponent by the sum of all exponents
         _snake_case      :							Optional[int]     				=						exponent_vector / sum_of_exponents
  
         return softmax_vector
  
  
  if __name__ == "__main__":
     print(softmax((0,)))
  
  
  
  
  
  
  