code: def _dynamic_from_4D_image(image, original_rank):
      shape = tf.shape(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]
      begin = tf.cast(tf.less_equal(original_rank, 3), dtype=tf.int32)
      end = 4 - tf.cast(tf.equal(original_rank, 2), dtype=tf.int32)
      new_shape = shape[begin:end]
      return tf.reshape(image, new_shape)
  
file_path: addons/tensorflow_addons/image/utils.py
imports: import tensorflow
label_desc: Use image node_id 5 for calling a global function with example usage: _dynamic_from_4D_image(image, original_rank) and returns: tf