code: def recurrent_step_lstm(
      input_val,
      num_units,
      step_hidden,
      step_cell,
      w_x_init,
      w_h_init,
      b_init,
      nonlinearity,
      gate_nonlinearity,
      forget_bias=1.0,
  ):
      """Helper function for performing feedforward of a lstm cell.
  
      Args:
          input_val (tf.Tensor): Input placeholder.
          num_units (int): Hidden dimension for LSTM cell.
          step_hidden (tf.Tensor): Place holder for step hidden state.
          step_cell (tf.Tensor): Place holder for step cell state.
          nonlinearity (callable): Activation function for intermediate
              dense layer(s). It should return a tf.Tensor. Set it to
              None to maintain a linear activation.
          w_x_init (callable): Initializer function for the weight
              of intermediate dense layer(s). The function should return a
              tf.Tensor.
          b_init (callable): Initializer function for the bias
              of intermediate dense layer(s). The function should return a
              tf.Tensor.
          gate_nonlinearity (callable): Activation function for recurrent
              layers. It should return a tf.Tensor. Set it to None to
              maintain a linear activation.
          w_h_init (callable): Initializer function for the weight
              of recurrent layer(s). The function should return a
              tf.Tensor.
          forget_bias (float): Bias to be added to the forget gate at
              initialization. It's used to reduce the scale of forgetting at the
              beginning of the training.
  
      Returns:
          tf.Tensor: Final hidden state after feedforward.
          tf.Tensor: Final cell state after feedforward.
  
      Note:
          Incoming gate:    i(t) = f_i(x(t) @ W_xi + h(t-1) @ W_hi +
                                   w_ci * c(t-1) + b_i)
          Forget gate:      f(t) = f_f(x(t) @ W_xf + h(t-1) @ W_hf +
                                   w_cf * c(t-1) + b_f)
          Cell gate:        c(t) = f(t) * c(t - 1) + i(t) * f_c(x(t) @ W_xc +
                                   h(t-1) @ W_hc + b_c)
          Out gate:         o(t) = f_o(x(t) @ W_xo + h(t-1) W_ho +
                                   w_co * c(t) + b_o)
          New hidden state: h(t) = o(t) * f_h(c(t))
          Incoming, forget, cell, and out vectors must have the same
          dimension as the hidden state.
  
      """
  
      def f(x):
          """Linear function.
  
          Args:
              x (float): Input variable.
  
          Returns:
              float: Ouput variable.
  
          """
          return x
  
      if nonlinearity is None:
          nonlinearity = f
      if gate_nonlinearity is None:
          gate_nonlinearity = f
  
      input_dim = np.prod(input_val.shape[1:])
      # Weights for the input gate
      w_xi = np.full((input_dim, num_units), w_x_init)
      w_hi = np.full((num_units, num_units), w_h_init)
      b_i = np.full((num_units,), b_init)
      # Weights for the forget gate
      w_xf = np.full((input_dim, num_units), w_x_init)
      w_hf = np.full((num_units, num_units), w_h_init)
      b_f = np.full((num_units,), b_init)
      # Weights for the cell gate
      w_xc = np.full((input_dim, num_units), w_x_init)
      w_hc = np.full((num_units, num_units), w_h_init)
      b_c = np.full((num_units,), b_init)
      # Weights for the out gate
      w_xo = np.full((input_dim, num_units), w_x_init)
      w_ho = np.full((num_units, num_units), w_h_init)
      b_o = np.full((num_units,), b_init)
  
      w_x_ifco = np.concatenate([w_xi, w_xf, w_xc, w_xo], axis=1)
      w_h_ifco = np.concatenate([w_hi, w_hf, w_hc, w_ho], axis=1)
  
      x_ifco = np.matmul(input_val, w_x_ifco)
      h_ifco = np.matmul(step_hidden, w_h_ifco)
  
      x_i = x_ifco[:, :num_units]
      x_f = x_ifco[:, num_units : num_units * 2]
      x_c = x_ifco[:, num_units * 2 : num_units * 3]
      x_o = x_ifco[:, num_units * 3 : num_units * 4]
  
      h_i = h_ifco[:, :num_units]
      h_f = h_ifco[:, num_units : num_units * 2]
      h_c = h_ifco[:, num_units * 2 : num_units * 3]
      h_o = h_ifco[:, num_units * 3 : num_units * 4]
  
      i = gate_nonlinearity(x_i + h_i + b_i)
      f = gate_nonlinearity(x_f + h_f + b_f + forget_bias)
      o = gate_nonlinearity(x_o + h_o + b_o)
  
      c = f * step_cell + i * nonlinearity(x_c + h_c + b_c)
      h = o * nonlinearity(c)
      return h, c
  
file_path: garage/tests/helpers.py
imports: import cloudpickle
  import numpy
  import pytest
  from garage import Environment
  from tests.quirks import KNOWN_GYM_RENDER_NOT_IMPLEMENTED
label_desc: Use image node_id 4 for calling a global function with example usage: recurrent_step_lstm(input_val, num_units, step_hidden, step_cell, w_x_init, w_h_init, b_init, nonlinearity, gate_nonlinearity, forget_bias) and returns: h,  c, x