code: def maybe_flatten3d2d(x):
      """Flatten if tensor has 3 dimensions, similar to maybe_flatten4d3d()."""
      xshape = common_layers.shape_list(x)
      if len(xshape) != 3:
          return x
      return tf.reshape(x, [xshape[0], xshape[1] * xshape[2]])
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import transformer_layers
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: maybe_flatten3d2d(x) and returns: tf, x