class_docstr: FastSpeech module for end-to-end text-to-speech.
  
  This is a module of FastSpeech, feed-forward Transformer with duration predictor
  described in `FastSpeech: Fast, Robust and Controllable Text to Speech`_, which
  does not require any auto-regressive processing during inference, resulting in
  fast decoding compared with auto-regressive Transformer.
  
  .. _`FastSpeech: Fast, Robust and Controllable Text to Speech`:
      https://arxiv.org/pdf/1905.09263.pdf
class_docstr_tok: ["FastSpeech","module","for","end-to-end","text-to-speech",".","This","is","a","module","of","FastSpeech",",","feed-forward","Transformer","with","duration","predictor","described","in","`","FastSpeech",":","Fast",",","Robust","and","Controllable","Text","to","Speech","`","_",",","which","does","not","require","any","auto-regressive","processing","during","inference",",","resulting","in","fast","decoding","compared","with","auto-regressive","Transformer",".","..","_","`","FastSpeech",":","Fast",",","Robust","and","Controllable","Text","to","Speech","`",":","https",":","\/\/arxiv.org\/pdf\/1905.09263.pdf"]
code: def _forward(
      self,
      xs: torch.Tensor,
      ilens: torch.Tensor,
      ys: Optional[torch.Tensor] = None,
      olens: Optional[torch.Tensor] = None,
      ds: Optional[torch.Tensor] = None,
      spembs: Optional[torch.Tensor] = None,
      sids: Optional[torch.Tensor] = None,
      lids: Optional[torch.Tensor] = None,
      is_inference: bool = False,
      alpha: float = 1.0,
  ) -> Sequence[torch.Tensor]:
      # forward encoder
      x_masks = self._source_mask(ilens)
      hs, _ = self.encoder(xs, x_masks)  # (B, T_text, adim)
  
      # integrate with GST
      if self.use_gst:
          style_embs = self.gst(ys)
          hs = hs + style_embs.unsqueeze(1)
  
      # integrate with SID and LID embeddings
      if self.spks is not None:
          sid_embs = self.sid_emb(sids.view(-1))
          hs = hs + sid_embs.unsqueeze(1)
      if self.langs is not None:
          lid_embs = self.lid_emb(lids.view(-1))
          hs = hs + lid_embs.unsqueeze(1)
  
      # integrate speaker embedding
      if self.spk_embed_dim is not None:
          hs = self._integrate_with_spk_embed(hs, spembs)
  
      # forward duration predictor and length regulator
      d_masks = make_pad_mask(ilens).to(xs.device)
      if is_inference:
          d_outs = self.duration_predictor.inference(
              hs, d_masks
          )  # (B, T_text)
          hs = self.length_regulator(
              hs, d_outs, alpha
          )  # (B, T_feats, adim)
      else:
          d_outs = self.duration_predictor(hs, d_masks)  # (B, T_text)
          hs = self.length_regulator(hs, ds)  # (B, T_feats, adim)
  
      # forward decoder
      if olens is not None and not is_inference:
          if self.reduction_factor > 1:
              olens_in = olens.new(
                  [
                      torch.div(
                          olen,
                          self.reduction_factor,
                          rounding_mode="trunc",
                      )
                      for olen in olens
                  ]
              )
          else:
              olens_in = olens
          h_masks = self._source_mask(olens_in)
      else:
          h_masks = None
      zs, _ = self.decoder(hs, h_masks)  # (B, T_feats, adim)
      before_outs = self.feat_out(zs).view(
          zs.size(0), -1, self.odim
      )  # (B, T_feats, odim)
  
      # postnet -> (B, T_feats//r * r, odim)
      if self.postnet is None:
          after_outs = before_outs
      else:
          after_outs = before_outs + self.postnet(
              before_outs.transpose(1, 2)
          ).transpose(1, 2)
  
      return before_outs, after_outs, d_outs
  
imports: import logging
  from typing import Dict, Optional, Sequence, Tuple
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.torch_utils.initialize import initialize
  from espnet2.tts.abs_tts import AbsTTS
  from espnet2.tts.gst.style_encoder import StyleEncoder
  from espnet.nets.pytorch_backend.conformer.encoder import Encoder
  from espnet.nets.pytorch_backend.e2e_tts_fastspeech import FeedForwardTransformerLoss
  from espnet.nets.pytorch_backend.fastspeech.duration_predictor import DurationPredictor
  from espnet.nets.pytorch_backend.fastspeech.length_regulator import LengthRegulator
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask, make_pad_mask
  from espnet.nets.pytorch_backend.tacotron2.decoder import Postnet
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding, ScaledPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
label_desc: Use image node_id 2 for calling the FastSpeech obj's underlying member method code with example usage: obj._forward(xs, ilens, ys, olens, ds, spembs, sids, lids, is_inference, alpha) and returns: before_outs,  after_outs,  d_outs