code: def maybe_reshape_4d_to_3d(x):
      """Reshape input from 4D to 3D if necessary."""
      x_shape = common_layers.shape_list(x)
      is_4d = False
      if len(x_shape) == 4:
          x = tf.reshape(
              x, [x_shape[0], x_shape[1] * x_shape[2], x_shape[3]]
          )
          is_4d = True
      return x, x_shape, is_4d
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from six.moves import range
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.utils import expert_utils
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 1 for calling a global function with example usage: maybe_reshape_4d_to_3d(x) and returns: x,  x_shape,  is_4d