code: def test_obtain_input_shape(self, data_format):
      # input_shape and default_size are not identical.
      with self.assertRaises(ValueError):
          utils.obtain_input_shape(
              input_shape=(224, 224, 3),
              default_size=299,
              min_size=139,
              data_format="channels_last",
              require_flatten=True,
              weights="imagenet",
          )
  
      # Test invalid use cases
  
      shape = (139, 139)
      if data_format == "channels_last":
          input_shape = shape + (99,)
      else:
          input_shape = (99,) + shape
  
      # input_shape is smaller than min_size.
      shape = (100, 100)
      if data_format == "channels_last":
          input_shape = shape + (3,)
      else:
          input_shape = (3,) + shape
      with self.assertRaises(ValueError):
          utils.obtain_input_shape(
              input_shape=input_shape,
              default_size=None,
              min_size=139,
              data_format=data_format,
              require_flatten=False,
          )
  
      # shape is 1D.
      shape = (100,)
      if data_format == "channels_last":
          input_shape = shape + (3,)
      else:
          input_shape = (3,) + shape
      with self.assertRaises(ValueError):
          utils.obtain_input_shape(
              input_shape=input_shape,
              default_size=None,
              min_size=139,
              data_format=data_format,
              require_flatten=False,
          )
  
      # the number of channels is 5 not 3.
      shape = (100, 100)
      if data_format == "channels_last":
          input_shape = shape + (5,)
      else:
          input_shape = (5,) + shape
      with self.assertRaises(ValueError):
          utils.obtain_input_shape(
              input_shape=input_shape,
              default_size=None,
              min_size=139,
              data_format=data_format,
              require_flatten=False,
          )
  
      # require_flatten=True with dynamic input shape.
      with self.assertRaises(ValueError):
          utils.obtain_input_shape(
              input_shape=None,
              default_size=None,
              min_size=139,
              data_format="channels_first",
              require_flatten=True,
          )
  
      # test include top
      self.assertEqual(
          utils.obtain_input_shape(
              input_shape=(3, 200, 200),
              default_size=None,
              min_size=139,
              data_format="channels_first",
              require_flatten=True,
          ),
          (3, 200, 200),
      )
  
      self.assertEqual(
          utils.obtain_input_shape(
              input_shape=None,
              default_size=None,
              min_size=139,
              data_format="channels_last",
              require_flatten=False,
          ),
          (None, None, 3),
      )
  
      self.assertEqual(
          utils.obtain_input_shape(
              input_shape=None,
              default_size=None,
              min_size=139,
              data_format="channels_first",
              require_flatten=False,
          ),
          (3, None, None),
      )
  
      self.assertEqual(
          utils.obtain_input_shape(
              input_shape=None,
              default_size=None,
              min_size=139,
              data_format="channels_last",
              require_flatten=False,
          ),
          (None, None, 3),
      )
  
      self.assertEqual(
          utils.obtain_input_shape(
              input_shape=(150, 150, 3),
              default_size=None,
              min_size=139,
              data_format="channels_last",
              require_flatten=False,
          ),
          (150, 150, 3),
      )
  
      self.assertEqual(
          utils.obtain_input_shape(
              input_shape=(3, None, None),
              default_size=None,
              min_size=139,
              data_format="channels_first",
              require_flatten=False,
          ),
          (3, None, None),
      )
  
file_path: keras/keras/applications/imagenet_utils_test.py
imports: import numpy
  import pytest
  from absl.testing import parameterized
  import keras
  from keras import backend
  from keras import testing
  from keras.applications import imagenet_utils
  from keras.mixed_precision import set_dtype_policy
label_desc: Use image node_id 4 for calling the TestImageNetUtils obj's underlying member method code with example usage: obj.test_obtain_input_shape(data_format) without return types