code: def cu_kernel_compute_grad(
      log_probs, labels, alpha, beta, grads, T, U, blank
  ):
      """
      Compute gradient for the forward-backward algorithm using Numba cuda kernel.
      Sequence Transduction with naive implementation : https://arxiv.org/pdf/1211.3711.pdf
  
      Arguments
      ---------
      log_probs : tensor
          4D Tensor of (batch x TimeLength x LabelLength x outputDim) from the Transducer network.
      labels : tensor
          2D Tensor of (batch x MaxSeqLabelLength) containing targets of the batch with zero padding.
      beta : tensor
          3D Tensor of (batch x TimeLength x LabelLength) for backward computation.
      log_p : tensor
          1D Tensor of (batch) for backward cost computation.
      T : tensor
          1D Tensor of (batch) containing TimeLength of each target.
      U : tensor
          1D Tensor of (batch) containing LabelLength of each target.
      blank : int
          Blank indice.
      lock : int
          2D Tensor of (batch x LabelLength) containing bool(1-0) lock for parallel computation.
      """
      # parallelize the gradient computation over batch and timeseq length dim
      t = cuda.blockIdx.x
      b = cuda.threadIdx.x
      if t < T[b]:
          # compute the gradient for no_emit prob
          if t == 0:
              grads[b, T[b] - 1, U[b], blank] = -math.exp(
                  alpha[b, T[b] - 1, U[b]]
                  + log_probs[b, T[b] - 1, U[b], blank]
                  - beta[b, 0, 0]
              )
  
          if t < T[b] - 1:
              for u in range(U[b] + 1):
                  grads[b, t, u, blank] = (
                      alpha[b, t, u] + beta[b, t + 1, u]
                  )
                  grads[b, t, u, blank] = -math.exp(
                      grads[b, t, u, blank]
                      + log_probs[b, t, u, blank]
                      - beta[b, 0, 0]
                  )
          # compute the gradient for emit prob
          for u, l in enumerate(labels[b]):
              if u < U[b]:
                  grads[b, t, u, l] = alpha[b, t, u] + beta[b, t, u + 1]
                  grads[b, t, u, l] = -math.exp(
                      grads[b, t, u, l]
                      + log_probs[b, t, u, l]
                      - beta[b, 0, 0]
                  )
  
file_path: speechbrain/speechbrain/nnet/loss/transducer_loss.py
imports: import torch
  from torch.autograd import Function
  from torch.nn import Module
  import logging
  import math
  import warnings
label_desc: Use image node_id 3 for calling a global function with example usage: cu_kernel_compute_grad(log_probs, labels, alpha, beta, grads, T, U, blank) without return types