code: def lstm_bid_encoder(inputs, sequence_length, hparams, train, name):
      """Bidirectional LSTM for encoding inputs that are [batch x time x size]."""
  
      with tf.variable_scope(name):
          cell_fw = tf.nn.rnn_cell.MultiRNNCell(
              [
                  _dropout_lstm_cell(hparams, train)
                  for _ in range(hparams.num_hidden_layers)
              ]
          )
  
          cell_bw = tf.nn.rnn_cell.MultiRNNCell(
              [
                  _dropout_lstm_cell(hparams, train)
                  for _ in range(hparams.num_hidden_layers)
              ]
          )
  
          (
              (encoder_fw_outputs, encoder_bw_outputs),
              (encoder_fw_state, encoder_bw_state),
          ) = tf.nn.bidirectional_dynamic_rnn(
              cell_fw,
              cell_bw,
              inputs,
              sequence_length,
              dtype=tf.float32,
              time_major=False,
          )
  
          encoder_outputs = tf.concat(
              (encoder_fw_outputs, encoder_bw_outputs), 2
          )
          encoder_states = []
  
          for i in range(hparams.num_hidden_layers):
              if isinstance(
                  encoder_fw_state[i], tf.nn.rnn_cell.LSTMStateTuple
              ):
                  encoder_state_c = tf.concat(
                      values=(
                          encoder_fw_state[i].c,
                          encoder_bw_state[i].c,
                      ),
                      axis=1,
                      name="encoder_fw_state_c",
                  )
                  encoder_state_h = tf.concat(
                      values=(
                          encoder_fw_state[i].h,
                          encoder_bw_state[i].h,
                      ),
                      axis=1,
                      name="encoder_fw_state_h",
                  )
                  encoder_state = tf.nn.rnn_cell.LSTMStateTuple(
                      c=encoder_state_c, h=encoder_state_h
                  )
              elif isinstance(encoder_fw_state[i], tf.Tensor):
                  encoder_state = tf.concat(
                      values=(encoder_fw_state[i], encoder_bw_state[i]),
                      axis=1,
                      name="bidirectional_concat",
                  )
  
              encoder_states.append(encoder_state)
  
          encoder_states = tuple(encoder_states)
          return encoder_outputs, encoder_states
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  from tensor2tensor.layers import area_attention
  from tensor2tensor.layers import common_hparams
  from tensor2tensor.layers import common_layers
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 6 for calling a global function with example usage: lstm_bid_encoder(inputs, sequence_length, hparams, train, name) and returns: encoder_outputs,  encoder_states