code: def from_4D_image(image, ndims):
      """Convert back to an image with `ndims` rank.
  
      Args:
        image: 4D `Tensor`.
        ndims: The original rank of the image.
  
      Returns:
        `ndims`-D `Tensor` with the same type.
      """
      with tf.control_dependencies(
          [
              tf.debugging.assert_rank(
                  image, 4, message="`image` must be 4D tensor"
              )
          ]
      ):
          if isinstance(ndims, tf.Tensor):
              return _dynamic_from_4D_image(image, ndims)
          elif ndims == 2:
              return tf.squeeze(image, [0, 3])
          elif ndims == 3:
              return tf.squeeze(image, [0])
          else:
              return image
  
file_path: addons/tensorflow_addons/image/utils.py
imports: import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: from_4D_image(image, ndims) and returns: _dynamic_from_4D_image, tf, tf, image