We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
keras.layers.CenterCrop raises AttributeError when passed a list of images
With tf.keras, the following code works, but not in Keras-Core:

```python
import keras_core as keras
import numpy as np

images = [
    np.random.rand(100, 100, 3),
    np.random.rand(100, 100, 3),
]
keras.layers.CenterCrop(height=60, width=50)(images)  #!!! AttributeError
```

Full stacktrace below:

<details>

```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[21], line 8
      2 import numpy as np
      4 images = [
      5     np.random.rand(100, 100, 3),
      6     np.random.rand(100, 100, 3),
      7 ]
----> 8 keras.layers.CenterCrop(height=60, width=50)(images)

File ~/opt/miniconda3/envs/kerascore/lib/python3.8/site-packages/keras_core/src/layers/preprocessing/tf_data_layer.py:36, in TFDataLayer.__call__(self, inputs, **kwargs)
     34             self._convert_input_args = True
     35     return outputs
---> 36 return super().__call__(inputs, **kwargs)

File ~/opt/miniconda3/envs/kerascore/lib/python3.8/site-packages/keras_core/src/utils/traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    119     filtered_tb = _process_traceback_frames(e.__traceback__)
    120     # To get the full stack trace, call:
    121     # `keras_core.config.disable_traceback_filtering()`
--> 122     raise e.with_traceback(filtered_tb) from None
    123 finally:
    124     del filtered_tb

File ~/opt/miniconda3/envs/kerascore/lib/python3.8/site-packages/keras_core/src/layers/preprocessing/center_crop.py:59, in CenterCrop.call(self, inputs)
     57     init_width = inputs.shape[-1]
     58 else:
---> 59     init_height = inputs.shape[-3]
     60     init_width = inputs.shape[-2]
     62 if init_height is None or init_width is None:
     63     # Dynamic size case. TODO.

AttributeError: Exception encountered when calling CenterCrop.call().

'list' object has no attribute 'shape'

Arguments received by CenterCrop.call():
  • inputs=['jnp.ndarray(shape=(100, 100, 3), dtype=float32)', 'jnp.ndarray(shape=(100, 100, 3), dtype=float32)']
```

</details>

A simple workaround is to stack the images:

```python
keras.layers.CenterCrop(height=60, width=50)(np.stack(images))
```

