code: def test_gluon_ctc_consistency():
      loss = mx.gluon.loss.CTCLoss()
      data = mx.np.flip(
          mx.np.repeat(
              mx.np.arange(0, 4, device=mx.gpu(0)), 40
          ).reshape((2, 20, 4)),
          axis=0,
      )
      cpu_label = mx.np.array(
          [[2, 1, -1, -1], [3, 2, 2, -1]], device=mx.cpu(0)
      )
      gpu_label = mx.np.array(
          [[2, 1, -1, -1], [3, 2, 2, -1]], device=mx.gpu(0)
      )
  
      cpu_data = data.copy().to_device(mx.cpu(0))
      cpu_data.attach_grad()
      with mx.autograd.record():
          l_cpu = loss(cpu_data, cpu_label)
          l_cpu.backward()
  
      gpu_data = data.copyto(mx.gpu(0))
      gpu_data.attach_grad()
      with mx.autograd.record():
          l_gpu = loss(gpu_data, gpu_label)
          l_gpu.backward()
  
      assert_almost_equal(
          cpu_data.grad, gpu_data.grad, atol=1e-3, rtol=1e-3
      )
  
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 12 for calling a global function with example usage: test_gluon_ctc_consistency() without return types