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(
          (
              (IMAGE_SIZE / (IMAGE_SIZE + IMAGE_PADDING_FOR_CROP))
              * 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
  
file_path: objax/examples/image_classification/imagenet_resnet50_data.py
imports: import enum
  from typing import Optional, Sequence, Tuple
  import jax
  import numpy
  import tensorflow.compat.v2
  import tensorflow_datasets
label_desc: Use image node_id 9 for calling a global function with example usage: _decode_and_center_crop(image_bytes, jpeg_shape) and returns: image