code: def resize(x, mode, factor=4):
      """Resize input tensor with unkown input-shape by a factor
  
      Args:
          x (tf.Tensor): tensor NCHW
          factor (int, optional): resize factor for H, W
  
      Note:
          Differences here against Caffe have huge impacts on the
          quality of the predictions.
  
      Returns:
          tf.Tensor: resized tensor NCHW
      """
      assert mode in ["bilinear", "nearest"], mode
      shp = tf.shape(x)[2:] * factor
      # NCHW -> NHWC
      x = tf.transpose(x, [0, 2, 3, 1])
      if mode == "bilinear":
          x = tf.image.resize_bilinear(x, shp, align_corners=True)
      else:
          # better approximation of what Caffe is doing
          x = tf.image.resize_nearest_neighbor(
              x, shp, align_corners=False
          )
      # NHWC -> NCHW
      return tf.transpose(x, [0, 3, 1, 2])
  
imports: import tensorflow
  from tensorpack import ModelDesc, argscope, enable_argscope_for_module
label_desc: Use image node_id 5 for calling a global function with example usage: resize(x, mode, factor) and returns: tf