code: def _pad_images(
      images,
      top_padding,
      bottom_padding,
      left_padding,
      right_padding,
      target_height,
      target_width,
  ):
      images = backend.convert_to_tensor(images)
      is_batch = True
      images_shape = ops.shape(images)
      if len(images_shape) == 3:
          is_batch = False
          images = backend.numpy.expand_dims(images, 0)
      elif len(images_shape) != 4:
          raise ValueError(
              f"Invalid shape for argument `images`: "
              "it must have rank 3 or 4. "
              f"Received: images.shape={images_shape}"
          )
  
      batch, height, width, depth = ops.shape(images)
  
      if [top_padding, bottom_padding, target_height].count(None) != 1:
          raise ValueError(
              "Must specify exactly two of "
              "top_padding, bottom_padding, target_height. "
              f"Received: top_padding={top_padding}, "
              f"bottom_padding={bottom_padding}, "
              f"target_height={target_height}"
          )
      if [left_padding, right_padding, target_width].count(None) != 1:
          raise ValueError(
              "Must specify exactly two of "
              "left_padding, right_padding, target_width. "
              f"Received: left_padding={left_padding}, "
              f"right_padding={right_padding}, "
              f"target_width={target_width}"
          )
  
      if top_padding is None:
          top_padding = target_height - bottom_padding - height
      if bottom_padding is None:
          bottom_padding = target_height - top_padding - height
      if left_padding is None:
          left_padding = target_width - right_padding - width
      if right_padding is None:
          right_padding = target_width - left_padding - width
  
      if top_padding < 0:
          raise ValueError(
              "top_padding must be >= 0. "
              f"Received: top_padding={top_padding}"
          )
      if left_padding < 0:
          raise ValueError(
              "left_padding must be >= 0. "
              f"Received: left_padding={left_padding}"
          )
      if right_padding < 0:
          raise ValueError(
              "right_padding must be >= 0. "
              f"Received: right_padding={right_padding}"
          )
      if bottom_padding < 0:
          raise ValueError(
              "bottom_padding must be >= 0. "
              f"Received: bottom_padding={bottom_padding}"
          )
  
      paddings = backend.numpy.reshape(
          backend.numpy.stack(
              [
                  0,
                  0,
                  top_padding,
                  bottom_padding,
                  left_padding,
                  right_padding,
                  0,
                  0,
              ]
          ),
          [4, 2],
      )
      padded = backend.numpy.pad(images, paddings)
  
      if target_height is None:
          target_height = top_padding + height + bottom_padding
      if target_width is None:
          target_width = left_padding + width + right_padding
      padded_shape = [batch, target_height, target_width, depth]
      padded = backend.numpy.reshape(padded, padded_shape)
  
      if not is_batch:
          padded = backend.numpy.squeeze(padded, axis=[0])
      return padded
  
imports: from keras import backend
  from keras import ops
  from keras.api_export import keras_export
  from keras.backend import KerasTensor
  from keras.backend import any_symbolic_tensors
  from keras.ops.operation import Operation
  from keras.ops.operation_utils import compute_conv_output_shape
label_desc: Use image node_id 6 for calling a global function with example usage: _pad_images(images, top_padding, bottom_padding, left_padding, right_padding, target_height, target_width) and returns: padded