code: def test_tanh():
      def tanh(x):
          return nd.tanh(x)
  
      def grad_op(x):
          return 1 - tanh(x) ** 2
  
      def grad_grad_op(x):
          return -2 * tanh(x) * grad_op(x)
  
      for dim in range(1, 5):
          shape = rand_shape_nd(dim)
          array = random_arrays(shape)
          check_nth_order_unary(
              array, tanh, grad_op, 1, rtol=1e-6, atol=1e-6
          )
          check_second_order_unary(
              array, tanh, grad_grad_op, rtol=1e-6, atol=1e-5
          )
  
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 6 for calling a global function with example usage: test_tanh() and returns: nd, unknown, unknown