code: def _compute_new_dynamic_size(image, min_dimension, max_dimension):
      """Compute new dynamic shape for resize_to_range method."""
      image_shape = tf.shape(image)
      orig_height = tf.to_float(image_shape[0])
      orig_width = tf.to_float(image_shape[1])
      num_channels = image_shape[2]
      orig_min_dim = tf.minimum(orig_height, orig_width)
      # Calculates the larger of the possible sizes
      min_dimension = tf.constant(min_dimension, dtype=tf.float32)
      large_scale_factor = min_dimension / orig_min_dim
      # Scaling orig_(height|width) by large_scale_factor will make the smaller
      # dimension equal to min_dimension, save for floating point rounding errors.
      # For reasonably-sized images, taking the nearest integer will reliably
      # eliminate this error.
      large_height = tf.to_int32(
          tf.round(orig_height * large_scale_factor)
      )
      large_width = tf.to_int32(
          tf.round(orig_width * large_scale_factor)
      )
      large_size = tf.stack([large_height, large_width])
      if max_dimension:
          # Calculates the smaller of the possible sizes, use that if the larger
          # is too big.
          orig_max_dim = tf.maximum(orig_height, orig_width)
          max_dimension = tf.constant(max_dimension, dtype=tf.float32)
          small_scale_factor = max_dimension / orig_max_dim
          # Scaling orig_(height|width) by small_scale_factor will make the larger
          # dimension equal to max_dimension, save for floating point rounding
          # errors. For reasonably-sized images, taking the nearest integer will
          # reliably eliminate this error.
          small_height = tf.to_int32(
              tf.round(orig_height * small_scale_factor)
          )
          small_width = tf.to_int32(
              tf.round(orig_width * small_scale_factor)
          )
          small_size = tf.stack([small_height, small_width])
          new_size = tf.cond(
              tf.to_float(tf.reduce_max(large_size)) > max_dimension,
              lambda: small_size,
              lambda: large_size,
          )
      else:
          new_size = large_size
      return tf.stack(tf.unstack(new_size) + [num_channels])
  
file_path: DALI/docs/examples/use_cases/tensorflow/efficientdet/pipeline/tf/preprocessor.py
imports: import tensorflow.compat.v1
  from pipeline.anchors_utils import box_list
label_desc: Use image node_id 6 for calling a global function with example usage: _compute_new_dynamic_size(image, min_dimension, max_dimension) and returns: tf