class_docstr: Transducer loss
  Detail of this loss function can be found in: Sequence Transduction with Recurrent Neural 
  Networks
  
  Arguments:
      fuse_softmax_backward (bool, optional) whether to fuse the backward of transducer loss with
          softmax. (default: True)
      opt (int, optional): pick the optimization level in [0, 1]. opt=1 picks a more optimized 
          algorithm. In some cases, opt=1 might fall back to opt=0. (default: 1)
      packed_input (bool, optional): whether to pack the output in a compact form with don't-care 
      data being removed. (default: False)
class_docstr_tok: ["Transducer","loss","Detail","of","this","loss","function","can","be","found","in",":","Sequence","Transduction","with","Recurrent","Neural","Networks","Arguments",":","fuse_softmax_backward","(","bool",",","optional",")","whether","to","fuse","the","backward","of","transducer","loss","with","softmax",".","(","default",":","True",")","opt","(","int",",","optional",")",":","pick","the","optimization","level","in","[","0",",","1","]",".","opt=1","picks","a","more","optimized","algorithm",".","In","some","cases",",","opt=1","might","fall","back","to","opt=0",".","(","default",":","1",")","packed_input","(","bool",",","optional",")",":","whether","to","pack","the","output","in","a","compact","form","with","don't-care","data","being","removed",".","(","default",":","False",")"]
docstr: Forward operation of transducer joint
  
  Arguments:
      x (tensor): input tensor to the loss function with a shape of (B, T, U, H).
      label (tensor): labels for the input data.
      f_len (tensor): lengths of the inputs in the time dimension for each batch.
      y_len (tensor): lengths of the labels for each batch.
      blank_idx (int): index for the null symbol.
      batch_offset (tensor, optional): tensor containing the offset of each batch
          in the input. For example, batch offset can be obtained from: 
          batch_offset = torch.cumsum(f_len*(y_len+1), dim=0)
          This argument is required if packed_input == True, and is ignored if 
          packed_input == False. (default: None)
      max_f_len (int, optional): maximum length of the input in the time dimension.
          For example, it can be obtained as 
          max_f_len = max(f_len)
          This argument is required if packed_input == True, and is ignored if 
          packed_input == False. (default: None)
          (default: None)
      debug_list (list, optional): when an empty list is supplied, Alpha and Beta generated 
          in the forward operation will be attached to this list for debug purpose. 
          (default: None)
docstr_tok: ["Forward","operation","of","transducer","joint","Arguments",":","x","(","tensor",")",":","input","tensor","to","the","loss","function","with","a","shape","of","(","B",",","T",",","U",",","H",")",".","label","(","tensor",")",":","labels","for","the","input","data",".","f_len","(","tensor",")",":","lengths","of","the","inputs","in","the","time","dimension","for","each","batch",".","y_len","(","tensor",")",":","lengths","of","the","labels","for","each","batch",".","blank_idx","(","int",")",":","index","for","the","null","symbol",".","batch_offset","(","tensor",",","optional",")",":","tensor","containing","the","offset","of","each","batch","in","the","input",".","For","example",",","batch","offset","can","be","obtained","from",":","batch_offset","=","torch.cumsum","(","f_len","*","(","y_len+1",")",",","dim=0",")","This","argument","is","required","if","packed_input","==","True",",","and","is","ignored","if","packed_input","==","False",".","(","default",":","None",")","max_f_len","(","int",",","optional",")",":","maximum","length","of","the","input","in","the","time","dimension",".","For","example",",","it","can","be","obtained","as","max_f_len","=","max","(","f_len",")","This","argument","is","required","if","packed_input","==","True",",","and","is","ignored","if","packed_input","==","False",".","(","default",":","None",")","(","default",":","None",")","debug_list","(","list",",","optional",")",":","when","an","empty","list","is","supplied",",","Alpha","and","Beta","generated","in","the","forward","operation","will","be","attached","to","this","list","for","debug","purpose",".","(","default",":","None",")"]
code: def forward(
      self,
      x,
      label,
      f_len,
      y_len,
      blank_idx,
      batch_offset=None,
      max_f_len=None,
      debug_list=None,
  ):
      """Forward operation of transducer joint
  
      Arguments:
          x (tensor): input tensor to the loss function with a shape of (B, T, U, H).
          label (tensor): labels for the input data.
          f_len (tensor): lengths of the inputs in the time dimension for each batch.
          y_len (tensor): lengths of the labels for each batch.
          blank_idx (int): index for the null symbol.
          batch_offset (tensor, optional): tensor containing the offset of each batch
              in the input. For example, batch offset can be obtained from:
              batch_offset = torch.cumsum(f_len*(y_len+1), dim=0)
              This argument is required if packed_input == True, and is ignored if
              packed_input == False. (default: None)
          max_f_len (int, optional): maximum length of the input in the time dimension.
              For example, it can be obtained as
              max_f_len = max(f_len)
              This argument is required if packed_input == True, and is ignored if
              packed_input == False. (default: None)
              (default: None)
          debug_list (list, optional): when an empty list is supplied, Alpha and Beta generated
              in the forward operation will be attached to this list for debug purpose.
              (default: None)
      """
      if self.packed_input:
          if batch_offset is None or max_f_len is None:
              raise Exception(
                  "Please specify batch_offset and max_f_len when packing is \
                                      enabled"
              )
          my_batch_offset = batch_offset
          my_max_f_len = max_f_len
      else:
          my_batch_offset = self.dummy_batch_offset
          my_max_f_len = x.size(1)
      return TransducerLossFunc.apply(
          x,
          label,
          f_len,
          y_len,
          my_batch_offset,
          my_max_f_len,
          blank_idx,
          self.fuse_softmax_backward,
          debug_list,
          self.opt,
          self.packed_input,
      )
  
file_path: apex/apex/contrib/transducer/transducer.py
imports: import torch
  import transducer_loss_cuda
  import transducer_joint_cuda
label_desc: Use image node_id 2 for calling the TransducerLoss obj's underlying member method code with example usage: obj.forward(x, label, f_len, y_len, blank_idx, batch_offset, max_f_len, debug_list) and returns: TransducerLossFunc