Not sure this can be considered a bug, but it's one of those little differences that may porting code from Keras 2.x to 3.0 a bit harder.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `keras_core/layers/preprocessing/center_crop.py`
Content:
```
1 from keras_core import backend
2 from keras_core.api_export import keras_core_export
3 from keras_core.layers.preprocessing.tf_data_layer import TFDataLayer
4 from keras_core.utils import image_utils
5 
6 
7 @keras_core_export("keras_core.layers.CenterCrop")
8 class CenterCrop(TFDataLayer):
9     """A preprocessing layer which crops images.
10 
11     This layers crops the central portion of the images to a target size. If an
12     image is smaller than the target size, it will be resized and cropped
13     so as to return the largest possible window in the image that matches
14     the target aspect ratio.
15 
16     Input pixel values can be of any range (e.g. `[0., 1.)` or `[0, 255]`).
17 
18     Input shape:
19         3D (unbatched) or 4D (batched) tensor with shape:
20         `(..., height, width, channels)`, in `"channels_last"` format,
21         or `(..., channels, height, width)`, in `"channels_first"` format.
22 
23     Output shape:
24         3D (unbatched) or 4D (batched) tensor with shape:
25         `(..., target_height, target_width, channels)`,
26         or `(..., channels, target_height, target_width)`,
27         in `"channels_first"` format.
28 
29     If the input height/width is even and the target height/width is odd (or
30     inversely), the input image is left-padded by 1 pixel.
31 
32     **Note:** This layer is safe to use inside a `tf.data` pipeline
33     (independently of which backend you're using).
34 
35     Args:
36         height: Integer, the height of the output shape.
37         width: Integer, the width of the output shape.
38         data_format: string, either `"channels_last"` or `"channels_first"`.
39             The ordering of the dimensions in the inputs. `"channels_last"`
40             corresponds to inputs with shape `(batch, height, width, channels)`
41             while `"channels_first"` corresponds to inputs with shape
42             `(batch, channels, height, width)`. It defaults to the
43             `image_data_format` value found in your Keras config file at
44             `~/.keras/keras.json`. If you never set it, then it will be
45             `"channels_last"`.
46     """
47 
48     def __init__(self, height, width, data_format=None, **kwargs):
49         super().__init__(**kwargs)
50         self.height = height
51         self.width = width
52         self.data_format = backend.standardize_data_format(data_format)
53 
54     def call(self, inputs):
55         if self.data_format == "channels_first":
56             init_height = inputs.shape[-2]
57             init_width = inputs.shape[-1]
58         else:
59             init_height = inputs.shape[-3]
60             init_width = inputs.shape[-2]
61 
62         if init_height is None or init_width is None:
63             # Dynamic size case. TODO.
64             raise ValueError(
65                 "At this time, CenterCrop can only "
66                 "process images with a static spatial "
67                 f"shape. Received: inputs.shape={inputs.shape}"
68             )
69 
70         h_diff = init_height - self.height
71         w_diff = init_width - self.width
72 
73         h_start = int(h_diff / 2)
74         w_start = int(w_diff / 2)
75 
76         if h_diff >= 0 and w_diff >= 0:
77             if len(inputs.shape) == 4:
78                 if self.data_format == "channels_first":
79                     return inputs[
80                         :,
81                         :,
82                         h_start : h_start + self.height,
83                         w_start : w_start + self.width,
84                     ]
85                 return inputs[
86                     :,
87                     h_start : h_start + self.height,
88                     w_start : w_start + self.width,
89                     :,
90                 ]
91             elif len(inputs.shape) == 3:
92                 if self.data_format == "channels_first":
93                     return inputs[
94                         :,
95                         h_start : h_start + self.height,
96                         w_start : w_start + self.width,
97                     ]
98                 return inputs[
99                     h_start : h_start + self.height,
100                     w_start : w_start + self.width,
101                     :,
102                 ]
103 
104         return image_utils.smart_resize(
105             inputs,
106             [self.height, self.width],
107             data_format=self.data_format,
108             backend_module=self.backend,
109         )
110 
111     def compute_output_shape(self, input_shape):
112         input_shape = list(input_shape)
113         if len(input_shape) == 4:
114             if self.data_format == "channels_last":
115                 input_shape[1] = self.height
116                 input_shape[2] = self.width
117             else:
118                 input_shape[2] = self.height
119                 input_shape[3] = self.width
120         else:
121             if self.data_format == "channels_last":
122                 input_shape[0] = self.height
123                 input_shape[1] = self.width
124             else:
125                 input_shape[1] = self.height
126                 input_shape[2] = self.width
127         return tuple(input_shape)
128 
129     def get_config(self):
130         base_config = super().get_config()
131         config = {
132             "height": self.height,
133             "width": self.width,
134             "data_format": self.data_format,
135         }
136         return {**base_config, **config}
137
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/keras_core/layers/preprocessing/center_crop.py b/keras_core/layers/preprocessing/center_crop.py
--- a/keras_core/layers/preprocessing/center_crop.py
+++ b/keras_core/layers/preprocessing/center_crop.py
@@ -52,6 +52,7 @@
         self.data_format = backend.standardize_data_format(data_format)
 
     def call(self, inputs):
+        inputs = self.backend.cast(inputs, self.compute_dtype)
         if self.data_format == "channels_first":
             init_height = inputs.shape[-2]
             init_width = inputs.shape[-1]

{"golden_diff": "diff --git a/keras_core/layers/preprocessing/center_crop.py b/keras_core/layers/preprocessing/center_crop.py\n--- a/keras_core/layers/preprocessing/center_crop.py\n+++ b/keras_core/layers/preprocessing/center_crop.py\n@@ -52,6 +52,7 @@\n         self.data_format = backend.standardize_data_format(data_format)\n \n     def call(self, inputs):\n+        inputs = self.backend.cast(inputs, self.compute_dtype)\n         if self.data_format == \"channels_first\":\n             init_height = inputs.shape[-2]\n             init_width = inputs.shape[-1]\n", "issue": "keras.layers.CenterCrop raises AttributeError when passed a list of images\nWith tf.keras, the following code works, but not in Keras-Core:\r\n\r\n```python\r\nimport keras_core as keras\r\nimport numpy as np\r\n\r\nimages = [\r\n    np.random.rand(100, 100, 3),\r\n    np.random.rand(100, 100, 3),\r\n]\r\nkeras.layers.CenterCrop(height=60, width=50)(images)  #!!! AttributeError\r\n```\r\n\r\nFull stacktrace below:\r\n\r\n<details>\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\nCell In[21], line 8\r\n      2 import numpy as np\r\n      4 images = [\r\n      5     np.random.rand(100, 100, 3),\r\n      6     np.random.rand(100, 100, 3),\r\n      7 ]\r\n----> 8 keras.layers.CenterCrop(height=60, width=50)(images)\r\n\r\nFile ~/opt/miniconda3/envs/kerascore/lib/python3.8/site-packages/keras_core/src/layers/preprocessing/tf_data_layer.py:36, in TFDataLayer.__call__(self, inputs, **kwargs)\r\n     34             self._convert_input_args = True\r\n     35     return outputs\r\n---> 36 return super().__call__(inputs, **kwargs)\r\n\r\nFile ~/opt/miniconda3/envs/kerascore/lib/python3.8/site-packages/keras_core/src/utils/traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)\r\n    119     filtered_tb = _process_traceback_frames(e.__traceback__)\r\n    120     # To get the full stack trace, call:\r\n    121     # `keras_core.config.disable_traceback_filtering()`\r\n--> 122     raise e.with_traceback(filtered_tb) from None\r\n    123 finally:\r\n    124     del filtered_tb\r\n\r\nFile ~/opt/miniconda3/envs/kerascore/lib/python3.8/site-packages/keras_core/src/layers/preprocessing/center_crop.py:59, in CenterCrop.call(self, inputs)\r\n     57     init_width = inputs.shape[-1]\r\n     58 else:\r\n---> 59     init_height = inputs.shape[-3]\r\n     60     init_width = inputs.shape[-2]\r\n     62 if init_height is None or init_width is None:\r\n     63     # Dynamic size case. TODO.\r\n\r\nAttributeError: Exception encountered when calling CenterCrop.call().\r\n\r\n'list' object has no attribute 'shape'\r\n\r\nArguments received by CenterCrop.call():\r\n  \u2022 inputs=['jnp.ndarray(shape=(100, 100, 3), dtype=float32)', 'jnp.ndarray(shape=(100, 100, 3), dtype=float32)']\r\n```\r\n\r\n</details>\r\n\r\nA simple workaround is to stack the images:\r\n\r\n```python\r\nkeras.layers.CenterCrop(height=60, width=50)(np.stack(images))\r\n```\r\n\r\nNot sure this can be considered a bug, but it's one of those little differences that may porting code from Keras 2.x to 3.0 a bit harder.\n", "before_files": [{"content": "from keras_core import backend\nfrom keras_core.api_export import keras_core_export\nfrom keras_core.layers.preprocessing.tf_data_layer import TFDataLayer\nfrom keras_core.utils import image_utils\n\n\n@keras_core_export(\"keras_core.layers.CenterCrop\")\nclass CenterCrop(TFDataLayer):\n    \"\"\"A preprocessing layer which crops images.\n\n    This layers crops the central portion of the images to a target size. If an\n    image is smaller than the target size, it will be resized and cropped\n    so as to return the largest possible window in the image that matches\n    the target aspect ratio.\n\n    Input pixel values can be of any range (e.g. `[0., 1.)` or `[0, 255]`).\n\n    Input shape:\n        3D (unbatched) or 4D (batched) tensor with shape:\n        `(..., height, width, channels)`, in `\"channels_last\"` format,\n        or `(..., channels, height, width)`, in `\"channels_first\"` format.\n\n    Output shape:\n        3D (unbatched) or 4D (batched) tensor with shape:\n        `(..., target_height, target_width, channels)`,\n        or `(..., channels, target_height, target_width)`,\n        in `\"channels_first\"` format.\n\n    If the input height/width is even and the target height/width is odd (or\n    inversely), the input image is left-padded by 1 pixel.\n\n    **Note:** This layer is safe to use inside a `tf.data` pipeline\n    (independently of which backend you're using).\n\n    Args:\n        height: Integer, the height of the output shape.\n        width: Integer, the width of the output shape.\n        data_format: string, either `\"channels_last\"` or `\"channels_first\"`.\n            The ordering of the dimensions in the inputs. `\"channels_last\"`\n            corresponds to inputs with shape `(batch, height, width, channels)`\n            while `\"channels_first\"` corresponds to inputs with shape\n            `(batch, channels, height, width)`. It defaults to the\n            `image_data_format` value found in your Keras config file at\n            `~/.keras/keras.json`. If you never set it, then it will be\n            `\"channels_last\"`.\n    \"\"\"\n\n    def __init__(self, height, width, data_format=None, **kwargs):\n        super().__init__(**kwargs)\n        self.height = height\n        self.width = width\n        self.data_format = backend.standardize_data_format(data_format)\n\n    def call(self, inputs):\n        if self.data_format == \"channels_first\":\n            init_height = inputs.shape[-2]\n            init_width = inputs.shape[-1]\n        else:\n            init_height = inputs.shape[-3]\n            init_width = inputs.shape[-2]\n\n        if init_height is None or init_width is None:\n            # Dynamic size case. TODO.\n            raise ValueError(\n                \"At this time, CenterCrop can only \"\n                \"process images with a static spatial \"\n                f\"shape. Received: inputs.shape={inputs.shape}\"\n            )\n\n        h_diff = init_height - self.height\n        w_diff = init_width - self.width\n\n        h_start = int(h_diff / 2)\n        w_start = int(w_diff / 2)\n\n        if h_diff >= 0 and w_diff >= 0:\n            if len(inputs.shape) == 4:\n                if self.data_format == \"channels_first\":\n                    return inputs[\n                        :,\n                        :,\n                        h_start : h_start + self.height,\n                        w_start : w_start + self.width,\n                    ]\n                return inputs[\n                    :,\n                    h_start : h_start + self.height,\n                    w_start : w_start + self.width,\n                    :,\n                ]\n            elif len(inputs.shape) == 3:\n                if self.data_format == \"channels_first\":\n                    return inputs[\n                        :,\n                        h_start : h_start + self.height,\n                        w_start : w_start + self.width,\n                    ]\n                return inputs[\n                    h_start : h_start + self.height,\n                    w_start : w_start + self.width,\n                    :,\n                ]\n\n        return image_utils.smart_resize(\n            inputs,\n            [self.height, self.width],\n            data_format=self.data_format,\n            backend_module=self.backend,\n        )\n\n    def compute_output_shape(self, input_shape):\n        input_shape = list(input_shape)\n        if len(input_shape) == 4:\n            if self.data_format == \"channels_last\":\n                input_shape[1] = self.height\n                input_shape[2] = self.width\n            else:\n                input_shape[2] = self.height\n                input_shape[3] = self.width\n        else:\n            if self.data_format == \"channels_last\":\n                input_shape[0] = self.height\n                input_shape[1] = self.width\n            else:\n                input_shape[1] = self.height\n                input_shape[2] = self.width\n        return tuple(input_shape)\n\n    def get_config(self):\n        base_config = super().get_config()\n        config = {\n            \"height\": self.height,\n            \"width\": self.width,\n            \"data_format\": self.data_format,\n        }\n        return {**base_config, **config}\n", "path": "keras_core/layers/preprocessing/center_crop.py"}], "after_files": [{"content": "from keras_core import backend\nfrom keras_core.api_export import keras_core_export\nfrom keras_core.layers.preprocessing.tf_data_layer import TFDataLayer\nfrom keras_core.utils import image_utils\n\n\n@keras_core_export(\"keras_core.layers.CenterCrop\")\nclass CenterCrop(TFDataLayer):\n    \"\"\"A preprocessing layer which crops images.\n\n    This layers crops the central portion of the images to a target size. If an\n    image is smaller than the target size, it will be resized and cropped\n    so as to return the largest possible window in the image that matches\n    the target aspect ratio.\n\n    Input pixel values can be of any range (e.g. `[0., 1.)` or `[0, 255]`).\n\n    Input shape:\n        3D (unbatched) or 4D (batched) tensor with shape:\n        `(..., height, width, channels)`, in `\"channels_last\"` format,\n        or `(..., channels, height, width)`, in `\"channels_first\"` format.\n\n    Output shape:\n        3D (unbatched) or 4D (batched) tensor with shape:\n        `(..., target_height, target_width, channels)`,\n        or `(..., channels, target_height, target_width)`,\n        in `\"channels_first\"` format.\n\n    If the input height/width is even and the target height/width is odd (or\n    inversely), the input image is left-padded by 1 pixel.\n\n    **Note:** This layer is safe to use inside a `tf.data` pipeline\n    (independently of which backend you're using).\n\n    Args:\n        height: Integer, the height of the output shape.\n        width: Integer, the width of the output shape.\n        data_format: string, either `\"channels_last\"` or `\"channels_first\"`.\n            The ordering of the dimensions in the inputs. `\"channels_last\"`\n            corresponds to inputs with shape `(batch, height, width, channels)`\n            while `\"channels_first\"` corresponds to inputs with shape\n            `(batch, channels, height, width)`. It defaults to the\n            `image_data_format` value found in your Keras config file at\n            `~/.keras/keras.json`. If you never set it, then it will be\n            `\"channels_last\"`.\n    \"\"\"\n\n    def __init__(self, height, width, data_format=None, **kwargs):\n        super().__init__(**kwargs)\n        self.height = height\n        self.width = width\n        self.data_format = backend.standardize_data_format(data_format)\n\n    def call(self, inputs):\n        inputs = self.backend.cast(inputs, self.compute_dtype)\n        if self.data_format == \"channels_first\":\n            init_height = inputs.shape[-2]\n            init_width = inputs.shape[-1]\n        else:\n            init_height = inputs.shape[-3]\n            init_width = inputs.shape[-2]\n\n        if init_height is None or init_width is None:\n            # Dynamic size case. TODO.\n            raise ValueError(\n                \"At this time, CenterCrop can only \"\n                \"process images with a static spatial \"\n                f\"shape. Received: inputs.shape={inputs.shape}\"\n            )\n\n        h_diff = init_height - self.height\n        w_diff = init_width - self.width\n\n        h_start = int(h_diff / 2)\n        w_start = int(w_diff / 2)\n\n        if h_diff >= 0 and w_diff >= 0:\n            if len(inputs.shape) == 4:\n                if self.data_format == \"channels_first\":\n                    return inputs[\n                        :,\n                        :,\n                        h_start : h_start + self.height,\n                        w_start : w_start + self.width,\n                    ]\n                return inputs[\n                    :,\n                    h_start : h_start + self.height,\n                    w_start : w_start + self.width,\n                    :,\n                ]\n            elif len(inputs.shape) == 3:\n                if self.data_format == \"channels_first\":\n                    return inputs[\n                        :,\n                        h_start : h_start + self.height,\n                        w_start : w_start + self.width,\n                    ]\n                return inputs[\n                    h_start : h_start + self.height,\n                    w_start : w_start + self.width,\n                    :,\n                ]\n\n        return image_utils.smart_resize(\n            inputs,\n            [self.height, self.width],\n            data_format=self.data_format,\n            backend_module=self.backend,\n        )\n\n    def compute_output_shape(self, input_shape):\n        input_shape = list(input_shape)\n        if len(input_shape) == 4:\n            if self.data_format == \"channels_last\":\n                input_shape[1] = self.height\n                input_shape[2] = self.width\n            else:\n                input_shape[2] = self.height\n                input_shape[3] = self.width\n        else:\n            if self.data_format == \"channels_last\":\n                input_shape[0] = self.height\n                input_shape[1] = self.width\n            else:\n                input_shape[1] = self.height\n                input_shape[2] = self.width\n        return tuple(input_shape)\n\n    def get_config(self):\n        base_config = super().get_config()\n        config = {\n            \"height\": self.height,\n            \"width\": self.width,\n            \"data_format\": self.data_format,\n        }\n        return {**base_config, **config}\n", "path": "keras_core/layers/preprocessing/center_crop.py"}]}