code: def _create_lstm_layer(self, inputs, hidden_size, lengths):
      with tf.compat.v1.device("/gpu:{}".format(self.use_gpu_device)):
          if not self.use_contrib:
              model = tf.keras.Sequential(
                  [
                      tf.keras.layers.Bidirectional(
                          layer=tf.keras.layers.LSTM(
                              hidden_size, return_sequences=False
                          ),
                          merge_mode="concat",
                      )
                  ]
              )
  
              mask = tf.expand_dims(
                  tf.sequence_mask(lengths, dtype=tf.float32), axis=-1
              )
              # shape = (batch x sentence, 2 x hidden)
              output = model(inputs, mask=mask)
              # inputs shape = (batch, sentence, inp)
              batch = tf.shape(input=lengths)[0]
  
              return tf.reshape(
                  output, shape=[batch, -1, 2 * hidden_size]
              )
  
          time_based = tf.transpose(a=inputs, perm=[1, 0, 2])
  
          cell_fw = tf.contrib.rnn.LSTMBlockFusedCell(
              hidden_size, use_peephole=True
          )
          cell_bw = tf.contrib.rnn.LSTMBlockFusedCell(
              hidden_size, use_peephole=True
          )
          cell_bw = tf.contrib.rnn.TimeReversedFusedRNN(cell_bw)
  
          output_fw, _ = cell_fw(
              time_based, dtype=tf.float32, sequence_length=lengths
          )
          output_bw, _ = cell_bw(
              time_based, dtype=tf.float32, sequence_length=lengths
          )
  
          result = tf.concat([output_fw, output_bw], axis=-1)
          return tf.transpose(a=result, perm=[1, 0, 2])
  
imports: import math
  import random
  import sys
  import numpy
  import tensorflow
  from .sentence_grouper import SentenceGrouper
label_desc: Use image node_id 5 for calling the NerModel obj's underlying member method code with example usage: obj._create_lstm_layer(inputs, hidden_size, lengths) and returns: tf, tf