code: def _aspect_preserving_resize(image, smallest_side):
      """Resize images preserving the original aspect ratio.
  
      Args:
        image: A 3-D image `Tensor`.
        smallest_side: A python integer or scalar `Tensor` indicating the size of
        the smallest side after resize.
  
      Returns:
        resized_image: A 3-D tensor containing the resized image.
      """
      smallest_side = tf.convert_to_tensor(
          smallest_side, dtype=tf.int32
      )
  
      shape = tf.shape(image)
      height = shape[0]
      width = shape[1]
      new_height, new_width = _smallest_size_at_least(
          height, width, smallest_side
      )
      image = tf.expand_dims(image, 0)
      resized_image = tf.image.resize_images(
          image,
          size=[new_height, new_width],
          method=tf.image.ResizeMethod.BICUBIC,
      )
  
      resized_image = tf.squeeze(resized_image)
      resized_image.set_shape([None, None, 3])
      return resized_image
  
file_path: tensor2tensor/tensor2tensor/data_generators/vqa_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.python.ops import control_flow_ops
label_desc: Use image node_id 2 for calling a global function with example usage: _aspect_preserving_resize(image, smallest_side) and returns: resized_image