code: def lstm(
      input_tensor,
      mask_tensor,
      cell_state_hidden,
      scope,
      n_hidden,
      init_scale=1.0,
      layer_norm=False,
  ):
      """
      Creates an Long Short Term Memory (LSTM) cell for TensorFlow
  
      :param input_tensor: (TensorFlow Tensor) The input tensor for the LSTM cell
      :param mask_tensor: (TensorFlow Tensor) The mask tensor for the LSTM cell
      :param cell_state_hidden: (TensorFlow Tensor) The state tensor for the LSTM cell
      :param scope: (str) The TensorFlow variable scope
      :param n_hidden: (int) The number of hidden neurons
      :param init_scale: (int) The initialization scale
      :param layer_norm: (bool) Whether to apply Layer Normalization or not
      :return: (TensorFlow Tensor) LSTM cell
      """
      _, n_input = [v.value for v in input_tensor[0].get_shape()]
      with tf.variable_scope(scope):
          weight_x = tf.get_variable(
              "wx",
              [n_input, n_hidden * 4],
              initializer=ortho_init(init_scale),
          )
          weight_h = tf.get_variable(
              "wh",
              [n_hidden, n_hidden * 4],
              initializer=ortho_init(init_scale),
          )
          bias = tf.get_variable(
              "b",
              [n_hidden * 4],
              initializer=tf.constant_initializer(0.0),
          )
  
          if layer_norm:
              # Gain and bias of layer norm
              gain_x = tf.get_variable(
                  "gx",
                  [n_hidden * 4],
                  initializer=tf.constant_initializer(1.0),
              )
              bias_x = tf.get_variable(
                  "bx",
                  [n_hidden * 4],
                  initializer=tf.constant_initializer(0.0),
              )
  
              gain_h = tf.get_variable(
                  "gh",
                  [n_hidden * 4],
                  initializer=tf.constant_initializer(1.0),
              )
              bias_h = tf.get_variable(
                  "bh",
                  [n_hidden * 4],
                  initializer=tf.constant_initializer(0.0),
              )
  
              gain_c = tf.get_variable(
                  "gc",
                  [n_hidden],
                  initializer=tf.constant_initializer(1.0),
              )
              bias_c = tf.get_variable(
                  "bc",
                  [n_hidden],
                  initializer=tf.constant_initializer(0.0),
              )
  
      cell_state, hidden = tf.split(
          axis=1, num_or_size_splits=2, value=cell_state_hidden
      )
      for idx, (_input, mask) in enumerate(
          zip(input_tensor, mask_tensor)
      ):
          cell_state = cell_state * (1 - mask)
          hidden = hidden * (1 - mask)
          if layer_norm:
              gates = (
                  _ln(tf.matmul(_input, weight_x), gain_x, bias_x)
                  + _ln(tf.matmul(hidden, weight_h), gain_h, bias_h)
                  + bias
              )
          else:
              gates = (
                  tf.matmul(_input, weight_x)
                  + tf.matmul(hidden, weight_h)
                  + bias
              )
          in_gate, forget_gate, out_gate, cell_candidate = tf.split(
              axis=1, num_or_size_splits=4, value=gates
          )
          in_gate = tf.nn.sigmoid(in_gate)
          forget_gate = tf.nn.sigmoid(forget_gate)
          out_gate = tf.nn.sigmoid(out_gate)
          cell_candidate = tf.tanh(cell_candidate)
          cell_state = (
              forget_gate * cell_state + in_gate * cell_candidate
          )
          if layer_norm:
              hidden = out_gate * tf.tanh(
                  _ln(cell_state, gain_c, bias_c)
              )
          else:
              hidden = out_gate * tf.tanh(cell_state)
          input_tensor[idx] = hidden
      cell_state_hidden = tf.concat(axis=1, values=[cell_state, hidden])
      return input_tensor, cell_state_hidden
  
file_path: stable-baselines/stable_baselines/common/tf_layers.py
imports: import numpy
  import tensorflow
label_desc: Use image node_id 5 for calling a global function with example usage: lstm(input_tensor, mask_tensor, cell_state_hidden, scope, n_hidden, init_scale, layer_norm) and returns: input_tensor,  cell_state_hidden