code: def test_dense_backward_no_flatten():
      print("2nd order gradient for Fully Connected, flatten=False")
      for x in NDArrayGenerator(5, 3):
          hidden = random.randrange(1, 4)
          net = gluon.nn.Sequential()
          net.add(gluon.nn.Dense(hidden, flatten=False))
          net.initialize(mxnet.initializer.Constant(0.5))
          x.attach_grad()
          with autograd.record():
              y = net.forward(x.as_np_ndarray()).as_nd_ndarray()
              o_y = arange_shape_like(y)  # head gradient of y
              params = [p.data() for p in net.collect_params().values()]
              w = params[0].as_nd_ndarray()
              b = params[1].as_nd_ndarray()
              print(
                  "Checking y ({}) = x({}) * w^T({}) + b({})".format(
                      y.shape, x.shape, w.shape, b.shape
                  )
              )
              x_grad = autograd.grad(
                  heads=y,
                  variables=x,
                  head_grads=o_y,
                  create_graph=True,
                  retain_graph=True,
              )[0]
              o_x_grad = arange_shape_like(x_grad)
              w_grad_grad = autograd.grad(
                  heads=x_grad,
                  variables=w,
                  head_grads=o_x_grad,
                  create_graph=False,
              )[0]
              w_grad = autograd.grad(
                  heads=y,
                  variables=w,
                  head_grads=o_y,
                  create_graph=True,
                  retain_graph=True,
              )[0]
              o_w_grad = arange_shape_like(w_grad)
              x_grad_grad = autograd.grad(
                  heads=w_grad,
                  variables=x,
                  head_grads=o_w_grad,
                  create_graph=False,
              )[0]
          # Expected results
          o_y = flatten2d_left(o_y)
          x = flatten2d_left(x)
          o_x_grad = flatten2d_left(o_x_grad)
          o_w_grad = flatten2d_left(o_w_grad)
          w_grad_e = nd.dot(o_y, x, transpose_a=True)
          w_grad_grad_e = nd.dot(o_y, o_x_grad, transpose_a=True)
          x_grad_e = nd.dot(o_y, w)
          x_grad_grad_e = nd.dot(o_y, o_w_grad)
          w_grad_check = same(
              flatten2d_left(w_grad), flatten2d_left(w_grad_e)
          )
          w_grad_grad_check = same(
              flatten2d_left(w_grad_grad), flatten2d_left(w_grad_grad_e)
          )
          x_grad_check = same(
              flatten2d_left(x_grad), flatten2d_left(x_grad_e)
          )
          x_grad_grad_check = same(
              flatten2d_left(x_grad_grad), flatten2d_left(x_grad_grad_e)
          )
          assert x_grad_check
          assert w_grad_check
          assert x_grad_grad_check
          assert w_grad_grad_check
  
imports: import math
  import random
  from functools import reduce
  from operator import mul
  import random
  from common import xfail_when_nonstandard_decimal_separator
  import mxnet
  from mxnet import nd, autograd, gluon
  from mxnet.test_utils import assert_almost_equal, random_arrays, random_uniform_arrays, rand_shape_nd, same
label_desc: Use image node_id 36 for calling a global function with example usage: test_dense_backward_no_flatten() without return types