code: def test_cast_storage_ex():
      def check_cast_storage(
          shape, density, from_stype, to_stype, check_numeric_grad=True
      ):
          x = mx.symbol.Variable("x", stype=from_stype)
          x_nd = rand_ndarray(shape, from_stype, density=density)
          x_np = x_nd.asnumpy()
          out_np = x_np
          test = mx.symbol.cast_storage(x, stype=to_stype)
          location = {"x": x_nd}
          check_symbolic_forward(test, location, [out_np])
          # consider disable the numeric grad check for gpu block kernel since the input is large
          if check_numeric_grad:
              check_numeric_gradient(test, location)
          grad_stypes = {"x": to_stype}
          check_symbolic_backward(
              test,
              location,
              [out_np],
              [out_np],
              grad_stypes=grad_stypes,
          )
  
      density = [1.00, 0.50, 0.01]
      for d in density:
          shape_2d = rand_shape_2d()
          shape_3d = rand_shape_3d()
          check_cast_storage(shape_2d, d, "csr", "default")
          check_cast_storage(shape_2d, d, "default", "csr")
          check_cast_storage(shape_2d, d, "csr", "csr")
          check_cast_storage(shape_2d, d, "row_sparse", "default")
          check_cast_storage(shape_2d, d, "default", "row_sparse")
          check_cast_storage(shape_2d, d, "row_sparse", "row_sparse")
          check_cast_storage(shape_3d, d, "row_sparse", "default")
          check_cast_storage(shape_3d, d, "default", "row_sparse")
          check_cast_storage(shape_3d, d, "row_sparse", "row_sparse")
          for i in range(4, 6):
              shape = rand_shape_nd(i, 5)
              check_cast_storage(shape, d, "default", "row_sparse")
              check_cast_storage(shape, d, "row_sparse", "default")
          # Test specific gpu kernels
          if default_device().device_type is "gpu":
              dim0 = rnd.randint(1, 10)
              # test gpu thread kernel
              check_cast_storage(
                  (dim0, rnd.randint(1, 32)), d, "default", "csr"
              )
              # test gpu warp   kernel
              check_cast_storage(
                  (dim0, rnd.randint(32, 512)), d, "default", "csr"
              )
              # test gpu block  kernel
              check_cast_storage(
                  (dim0, rnd.randint(512, 1024)),
                  d,
                  "default",
                  "csr",
                  check_numeric_grad=False,
              )
              # check race condition in block kernel
              check_cast_storage(
                  (200, 128 * 2 + 1),
                  d,
                  "default",
                  "csr",
                  check_numeric_grad=False,
              )
              # test gpu thread kernel
              check_cast_storage(
                  (dim0, rnd.randint(1, 32)), d, "default", "row_sparse"
              )
              # test gpu warp   kernel
              check_cast_storage(
                  (dim0, rnd.randint(32, 512)),
                  d,
                  "default",
                  "row_sparse",
              )
              # test gpu block  kernel
              check_cast_storage(
                  (dim0, rnd.randint(512, 1024)),
                  d,
                  "default",
                  "row_sparse",
                  check_numeric_grad=False,
              )
  
imports: from mxnet.test_utils import *
  from mxnet.base import MXNetError
  import pytest
  from common import assertRaises
  import random
  import warnings
label_desc: Use image node_id 18 for calling a global function with example usage: test_cast_storage_ex() without return types