class_docstr: CBHG module to convert log Mel-filterbanks to linear spectrogram.
  
  This is a module of CBHG introduced
  in `Tacotron: Towards End-to-End Speech Synthesis`_.
  The CBHG converts the sequence of log Mel-filterbanks into linear spectrogram.
  
  .. _`Tacotron: Towards End-to-End Speech Synthesis`:
       https://arxiv.org/abs/1703.10135
class_docstr_tok: ["CBHG","module","to","convert","log","Mel-filterbanks","to","linear","spectrogram",".","This","is","a","module","of","CBHG","introduced","in","`","Tacotron",":","Towards","End-to-End","Speech","Synthesis","`","_",".","The","CBHG","converts","the","sequence","of","log","Mel-filterbanks","into","linear","spectrogram",".","..","_","`","Tacotron",":","Towards","End-to-End","Speech","Synthesis","`",":","https",":","\/\/arxiv.org\/abs\/1703.10135"]
docstr: Calculate forward propagation.
  
  Args:
      xs (Tensor): Batch of the padded sequences of inputs (B, Tmax, idim).
      ilens (LongTensor): Batch of lengths of each input sequence (B,).
  
  Return:
      Tensor: Batch of the padded sequence of outputs (B, Tmax, odim).
      LongTensor: Batch of lengths of each output sequence (B,).
docstr_tok: ["Calculate","forward","propagation",".","Args",":","xs","(","Tensor",")",":","Batch","of","the","padded","sequences","of","inputs","(","B",",","Tmax",",","idim",")",".","ilens","(","LongTensor",")",":","Batch","of","lengths","of","each","input","sequence","(","B",",",")",".","Return",":","Tensor",":","Batch","of","the","padded","sequence","of","outputs","(","B",",","Tmax",",","odim",")",".","LongTensor",":","Batch","of","lengths","of","each","output","sequence","(","B",",",")","."]
code: def forward(self, xs, ilens):
      """Calculate forward propagation.
  
      Args:
          xs (Tensor): Batch of the padded sequences of inputs (B, Tmax, idim).
          ilens (LongTensor): Batch of lengths of each input sequence (B,).
  
      Return:
          Tensor: Batch of the padded sequence of outputs (B, Tmax, odim).
          LongTensor: Batch of lengths of each output sequence (B,).
  
      """
      xs = xs.transpose(1, 2)  # (B, idim, Tmax)
      convs = []
      for k in range(self.conv_bank_layers):
          convs += [self.conv_bank[k](xs)]
      convs = torch.cat(convs, dim=1)  # (B, #CH * #BANK, Tmax)
      convs = self.max_pool(convs)
      convs = self.projections(convs).transpose(1, 2)  # (B, Tmax, idim)
      xs = xs.transpose(1, 2) + convs
      # + 1 for dimension adjustment layer
      for i in range(self.highway_layers + 1):
          xs = self.highways[i](xs)
  
      # sort by length
      xs, ilens, sort_idx = self._sort_by_length(xs, ilens)
  
      # total_length needs for DataParallel
      # (see https://github.com/pytorch/pytorch/pull/6327)
      total_length = xs.size(1)
      if not isinstance(ilens, torch.Tensor):
          ilens = torch.tensor(ilens)
      xs = pack_padded_sequence(xs, ilens.cpu(), batch_first=True)
      self.gru.flatten_parameters()
      xs, _ = self.gru(xs)
      xs, ilens = pad_packed_sequence(
          xs, batch_first=True, total_length=total_length
      )
  
      # revert sorting by length
      xs, ilens = self._revert_sort_by_length(xs, ilens, sort_idx)
  
      xs = self.output(xs)  # (B, Tmax, odim)
  
      return xs, ilens
  
file_path: espnet/espnet/nets/pytorch_backend/tacotron2/cbhg.py
imports: import torch
  import torch.nn.functional
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
label_desc: Use image node_id 2 for calling the CBHG obj's underlying member method code with example usage: obj.forward(xs, ilens) and returns: xs,  ilens