code: def _dynamic_to_4D_image(image):
      shape = tf.shape(image)
      original_rank = tf.rank(image)
      # 4D image => [N, H, W, C] or [N, C, H, W]
      # 3D image => [1, H, W, C] or [1, C, H, W]
      # 2D image => [1, H, W, 1]
      left_pad = tf.cast(
          tf.less_equal(original_rank, 3), dtype=tf.int32
      )
      right_pad = tf.cast(tf.equal(original_rank, 2), dtype=tf.int32)
      new_shape = tf.concat(
          [
              tf.ones(shape=left_pad, dtype=tf.int32),
              shape,
              tf.ones(shape=right_pad, dtype=tf.int32),
          ],
          axis=0,
      )
      return tf.reshape(image, new_shape)
  
file_path: addons/tensorflow_addons/image/utils.py
imports: import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: _dynamic_to_4D_image(image) and returns: tf