code: def prepare_encoder(inputs, hparams, attention_type="local_1d"):
      """Prepare encoder for images."""
      x = prepare_image(inputs, hparams, name="enc_channels")
      # Add position signals.
      x = add_pos_signals(x, hparams, "enc_pos")
      x_shape = common_layers.shape_list(x)
      if attention_type == "local_1d":
          x = tf.reshape(
              x,
              [
                  x_shape[0],
                  x_shape[1] * x_shape[2],
                  hparams.hidden_size,
              ],
          )
          x.set_shape([None, None, hparams.hidden_size])
      elif attention_type == "local_2d":
          x.set_shape([None, None, None, hparams.hidden_size])
      return x
  
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 15 for calling a global function with example usage: prepare_encoder(inputs, hparams, attention_type) and returns: x