code: def extract_conv2d_patches(
      X: Tensor, kernel_shape, strides, rates, padding
  ) -> Tensor:
      """Extracts conv2d patches like TF function extract_image_patches.
  
      :param x: Input image.
      :param kernel_shape: Shape of the Keras conv2d kernel.
      :param strides: Strides of the Keras conv2d layer.
      :param rates: Dilation rates of the Keras conv2d layer.
      :param padding: Paddings of the Keras conv2d layer.
      :return: The extracted patches.
      """
      if kbackend.image_data_format() == "channels_first":
          X = kbackend.permute_dimensions(X, (0, 2, 3, 1))
      kernel_shape = [1, kernel_shape[0], kernel_shape[1], 1]
      strides = [1, strides[0], strides[1], 1]
      rates = [1, rates[0], rates[1], 1]
      ret = tf.compat.v1.extract_image_patches(
          X, kernel_shape, strides, rates, padding.upper()
      )
  
      if kbackend.image_data_format() == "channels_first":
          # TODO: check if we need to permute again.xs
          pass
      return ret
  
imports: from __future__ import annotations
  from typing import TypeVar
  import numpy
  import tensorflow
  import tensorflow.keras.backend
  from innvestigate.backend.types import Layer, OptionalList, ShapeTuple, Tensor
label_desc: Use image node_id 15 for calling a global function with example usage: extract_conv2d_patches(X, kernel_shape, strides, rates, padding) and returns: ret