docstr: Resize the image to a maximum height of `self.height` and maximum
  width of `self.width` while maintaining the aspect ratio. Pad the
  resized image to a fixed size of ``[self.height, self.width]``.
docstr_tok: ["Resize","the","image","to","a","maximum","height","of","`","self.height","`","and","maximum","width","of","`","self.width","`","while","maintaining","the","aspect","ratio",".","Pad","the","resized","image","to","a","fixed","size","of","``","[","self.height",",","self.width","]","``","."]
code: def _prepare_image(self, image):
      """Resize the image to a maximum height of `self.height` and maximum
      width of `self.width` while maintaining the aspect ratio. Pad the
      resized image to a fixed size of ``[self.height, self.width]``."""
      img = tf.image.decode_png(image, channels=self.channels)
      dims = tf.shape(img)
      width = self.max_width
  
      max_width = tf.cast(
          tf.math.ceil(
              tf.truediv(dims[1], dims[0]) * self.height_float
          ),
          dtype=tf.int32,
      )
      max_height = tf.cast(
          tf.math.ceil(
              tf.truediv(width, max_width) * self.height_float
          ),
          dtype=tf.int32,
      )
  
      resized = tf.cond(
          tf.greater_equal(width, max_width),
          lambda: tf.cond(
              tf.less_equal(dims[0], self.height),
              lambda: tf.cast(img, dtype=tf.float32),
              lambda: tf.image.resize(
                  img,
                  [self.height, max_width],
                  method=tf.image.ResizeMethod.BICUBIC,
              ),
          ),
          lambda: tf.image.resize(
              img,
              [max_height, width],
              method=tf.image.ResizeMethod.BICUBIC,
          ),
      )
  
      padded = tf.image.pad_to_bounding_box(
          resized, 0, 0, self.height, width
      )
      return padded
  
imports: from __future__ import absolute_import
  from __future__ import division
  import time
  import os
  import math
  import logging
  import sys
  import distance
  import numpy
  import tensorflow
  from six.moves import xrange
  from .cnn import CNN
  from .seq2seq_model import Seq2SeqModel
  from ..util.data_gen import DataGen
  from ..util.visualizations import visualize_attention
label_desc: Use image node_id 6 for calling the Model obj's underlying member method code with example usage: obj._prepare_image(image) and returns: padded