code: def transducer_joint_reference(
      f,
      g,
      h_grad,
      f_len,
      g_len,
      pack_output,
      relu,
      dropout,
      dropout_prob=0,
      mask=None,
  ):
      if dropout and mask == None:
          raise NotImplementedError(
              "mask needs to supplied to test dropout."
          )
      B, T, H = f.size()
      U = g.size(1)
      f_expand = f.unsqueeze(dim=2)
      g_expand = g.unsqueeze(dim=1)
      h = f_expand + g_expand
      if relu:
          h = torch.nn.functional.relu(h)
      if dropout:
          h *= mask
          scale = 1 / (1 - dropout_prob)
          h *= scale
      h.backward(h_grad)
  
      if pack_output == False:
          # intentionally set don't-care region to -1 to test if transducer joint
          # write these regions to avoid NaN and inf
          for b in range(B):
              h[b, f_len[b] :] = -1
              h[b, :, g_len[b] :] = -1
  
          return h, f.grad, g.grad
  
      # packing
      list_to_pack = []
      for b in range(B):
          list_to_pack.append(
              h[b, : f_len[b], : g_len[b], :].reshape(-1, H)
          )
      h_packed = torch.cat(list_to_pack)
      return h_packed, f.grad, g.grad
  
label_desc: Use image node_id 2 for calling a global function with example usage: transducer_joint_reference(f, g, h_grad, f_len, g_len, pack_output, relu, dropout, dropout_prob, mask) and returns: h_packed,  f,  g, h,  f,  g