class_docstr: Encoder module of Spectrogram prediction network.
  
  This is a module of encoder of Spectrogram prediction network in Singing Tacotron,
  which described in `Singing-Tacotron: Global Duration Control Attention and Dynamic
  Filter for End-to-end Singing Voice Synthesis`_. This is the encoder which converts
  either a sequence of characters or acoustic features into the sequence of
  hidden states.
  
  .. _`Singing-Tacotron: Global Duration Control Attention and Dynamic
  Filter for End-to-end Singing Voice Synthesis`:
     https://arxiv.org/abs/2202.07907
class_docstr_tok: ["Encoder","module","of","Spectrogram","prediction","network",".","This","is","a","module","of","encoder","of","Spectrogram","prediction","network","in","Singing","Tacotron",",","which","described","in","`","Singing-Tacotron",":","Global","Duration","Control","Attention","and","Dynamic","Filter","for","End-to-end","Singing","Voice","Synthesis","`","_",".","This","is","the","encoder","which","converts","either","a","sequence","of","characters","or","acoustic","features","into","the","sequence","of","hidden","states",".","..","_","`","Singing-Tacotron",":","Global","Duration","Control","Attention","and","Dynamic","Filter","for","End-to-end","Singing","Voice","Synthesis","`",":","https",":","\/\/arxiv.org\/abs\/2202.07907"]
docstr: Calculate forward propagation.
  
  Args:
      xs (Tensor): Batch of the padded sequence. Either character ids (B, Tmax)
          or acoustic feature (B, Tmax, idim * encoder_reduction_factor). Padded
          value should be 0.
      ilens (LongTensor): Batch of lengths of each input batch (B,).
  
  Returns:
      Tensor: Batch of the sequences of encoder states(B, Tmax, eunits).
      LongTensor: Batch of lengths of each sequence (B,)
docstr_tok: ["Calculate","forward","propagation",".","Args",":","xs","(","Tensor",")",":","Batch","of","the","padded","sequence",".","Either","character","ids","(","B",",","Tmax",")","or","acoustic","feature","(","B",",","Tmax",",","idim","*","encoder_reduction_factor",")",".","Padded","value","should","be","0.","ilens","(","LongTensor",")",":","Batch","of","lengths","of","each","input","batch","(","B",",",")",".","Returns",":","Tensor",":","Batch","of","the","sequences","of","encoder","states","(","B",",","Tmax",",","eunits",")",".","LongTensor",":","Batch","of","lengths","of","each","sequence","(","B",",",")"]
code: def forward(self, xs, ilens=None):
      """Calculate forward propagation.
  
      Args:
          xs (Tensor): Batch of the padded sequence. Either character ids (B, Tmax)
              or acoustic feature (B, Tmax, idim * encoder_reduction_factor). Padded
              value should be 0.
          ilens (LongTensor): Batch of lengths of each input batch (B,).
  
      Returns:
          Tensor: Batch of the sequences of encoder states(B, Tmax, eunits).
          LongTensor: Batch of lengths of each sequence (B,)
  
      """
      xs = xs.transpose(1, 2)
      if self.convs is not None:
          for i in range(len(self.convs)):
              if self.use_residual:
                  xs = xs + self.convs[i](xs)
              else:
                  xs = self.convs[i](xs)
      if self.blstm is None:
          return xs.transpose(1, 2)
      if not isinstance(ilens, torch.Tensor):
          ilens = torch.tensor(ilens)
      xs = pack_padded_sequence(
          xs.transpose(1, 2),
          ilens.cpu(),
          batch_first=True,
          enforce_sorted=False,
      )
      self.blstm.flatten_parameters()
      xs, _ = self.blstm(xs)  # (B, Tmax, C)
      xs, hlens = pad_packed_sequence(xs, batch_first=True)
  
      return xs, hlens
  
file_path: espnet/espnet2/svs/singing_tacotron/encoder.py
imports: import torch
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.forward(xs, ilens) and returns: xs,  hlens, xs