code: def _decode_and_center_crop(
      image_bytes: tf.Tensor,
      jpeg_shape: Optional[tf.Tensor] = None,
  ) -> tf.Tensor:
      """Crops to center of image with padding then scales."""
      if jpeg_shape is None:
          jpeg_shape = tf.image.extract_jpeg_shape(image_bytes)
      image_height = jpeg_shape[0]
      image_width = jpeg_shape[1]
  
      padded_center_crop_size = tf.cast(
          (
              (224 / (224 + 32))
              * tf.cast(
                  tf.minimum(image_height, image_width), tf.float32
              )
          ),
          tf.int32,
      )
  
      offset_height = (
          (image_height - padded_center_crop_size) + 1
      ) // 2
      offset_width = ((image_width - padded_center_crop_size) + 1) // 2
      crop_window = tf.stack(
          [
              offset_height,
              offset_width,
              padded_center_crop_size,
              padded_center_crop_size,
          ]
      )
      image = tf.image.decode_and_crop_jpeg(
          image_bytes, crop_window, channels=3
      )
      return image
  
imports: from collections.abc import Iterable, Iterator, Mapping, Sequence
  import enum
  import itertools
  import types
  from typing import Optional
  import jax
  import jax.numpy
  import numpy
  from packaging import version
  import tensorflow.compat.v2
  import tensorflow_datasets
label_desc: Use image node_id 12 for calling a global function with example usage: _decode_and_center_crop(image_bytes, jpeg_shape) and returns: image