code: def test_nn():
      def check_dense():
          data = mx.nd.ones(shape=LARGE_X)
          linear = gluon.nn.Dense(2)
          linear.initialize()
          res = linear(data)
          assert res.shape == (LARGE_X, 2)
  
      def check_sign():
          a = mx.nd.random.normal(-1, 1, shape=LARGE_X)
          mx_res = mx.nd.sign(a)
          assert_almost_equal(
              mx_res[-1].asnumpy(), np.sign(a[-1].asnumpy())
          )
  
      # TODO: correctness of layernorm
      # numpy implementation for large vector is flaky
      def check_layer_norm():
          axis = 0
          eps = 1e-5
          in_shape = LARGE_X
          data = nd.random.normal(0, 1, in_shape)
          gamma = nd.random.normal(0, 1, in_shape)
          beta = nd.random.normal(0, 1, in_shape)
          mx_out = nd.LayerNorm(data, gamma, beta, axis, eps)
          assert mx_out.shape == (in_shape,)
  
      # TODO: correctness of batchnorm
      # in future, we could test if mean, var of output
      # matches target output's mean, var
      def check_batchnorm():
          shape = LARGE_X
          axis = 0  # since vector
          data = mx.nd.ones(shape=shape)
          bn_gamma = mx.nd.random.uniform(shape=shape)
          bn_beta = mx.nd.random.uniform(shape=shape)
          bn_running_mean = mx.nd.zeros(shape)
          bn_running_var = mx.nd.ones(shape)
          output = mx.nd.BatchNorm(
              data,
              bn_gamma,
              bn_beta,
              bn_running_mean,
              bn_running_var,
              axis=axis,
          )
          assert output.shape == (shape,)
  
      def check_sequence_mask():
          # Sequence Mask input [max_sequence_length, batch_size]
          # test with input batch_size = 2
          a = nd.arange(0, LARGE_X * 2).reshape(LARGE_X, 2)
          # test as identity operator
          b = nd.SequenceMask(a)
          assert b[-1][0] == a[-1][0]
          assert b.shape == a.shape
          # test with default mask
          b = nd.SequenceMask(
              a,
              sequence_length=nd.array([1, 1]),
              use_sequence_length=True,
          )
          assert b[0][1] == a[0][1]  # first sequence of each batch kept
          assert b[-1][-1] != a[-1][-1]  # rest sequences masked
          assert b[-1][-1] == 0
          # test with mask value
          b = nd.SequenceMask(
              a,
              sequence_length=nd.array([1, 1]),
              use_sequence_length=True,
              value=-1,
          )
          assert b[-1][-1] == -1
  
      def check_sequence_reverse():
          a = nd.arange(0, LARGE_X * 2).reshape(LARGE_X, 2)
          # test as reverse operator
          b = nd.SequenceReverse(a)
          assert b[-1][0] == a[0][0]
          assert b.shape == a.shape
          # test with sequence length
          b = nd.SequenceReverse(
              a,
              sequence_length=nd.array([2, 3]),
              use_sequence_length=True,
          )
          assert b[1][0] == a[0][0]  # check if reversed
          assert b[-1][0] == a[-1][0]  # check if intact
          assert b.shape == a.shape
  
      def check_sequence_last():
          a = nd.arange(0, LARGE_X * 2).reshape(LARGE_X, 2)
          # test if returns last sequence
          b = nd.SequenceLast(a)
          assert_almost_equal(b.asnumpy(), a[-1].asnumpy())
          assert b.shape == (2,)
          # test with sequence length
          # parameter sequence_length - NDArray with shape (batch_size)
          # (2,3) indicates 2nd sequence from batch 1 and 3rd sequence from batch 2
          # need to mention dtype = int64 for sequence_length ndarray to support large indices
          # else it defaults to float32 and errors
          b = nd.SequenceLast(
              a,
              sequence_length=mx.nd.array([2, 3], dtype="int64"),
              use_sequence_length=True,
          )
          # check if it takes 2nd sequence from the first batch
          assert b[0] == a[1][0]
  
      check_sequence_last()
      check_dense()
      check_sign()
      check_layer_norm()
      check_batchnorm()
      check_sequence_mask()
      check_sequence_reverse()
  
file_path: mxnet/tests/nightly/test_large_vector.py
imports: import os
  import sys
  import math
  import numpy
  import mxnet
  from mxnet.test_utils import rand_ndarray, assert_almost_equal, rand_coord_2d, create_vector
  from mxnet.util import TemporaryDirectory
  from mxnet import gluon, nd
  from common import with_seed
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: test_nn() without return types