code: def _lstm_layer(
      x,
      hidden,
      weights,
      biases,
      bidirectional,
      batch_first,
      batch_sizes=None,
  ):
      if not bidirectional:
          result, (h, c) = _lstm_cell(
              x,
              *hidden,
              *weights,
              *biases,
              batch_first=batch_first,
              batch_sizes=batch_sizes,
          )
      else:
          result_fw, (h_fw, c_fw) = _lstm_cell(
              x,
              hidden[0][:1],
              hidden[1][:1],
              weights[0][0],
              weights[1][0],
              biases[0][0],
              biases[1][0],
              batch_first=batch_first,
              batch_sizes=batch_sizes,
          )
          x_reversed = ivy.flip(x, axis=0)
          result_bw, (h_bw, c_bw) = _lstm_cell(
              x_reversed,
              hidden[0][1:],
              hidden[1][1:],
              weights[0][1],
              weights[1][1],
              biases[0][1],
              biases[1][1],
              batch_first=batch_first,
              batch_sizes=batch_sizes,
          )
          result_bw = ivy.flip(result_bw, axis=0)
          result = ivy.concat(
              [result_fw, result_bw], axis=len(result_fw.shape) - 1
          )
          c = ivy.concat([c_fw, c_bw], axis=0)
          h = ivy.concat([h_fw, h_bw], axis=0)
      return result, (h, c)
  
imports: from typing import Optional, Tuple, Union, Sequence
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, handle_partial_mixed_function, inputs_to_ivy_arrays, to_native_arrays_and_back, inputs_to_native_shapes, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 28 for calling a global function with example usage: _lstm_layer(x, hidden, weights, biases, bidirectional, batch_first, batch_sizes) and returns: result,  h,  c