code: def get_pp_resize_smallest(
      min_resize: int,
      method: str = tf.image.ResizeMethod.BILINEAR,
  ) -> Callable[[tf.Tensor], tf.Tensor]:
      """PP op to resize an image to the smallest size as in DMVR."""
  
      def _resize(
          image: tf.Tensor,  # Shape: (..., H, W, C)
      ) -> tf.Tensor:
          shape = tf.shape(input=image)
          input_h = shape[-3]
          input_w = shape[-2]
  
          output_h = tf.maximum(
              min_resize, (input_h * min_resize) // input_w
          )
          output_w = tf.maximum(
              min_resize, (input_w * min_resize) // input_h
          )
  
          def resize_fn() -> tf.Tensor:
              frames_resized = tf.image.resize(
                  image, (output_h, output_w), method=method
              )
              return tf.cast(frames_resized, image.dtype)
  
          should_resize = tf.math.logical_or(
              tf.not_equal(input_w, output_w),
              tf.not_equal(input_h, output_h),
          )
          image = tf.cond(
              pred=should_resize,
              true_fn=resize_fn,
              false_fn=lambda: image,
          )
  
          return image
  
      return _resize
  
file_path: scenic/scenic/projects/lang4video/pp_ops.py
imports: from collections.abc import Callable
  import functools
  from typing import Optional
  from dmvr import processors
  from dmvr import tokenizers
  import ml_collections
  from scenic.dataset_lib.big_transfer.preprocessing import utils
  from scenic.dataset_lib.big_transfer.registry import Registry
  from scenic.projects.lang4video import util
  import tensorflow
label_desc: Use image node_id 5 for calling a global function with example usage: get_pp_resize_smallest(min_resize, method) and returns: _resize, image, tf