class_docstr: This class implements the Transducer loss computation with forward-backward algorithm
  Sequence Transduction with naive implementation : https://arxiv.org/pdf/1211.3711.pdf
  
  This class use torch.autograd.Function. In fact of using the forward-backward algorithm,
  we need to compute the gradient manually.
  
  This class can't be instantiated, please refer to TransducerLoss class
  
  It is also possible to use this class directly by using Transducer.apply
class_docstr_tok: ["This","class","implements","the","Transducer","loss","computation","with","forward-backward","algorithm","Sequence","Transduction","with","naive","implementation",":","https",":","\/\/arxiv.org\/pdf\/1211.3711.pdf","This","class","use","torch.autograd.Function",".","In","fact","of","using","the","forward-backward","algorithm",",","we","need","to","compute","the","gradient","manually",".","This","class","ca","n't","be","instantiated",",","please","refer","to","TransducerLoss","class","It","is","also","possible","to","use","this","class","directly","by","using","Transducer.apply"]
docstr: Computes the transducer loss.
docstr_tok: ["Computes","the","transducer","loss","."]
code: def forward(ctx, log_probs, labels, T, U, blank, reduction):
      """Computes the transducer loss."""
      log_probs = log_probs.detach()
      B, maxT, maxU, A = log_probs.shape
      grads = torch.zeros(
          (B, maxT, maxU, A),
          dtype=log_probs.dtype,
          device=log_probs.device,
      )
      alpha = torch.zeros(
          (B, maxT, maxU),
          device=log_probs.device,
          dtype=log_probs.dtype,
      )
      beta = torch.zeros(
          (B, maxT, maxU),
          device=log_probs.device,
          dtype=log_probs.dtype,
      )
      lock = torch.zeros(
          (B, maxU), dtype=torch.int32, device=log_probs.device
      )
      log_p_alpha = torch.zeros(
          (B,), device=log_probs.device, dtype=log_probs.dtype
      )
      log_p_beta = torch.zeros(
          (B,), device=log_probs.device, dtype=log_probs.dtype
      )
      cu_kernel_forward[B, maxU](
          log_probs,
          labels,
          alpha,
          log_p_alpha,
          T,
          U,
          blank,
          lock,
      )
      lock = lock * 0
      cu_kernel_backward[B, maxU](
          log_probs, labels, beta, log_p_beta, T, U, blank, lock
      )
      cu_kernel_compute_grad[maxT, B](
          log_probs, labels, alpha, beta, grads, T, U, blank
      )
      ctx.grads = grads
      del alpha, beta, lock, log_p_beta, T, U, log_probs, labels
      torch.cuda.empty_cache()
      if reduction == "mean":
          return -log_p_alpha.mean()
      elif reduction == "sum":
          return sum(-log_p_alpha)
      elif reduction == "none":
          return -log_p_alpha
      else:
          raise Exception("Unexpected reduction {}".format(reduction))
  
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 1 for calling the Transducer obj's underlying member method code with example usage: obj.forward(ctx, log_probs, labels, T, U, blank, reduction) and returns: unknown, sum, unknown