code: def test_lstm_return_final():
      num_batch, seq_len, n_features = 2, 3, 4
      num_units = 2
      in_shp = (num_batch, seq_len, n_features)
      x_in = np.random.random(in_shp).astype("float32")
  
      l_inp = InputLayer(in_shp)
      lasagne.random.get_rng().seed(1234)
      l_rec_final = LSTMLayer(l_inp, num_units, only_return_final=True)
      lasagne.random.get_rng().seed(1234)
      l_rec_all = LSTMLayer(l_inp, num_units, only_return_final=False)
  
      output_final = helper.get_output(l_rec_final).eval(
          {l_inp.input_var: x_in}
      )
      output_all = helper.get_output(l_rec_all).eval(
          {l_inp.input_var: x_in}
      )
  
      assert output_final.shape == (
          output_all.shape[0],
          output_all.shape[2],
      )
      assert output_final.shape == lasagne.layers.get_output_shape(
          l_rec_final
      )
      assert np.allclose(output_final, output_all[:, -1])
  
imports: import pytest
  from lasagne.layers import RecurrentLayer, LSTMLayer, CustomRecurrentLayer
  from lasagne.layers import InputLayer, DenseLayer, GRULayer, Gate, Layer
  from lasagne.layers import helper
  import theano
  import theano.tensor
  import numpy
  import lasagne
  from mock import Mock
label_desc: Use image node_id 38 for calling a global function with example usage: test_lstm_return_final() without return types