class_docstr: General class to jointly train text2mel and vocoder parts.
docstr: Perform generator forward.
  
  Args:
      text (Tensor): Text index tensor (B, T_text).
      text_lengths (Tensor): Text length tensor (B,).
      feats (Tensor): Feature tensor (B, T_feats, aux_channels).
      feats_lengths (Tensor): Feature length tensor (B,).
      speech (Tensor): Speech waveform tensor (B, T_wav).
      speech_lengths (Tensor): Speech length tensor (B,).
      forward_generator (bool): Whether to forward generator.
  
  Returns:
      Dict[str, Any]:
          - loss (Tensor): Loss scalar tensor.
          - stats (Dict[str, float]): Statistics to be monitored.
          - weight (Tensor): Weight tensor to summarize losses.
          - optim_idx (int): Optimizer index (0 for G and 1 for D).
docstr_tok: ["Perform","generator","forward",".","Args",":","text","(","Tensor",")",":","Text","index","tensor","(","B",",","T_text",")",".","text_lengths","(","Tensor",")",":","Text","length","tensor","(","B",",",")",".","feats","(","Tensor",")",":","Feature","tensor","(","B",",","T_feats",",","aux_channels",")",".","feats_lengths","(","Tensor",")",":","Feature","length","tensor","(","B",",",")",".","speech","(","Tensor",")",":","Speech","waveform","tensor","(","B",",","T_wav",")",".","speech_lengths","(","Tensor",")",":","Speech","length","tensor","(","B",",",")",".","forward_generator","(","bool",")",":","Whether","to","forward","generator",".","Returns",":","Dict","[","str",",","Any","]",":","-","loss","(","Tensor",")",":","Loss","scalar","tensor",".","-","stats","(","Dict","[","str",",","float","]",")",":","Statistics","to","be","monitored",".","-","weight","(","Tensor",")",":","Weight","tensor","to","summarize","losses",".","-","optim_idx","(","int",")",":","Optimizer","index","(","0","for","G","and","1","for","D",")","."]
code: def forward(
      self,
      text: torch.Tensor,
      text_lengths: torch.Tensor,
      feats: torch.Tensor,
      feats_lengths: torch.Tensor,
      speech: torch.Tensor,
      speech_lengths: torch.Tensor,
      forward_generator: bool = True,
      **kwargs,
  ) -> Dict[str, Any]:
      """Perform generator forward.
  
      Args:
          text (Tensor): Text index tensor (B, T_text).
          text_lengths (Tensor): Text length tensor (B,).
          feats (Tensor): Feature tensor (B, T_feats, aux_channels).
          feats_lengths (Tensor): Feature length tensor (B,).
          speech (Tensor): Speech waveform tensor (B, T_wav).
          speech_lengths (Tensor): Speech length tensor (B,).
          forward_generator (bool): Whether to forward generator.
  
      Returns:
          Dict[str, Any]:
              - loss (Tensor): Loss scalar tensor.
              - stats (Dict[str, float]): Statistics to be monitored.
              - weight (Tensor): Weight tensor to summarize losses.
              - optim_idx (int): Optimizer index (0 for G and 1 for D).
  
      """
      if forward_generator:
          return self._forward_generator(
              text=text,
              text_lengths=text_lengths,
              feats=feats,
              feats_lengths=feats_lengths,
              speech=speech,
              speech_lengths=speech_lengths,
              **kwargs,
          )
      else:
          return self._forward_discrminator(
              text=text,
              text_lengths=text_lengths,
              feats=feats,
              feats_lengths=feats_lengths,
              speech=speech,
              speech_lengths=speech_lengths,
              **kwargs,
          )
  
imports: from typing import Any, Dict
  import torch
  from typeguard import check_argument_types
  from espnet2.gan_tts.abs_gan_tts import AbsGANTTS
  from espnet2.gan_tts.hifigan import HiFiGANGenerator, HiFiGANMultiPeriodDiscriminator, HiFiGANMultiScaleDiscriminator, HiFiGANMultiScaleMultiPeriodDiscriminator, HiFiGANPeriodDiscriminator, HiFiGANScaleDiscriminator
  from espnet2.gan_tts.hifigan.loss import DiscriminatorAdversarialLoss, FeatureMatchLoss, GeneratorAdversarialLoss, MelSpectrogramLoss
  from espnet2.gan_tts.melgan import MelGANGenerator, MelGANMultiScaleDiscriminator
  from espnet2.gan_tts.melgan.pqmf import PQMF
  from espnet2.gan_tts.parallel_wavegan import ParallelWaveGANDiscriminator, ParallelWaveGANGenerator
  from espnet2.gan_tts.style_melgan import StyleMelGANDiscriminator, StyleMelGANGenerator
  from espnet2.gan_tts.utils import get_random_segments, get_segments
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.tts.fastspeech import FastSpeech
  from espnet2.tts.fastspeech2 import FastSpeech2
  from espnet2.tts.tacotron2 import Tacotron2
  from espnet2.tts.transformer import Transformer
label_desc: Use image node_id 4 for calling the JointText2Wav obj's underlying member method code with example usage: obj.forward(text, text_lengths, feats, feats_lengths, speech, speech_lengths, forward_generator) and returns: self, self