class_docstr: Transducer joint
  Detail of this loss function can be found in: Sequence Transduction with Recurrent Neural 
  Networks
  
  Arguments:
      pack_output (bool, optional): whether to pack the output in a compact form with don't-care 
      data being removed. (default: False)
      relu (bool, optional): apply ReLU to the output of the joint operation. Requires opt=1  
      (default: False)
      dropout (bool, optional): apply dropout to the output of the joint operation. Requires opt=1  
      (default: False)
      opt (int, optional): pick the optimization level in [0, 1]. opt=1 picks a tiled algorithm. 
          (default: 1)
      fwd_tile_size (int, optional): tile size used in forward operation. This argument will be 
      ignored if opt != 1. (default: 4) 
      dropout_prob (float, optional): dropout probability. (default: 0.0)
      probe_mask (bool, optional): a flag used to probe the mask generated by ReLU and/or dropout
      operation. When this argument is set to True, the mask can be accessed through 
      self.mask_probe. (default: false)
class_docstr_tok: ["Transducer","joint","Detail","of","this","loss","function","can","be","found","in",":","Sequence","Transduction","with","Recurrent","Neural","Networks","Arguments",":","pack_output","(","bool",",","optional",")",":","whether","to","pack","the","output","in","a","compact","form","with","don't-care","data","being","removed",".","(","default",":","False",")","relu","(","bool",",","optional",")",":","apply","ReLU","to","the","output","of","the","joint","operation",".","Requires","opt=1","(","default",":","False",")","dropout","(","bool",",","optional",")",":","apply","dropout","to","the","output","of","the","joint","operation",".","Requires","opt=1","(","default",":","False",")","opt","(","int",",","optional",")",":","pick","the","optimization","level","in","[","0",",","1","]",".","opt=1","picks","a","tiled","algorithm",".","(","default",":","1",")","fwd_tile_size","(","int",",","optional",")",":","tile","size","used","in","forward","operation",".","This","argument","will","be","ignored","if","opt","!","=","1",".","(","default",":","4",")","dropout_prob","(","float",",","optional",")",":","dropout","probability",".","(","default",":","0.0",")","probe_mask","(","bool",",","optional",")",":","a","flag","used","to","probe","the","mask","generated","by","ReLU","and\/or","dropout","operation",".","When","this","argument","is","set","to","True",",","the","mask","can","be","accessed","through","self.mask_probe",".","(","default",":","false",")"]
docstr: Forward operation of transducer joint
  
  Arguments:
      f (tensor): transcription vector from encode block of shape (B, T, H).
      g (tensor): prediction vector form predict block of shape (B, U, H).
      f_len (tensor): length of transcription vector for each batch.
      g_len (tensor): length of prediction vector minus 1 for each batch.
      batch_offset (tensor, optional): tensor containing the offset of each batch
          in the results. For example, batch offset can be obtained from: 
          batch_offset = torch.cumsum(f_len*g_len, dim=0)
          This argument is required if pack_output == True, and is ignored if 
          pack_output == False. (default: None)
      packed_batch (int, optional): the batch size after packing. This argument is 
          ignored if pack_output == False. (default: 0)
docstr_tok: ["Forward","operation","of","transducer","joint","Arguments",":","f","(","tensor",")",":","transcription","vector","from","encode","block","of","shape","(","B",",","T",",","H",")",".","g","(","tensor",")",":","prediction","vector","form","predict","block","of","shape","(","B",",","U",",","H",")",".","f_len","(","tensor",")",":","length","of","transcription","vector","for","each","batch",".","g_len","(","tensor",")",":","length","of","prediction","vector","minus","1","for","each","batch",".","batch_offset","(","tensor",",","optional",")",":","tensor","containing","the","offset","of","each","batch","in","the","results",".","For","example",",","batch","offset","can","be","obtained","from",":","batch_offset","=","torch.cumsum","(","f_len","*","g_len",",","dim=0",")","This","argument","is","required","if","pack_output","==","True",",","and","is","ignored","if","pack_output","==","False",".","(","default",":","None",")","packed_batch","(","int",",","optional",")",":","the","batch","size","after","packing",".","This","argument","is","ignored","if","pack_output","==","False",".","(","default",":","0",")"]
code: def forward(
      self, f, g, f_len, g_len, batch_offset=None, packed_batch=0
  ):
      """Forward operation of transducer joint
  
      Arguments:
          f (tensor): transcription vector from encode block of shape (B, T, H).
          g (tensor): prediction vector form predict block of shape (B, U, H).
          f_len (tensor): length of transcription vector for each batch.
          g_len (tensor): length of prediction vector minus 1 for each batch.
          batch_offset (tensor, optional): tensor containing the offset of each batch
              in the results. For example, batch offset can be obtained from:
              batch_offset = torch.cumsum(f_len*g_len, dim=0)
              This argument is required if pack_output == True, and is ignored if
              pack_output == False. (default: None)
          packed_batch (int, optional): the batch size after packing. This argument is
              ignored if pack_output == False. (default: 0)
      """
      my_batch_offset = (
          batch_offset if self.pack_output else self.dummy_batch_offset
      )
      if self.pack_output and (
          batch_offset is None or packed_batch == 0
      ):
          raise Exception(
              "Please specify batch_offset and packed_batch when packing is enabled"
          )
      dropout = (
          self.dropout and self.training
      )  # only dropout for training
      return TransducerJointFunc.apply(
          f,
          g,
          f_len,
          g_len,
          self.pack_output,
          self.relu,
          dropout,
          my_batch_offset,
          packed_batch,
          self.opt,
          self.fwd_tile_size,
          self.dropout_prob,
          self.mask_probe,
      )
  
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 TransducerJoint obj's underlying member method code with example usage: obj.forward(f, g, f_len, g_len, batch_offset, packed_batch) and returns: TransducerJointFunc