code: def test_preprocess_input(self):
      # Test invalid mode check
      x = np.random.uniform(0, 255, (10, 10, 3))
      with self.assertRaises(ValueError):
          utils.preprocess_input(x, mode="some_unknown_mode")
  
      # Test image batch with float and int image input
      x = np.random.uniform(0, 255, (2, 10, 10, 3))
      xint = x.astype("int32")
      self.assertEqual(utils.preprocess_input(x).shape, x.shape)
      self.assertEqual(utils.preprocess_input(xint).shape, xint.shape)
  
      out1 = utils.preprocess_input(x, "channels_last")
      out1int = utils.preprocess_input(xint, "channels_last")
      out2 = utils.preprocess_input(
          np.transpose(x, (0, 3, 1, 2)), "channels_first"
      )
      out2int = utils.preprocess_input(
          np.transpose(xint, (0, 3, 1, 2)), "channels_first"
      )
      self.assertAllClose(out1, out2.transpose(0, 2, 3, 1))
      self.assertAllClose(out1int, out2int.transpose(0, 2, 3, 1))
  
      # Test single image
      x = np.random.uniform(0, 255, (10, 10, 3))
      xint = x.astype("int32")
      self.assertEqual(utils.preprocess_input(x).shape, x.shape)
      self.assertEqual(utils.preprocess_input(xint).shape, xint.shape)
  
      out1 = utils.preprocess_input(x, "channels_last")
      out1int = utils.preprocess_input(xint, "channels_last")
      out2 = utils.preprocess_input(
          np.transpose(x, (2, 0, 1)), "channels_first"
      )
      out2int = utils.preprocess_input(
          np.transpose(xint, (2, 0, 1)), "channels_first"
      )
      self.assertAllClose(out1, out2.transpose(1, 2, 0))
      self.assertAllClose(out1int, out2int.transpose(1, 2, 0))
  
      # Test that writing over the input data works predictably
      for mode in ["torch", "tf"]:
          x = np.random.uniform(0, 255, (2, 10, 10, 3))
          xint = x.astype("int")
          x2 = utils.preprocess_input(x, "channels_last", mode=mode)
          xint2 = utils.preprocess_input(xint, "channels_last")
          self.assertAllClose(x, x2)
          self.assertNotEqual(xint.astype("float").max(), xint2.max())
  
      # Caffe mode works differently from the others
      x = np.random.uniform(0, 255, (2, 10, 10, 3))
      xint = x.astype("int")
      x2 = utils.preprocess_input(
          x, data_format="channels_last", mode="caffe"
      )
      xint2 = utils.preprocess_input(xint, data_format="channels_last")
      self.assertAllClose(x, x2[..., ::-1])
      self.assertNotEqual(xint.astype("float").max(), xint2.max())
  
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 1 for calling the TestImageNetUtils obj's underlying member method code with example usage: obj.test_preprocess_input() without return types