class_docstr: Transducer tasks module.
docstr: Compute auxiliary Transducer loss and Jensen-Shannon divergence loss.
  
  Args:
      aux_enc_out: Encoder auxiliary output sequences. [N x (B, T_aux, D_enc_aux)]
      dec_out: Decoder output sequences. (B, U, D_dec)
      joint_out: Joint output sequences. (B, T, U, D_joint)
      target: Target character ID sequences. (B, L)
      aux_t_len: Auxiliary time lengths. [N x (B,)]
      u_len: True U lengths. (B,)
  
  Returns:
     : Auxiliary Transducer loss and KL divergence loss values.
docstr_tok: ["Compute","auxiliary","Transducer","loss","and","Jensen-Shannon","divergence","loss",".","Args",":","aux_enc_out",":","Encoder","auxiliary","output","sequences",".","[","N","x","(","B",",","T_aux",",","D_enc_aux",")","]","dec_out",":","Decoder","output","sequences",".","(","B",",","U",",","D_dec",")","joint_out",":","Joint","output","sequences",".","(","B",",","T",",","U",",","D_joint",")","target",":","Target","character","ID","sequences",".","(","B",",","L",")","aux_t_len",":","Auxiliary","time","lengths",".","[","N","x","(","B",",",")","]","u_len",":","True","U","lengths",".","(","B",",",")","Returns",":",":","Auxiliary","Transducer","loss","and","KL","divergence","loss","values","."]
code: def compute_aux_transducer_and_symm_kl_div_losses(
      self,
      aux_enc_out: torch.Tensor,
      dec_out: torch.Tensor,
      joint_out: torch.Tensor,
      target: torch.Tensor,
      aux_t_len: torch.Tensor,
      u_len: torch.Tensor,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Compute auxiliary Transducer loss and Jensen-Shannon divergence loss.
  
      Args:
          aux_enc_out: Encoder auxiliary output sequences. [N x (B, T_aux, D_enc_aux)]
          dec_out: Decoder output sequences. (B, U, D_dec)
          joint_out: Joint output sequences. (B, T, U, D_joint)
          target: Target character ID sequences. (B, L)
          aux_t_len: Auxiliary time lengths. [N x (B,)]
          u_len: True U lengths. (B,)
  
      Returns:
         : Auxiliary Transducer loss and KL divergence loss values.
  
      """
      aux_trans_loss = 0
      symm_kl_div_loss = 0
  
      num_aux_layers = len(aux_enc_out)
      B, T, U, D = joint_out.shape
  
      for p in self.joint_network.parameters():
          p.requires_grad = False
  
      for i, aux_enc_out_i in enumerate(aux_enc_out):
          aux_mlp = self.mlp(aux_enc_out_i)
  
          aux_joint_out = self.joint_network(
              aux_mlp.unsqueeze(2),
              dec_out.unsqueeze(1),
              is_aux=True,
          )
  
          if self.use_aux_transducer_loss:
              aux_trans_loss += (
                  self.transducer_loss(
                      aux_joint_out,
                      target,
                      aux_t_len[i],
                      u_len,
                  )
                  / B
              )
  
          if self.use_symm_kl_div_loss:
              denom = B * T * U
  
              kl_main_aux = (
                  self.kl_div(
                      torch.log_softmax(joint_out, dim=-1),
                      torch.softmax(aux_joint_out, dim=-1),
                  )
                  / denom
              )
  
              kl_aux_main = (
                  self.kl_div(
                      torch.log_softmax(aux_joint_out, dim=-1),
                      torch.softmax(joint_out, dim=-1),
                  )
                  / denom
              )
  
              symm_kl_div_loss += kl_main_aux + kl_aux_main
  
      for p in self.joint_network.parameters():
          p.requires_grad = True
  
      aux_trans_loss /= num_aux_layers
  
      if self.use_symm_kl_div_loss:
          symm_kl_div_loss /= num_aux_layers
  
      return aux_trans_loss, symm_kl_div_loss
  
file_path: espnet/espnet/nets/pytorch_backend/transducer/transducer_tasks.py
imports: from typing import Any, List, Optional, Tuple
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
  from espnet.nets.pytorch_backend.transducer.joint_network import JointNetwork
  from espnet.nets.pytorch_backend.transformer.label_smoothing_loss import LabelSmoothingLoss
label_desc: Use image node_id 4 for calling the TransducerTasks obj's underlying member method code with example usage: obj.compute_aux_transducer_and_symm_kl_div_losses(aux_enc_out, dec_out, joint_out, target, aux_t_len, u_len) and returns: aux_trans_loss,  symm_kl_div_loss