code: def resize(features, size, max_size=None):
      """Resize the image to min-side = size and adjust target boxes, area, mask.
  
      Args:
        features: dict; 'inputs' contains tf.Tensor image unbatched. 'label' is
          a dictionary of label information such a boxes, area, etc.
        size: tf.Tensor; Scalar for size of smallest sized after resize.
        max_size: int[Optional]; Scalar upper bound on resized image dimensions.
  
      Returns:
        Resized and adjusted features. Also features['size'] = (w, h) tuple.
      """
      image = features["inputs"]
      target = features["label"]
  
      # Resize the image while preserving aspect ratio.
      original_size = tf.shape(image)[0:2]
      new_size = get_size_with_aspect_ratio(
          original_size, size, max_size
      )
      rescaled_image = tf.image.resize(image, new_size)
  
      # Compute resize ratios for each dimension to be used for scaling boxes, area.
      r_height = tf_float(new_size[0] / original_size[0])
      r_width = tf_float(new_size[1] / original_size[1])
  
      if "boxes" in target:
          x0, y0, x1, y1 = tf.split(target["boxes"], 4, axis=-1)
          target["boxes"] = tf.concat(
              [
                  x0 * r_width,
                  y0 * r_height,
                  x1 * r_width,
                  y1 * r_height,
              ],
              axis=-1,
          )
  
      if "area" in target:
          area = target["area"]
          scaled_area = tf_float(area) * (r_width * r_height)
          target["area"] = scaled_area
  
      target["size"] = tf.stack(new_size)
  
      if "masks" in target:
          dtype = target["masks"].dtype
          rescaled_masks = tf.image.resize(
              tf_float(target["masks"]),
              new_size,
              method=tf.image.ResizeMethod.NEAREST_NEIGHBOR,
          )
          tf.debugging.assert_shapes(
              (
                  (rescaled_image, [..., "w", "h", 3]),
                  (rescaled_masks, [..., "w", "h", 1]),
              )
          )
          target["masks"] = tf.cast(rescaled_masks, dtype)
  
      features["inputs"] = rescaled_image
      features["label"] = target
      return features
  
imports: from typing import Any, Dict
  import tensorflow
label_desc: Use image node_id 7 for calling a global function with example usage: resize(features, size, max_size) and returns: features