code: def test_lstmp():
      hidden_size, projection_size = 3, 2
      rtol, atol = 1e-2, 1e-2
      batch_size, seq_len = 7, 11
      input_size = 5
      device = mx.gpu(0)
      lstm_input = mx.np.random.uniform(
          size=(seq_len, batch_size, input_size), device=device
      )
      shapes = {
          "i2h_weight": (hidden_size * 4, input_size),
          "h2h_weight": (hidden_size * 4, projection_size),
          "i2h_bias": (hidden_size * 4,),
          "h2h_bias": (hidden_size * 4,),
          "h2r_weight": (projection_size, hidden_size),
      }
      weights = {
          k: rand_ndarray(v).as_np_ndarray() for k, v in shapes.items()
      }
      lstm_layer = gluon.rnn.LSTM(
          hidden_size,
          projection_size=projection_size,
          input_size=input_size,
      )
      lstm_cell = gluon.rnn.LSTMPCell(
          hidden_size=hidden_size,
          projection_size=projection_size,
          input_size=input_size,
      )
      lstm_layer.initialize(device=device)
      lstm_cell.initialize(device=device)
      layer_params = lstm_layer.collect_params()
      cell_params = lstm_cell.collect_params()
      params = (
          weights["{}_{}".format(g, t)].reshape(-1)
          for t in ["weight", "bias"]
          for g in ["i2h", "h2h", "h2r"]
          if g != "h2r" or t != "bias"
      )
  
      net_params_concat = mx.np.concatenate(params)
      layer_params["rnn_param"].set_data(net_params_concat)
      for k, v in weights.items():
          cell_params[k].set_data(v)
      with autograd.record():
          layer_output = lstm_layer(lstm_input.copy())
          cell_output = lstm_cell.unroll(
              seq_len,
              lstm_input.copy(),
              layout="TNC",
              merge_outputs=True,
          )[0]
  
      assert_almost_equal(
          layer_output, cell_output, rtol=rtol, atol=atol
      )
      layer_output.backward()
      cell_output.backward()
      layer_params_split = split_rnn_params(
          layer_params["rnn_param"].grad(),
          "lstm",
          1,
          input_size,
          hidden_size,
          False,
          projection_size=projection_size,
      )
      for k, _ in weights.items():
          layer_grad = layer_params_split["l0_" + k]
          cell_grad = cell_params[k].grad()
          print("checking gradient for {}".format("lstm0_l0_" + k))
          assert_almost_equal(
              layer_grad, cell_grad, rtol=rtol, atol=atol
          )
      check_rnn_layer_forward(
          gluon.rnn.LSTM(10, 2, projection_size=5),
          mx.np.ones((8, 3, 20)),
          device=device,
      )
      check_rnn_layer_forward(
          gluon.rnn.LSTM(10, 2, projection_size=5, bidirectional=True),
          mx.np.ones((8, 3, 20)),
          [mx.np.ones((4, 3, 5)), mx.np.ones((4, 3, 10))],
          device=device,
      )
      check_rnn_layer_forward(
          gluon.rnn.LSTM(10, 2, dropout=0.5, projection_size=5),
          mx.np.ones((8, 3, 20)),
          run_only=True,
          device=device,
      )
      check_rnn_layer_forward(
          gluon.rnn.LSTM(
              10, 2, bidirectional=True, dropout=0.5, projection_size=5
          ),
          mx.np.ones((8, 3, 20)),
          [mx.np.ones((4, 3, 5)), mx.np.ones((4, 3, 10))],
          run_only=True,
          device=device,
      )
      lstm_layer.save_parameters("gpu_tmp.params")
      lstm_layer.load_parameters("gpu_tmp.params")
  
imports: import sys
  import os
  import time
  import random
  import mxnet
  import multiprocessing
  from mxnet.test_utils import check_consistency, set_default_device, assert_almost_equal, rand_ndarray, environment
  import numpy
  import math
  from mxnet import autograd
  import pytest
  from common import assert_raises_cudnn_not_satisfied, run_in_spawned_process, random_seed
  from test_gluon import *
  from test_loss import *
  from test_numpy_loss import *
  from test_gluon_rnn import *
label_desc: Use image node_id 3 for calling a global function with example usage: test_lstmp() without return types