code: def lstm_layer(
      inputs,
      num_units,
      lengths=None,
      stack_size=1,
      use_cudnn=False,
      rnn_dropout_drop_amt=0,
      bidirectional=True,
  ):
      """Create a LSTM layer using the specified backend."""
      if use_cudnn:
          tf.logging.warning(
              "cuDNN LSTM no longer supported. Using regular LSTM."
          )
      if not bidirectional:
          raise ValueError("Only bidirectional LSTMs are supported.")
  
      assert rnn_dropout_drop_amt == 0
      cells_fw = [
          contrib_cudnn_rnn.CudnnCompatibleLSTMCell(num_units)
          for _ in range(stack_size)
      ]
      cells_bw = [
          contrib_cudnn_rnn.CudnnCompatibleLSTMCell(num_units)
          for _ in range(stack_size)
      ]
      with tf.variable_scope("cudnn_lstm"):
          (
              outputs,
              unused_state_f,
              unused_state_b,
          ) = contrib_rnn.stack_bidirectional_dynamic_rnn(
              cells_fw,
              cells_bw,
              inputs,
              dtype=tf.float32,
              sequence_length=lengths,
              parallel_iterations=1,
          )
  
      return outputs
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  from magenta.common import flatten_maybe_padded_sequences
  from magenta.common import tf_utils
  from magenta.contrib import cudnn_rnn
  from magenta.contrib import rnn
  from magenta.contrib import training
  from magenta.models.onsets_frames_transcription import constants
  from magenta.models.onsets_frames_transcription import infer_util
  from magenta.models.onsets_frames_transcription import metrics
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  import tf_slim
label_desc: Use image node_id 2 for calling a global function with example usage: lstm_layer(inputs, num_units, lengths, stack_size, use_cudnn, rnn_dropout_drop_amt, bidirectional) and returns: outputs