class_docstr: Length regulator module for feed-forward Transformer.
  
  This is a module of length regulator described in
  `FastSpeech: Fast, Robust and Controllable Text to Speech`_.
  The length regulator expands char or
  phoneme-level embedding features to frame-level by repeating each
  feature based on the corresponding predicted durations.
  
  .. _`FastSpeech: Fast, Robust and Controllable Text to Speech`:
      https://arxiv.org/pdf/1905.09263.pdf
docstr: Calculate forward propagation.
  
  Args:
      xs (Tensor): Batch of sequences of char or phoneme embeddings (B, Tmax, D).
      ds (LongTensor): Batch of durations of each frame (B, T).
      alpha (float, optional): Alpha value to control speed of speech.
  
  Returns:
      Tensor: replicated input tensor based on durations (B, T*, D).
docstr_tok: ["Calculate","forward","propagation",".","Args",":","xs","(","Tensor",")",":","Batch","of","sequences","of","char","or","phoneme","embeddings","(","B",",","Tmax",",","D",")",".","ds","(","LongTensor",")",":","Batch","of","durations","of","each","frame","(","B",",","T",")",".","alpha","(","float",",","optional",")",":","Alpha","value","to","control","speed","of","speech",".","Returns",":","Tensor",":","replicated","input","tensor","based","on","durations","(","B",",","T","*",",","D",")","."]
code: def forward(self, xs, ds, alpha=1.0):
      """Calculate forward propagation.
  
      Args:
          xs (Tensor): Batch of sequences of char or phoneme embeddings (B, Tmax, D).
          ds (LongTensor): Batch of durations of each frame (B, T).
          alpha (float, optional): Alpha value to control speed of speech.
  
      Returns:
          Tensor: replicated input tensor based on durations (B, T*, D).
  
      """
      if alpha != 1.0:
          assert alpha > 0
          ds = torch.round(ds.float() * alpha).long()
  
      if ds.sum() == 0:
          logging.warning(
              "predicted durations includes all 0 sequences. "
              "fill the first element with 1."
          )
          # NOTE(kan-bayashi): This case must not be happened in teacher forcing.
          #   It will be happened in inference with a bad duration predictor.
          #   So we do not need to care the padded sequence case here.
          ds[ds.sum(dim=1).eq(0)] = 1
  
      repeat = [
          torch.repeat_interleave(x, d, dim=0) for x, d in zip(xs, ds)
      ]
      return pad_list(repeat, self.pad_value)
  
imports: import logging
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 2 for calling the LengthRegulator obj's underlying member method code with example usage: obj.forward(xs, ds, alpha) and returns: pad_list