class_docstr: ESPnet model for text-to-speech task.
docstr: Caclualte outputs and return the loss tensor.
  
  Args:
      text (Tensor): Text index tensor (B, T_text).
      text_lengths (Tensor): Text length tensor (B,).
      speech (Tensor): Speech waveform tensor (B, T_wav).
      speech_lengths (Tensor): Speech length tensor (B,).
      duration (Optional[Tensor]): Duration tensor.
      duration_lengths (Optional[Tensor]): Duration length tensor (B,).
      pitch (Optional[Tensor]): Pitch tensor.
      pitch_lengths (Optional[Tensor]): Pitch length tensor (B,).
      energy (Optional[Tensor]): Energy tensor.
      energy_lengths (Optional[Tensor]): Energy length tensor (B,).
      spembs (Optional[Tensor]): Speaker embedding tensor (B, D).
      sids (Optional[Tensor]): Speaker ID tensor (B, 1).
      lids (Optional[Tensor]): Language ID tensor (B, 1).
      kwargs: "utt_id" is among the input.
  
  Returns:
      Tensor: Loss scalar tensor.
      Dict[str, float]: Statistics to be monitored.
      Tensor: Weight tensor to summarize losses.
docstr_tok: ["Caclualte","outputs","and","return","the","loss","tensor",".","Args",":","text","(","Tensor",")",":","Text","index","tensor","(","B",",","T_text",")",".","text_lengths","(","Tensor",")",":","Text","length","tensor","(","B",",",")",".","speech","(","Tensor",")",":","Speech","waveform","tensor","(","B",",","T_wav",")",".","speech_lengths","(","Tensor",")",":","Speech","length","tensor","(","B",",",")",".","duration","(","Optional","[","Tensor","]",")",":","Duration","tensor",".","duration_lengths","(","Optional","[","Tensor","]",")",":","Duration","length","tensor","(","B",",",")",".","pitch","(","Optional","[","Tensor","]",")",":","Pitch","tensor",".","pitch_lengths","(","Optional","[","Tensor","]",")",":","Pitch","length","tensor","(","B",",",")",".","energy","(","Optional","[","Tensor","]",")",":","Energy","tensor",".","energy_lengths","(","Optional","[","Tensor","]",")",":","Energy","length","tensor","(","B",",",")",".","spembs","(","Optional","[","Tensor","]",")",":","Speaker","embedding","tensor","(","B",",","D",")",".","sids","(","Optional","[","Tensor","]",")",":","Speaker","ID","tensor","(","B",",","1",")",".","lids","(","Optional","[","Tensor","]",")",":","Language","ID","tensor","(","B",",","1",")",".","kwargs",":","``","utt_id","''","is","among","the","input",".","Returns",":","Tensor",":","Loss","scalar","tensor",".","Dict","[","str",",","float","]",":","Statistics","to","be","monitored",".","Tensor",":","Weight","tensor","to","summarize","losses","."]
code: def forward(
      self,
      text: torch.Tensor,
      text_lengths: torch.Tensor,
      speech: torch.Tensor,
      speech_lengths: torch.Tensor,
      durations: Optional[torch.Tensor] = None,
      durations_lengths: Optional[torch.Tensor] = None,
      pitch: Optional[torch.Tensor] = None,
      pitch_lengths: Optional[torch.Tensor] = None,
      energy: Optional[torch.Tensor] = None,
      energy_lengths: Optional[torch.Tensor] = None,
      spembs: Optional[torch.Tensor] = None,
      sids: Optional[torch.Tensor] = None,
      lids: Optional[torch.Tensor] = None,
      **kwargs,
  ) -> Tuple[torch.Tensor, Dict[str, torch.Tensor], torch.Tensor]:
      """Caclualte outputs and return the loss tensor.
  
      Args:
          text (Tensor): Text index tensor (B, T_text).
          text_lengths (Tensor): Text length tensor (B,).
          speech (Tensor): Speech waveform tensor (B, T_wav).
          speech_lengths (Tensor): Speech length tensor (B,).
          duration (Optional[Tensor]): Duration tensor.
          duration_lengths (Optional[Tensor]): Duration length tensor (B,).
          pitch (Optional[Tensor]): Pitch tensor.
          pitch_lengths (Optional[Tensor]): Pitch length tensor (B,).
          energy (Optional[Tensor]): Energy tensor.
          energy_lengths (Optional[Tensor]): Energy length tensor (B,).
          spembs (Optional[Tensor]): Speaker embedding tensor (B, D).
          sids (Optional[Tensor]): Speaker ID tensor (B, 1).
          lids (Optional[Tensor]): Language ID tensor (B, 1).
          kwargs: "utt_id" is among the input.
  
      Returns:
          Tensor: Loss scalar tensor.
          Dict[str, float]: Statistics to be monitored.
          Tensor: Weight tensor to summarize losses.
  
      """
      with autocast(False):
          # Extract features
          if self.feats_extract is not None:
              feats, feats_lengths = self.feats_extract(
                  speech, speech_lengths
              )
          else:
              # Use precalculated feats (feats_type != raw case)
              feats, feats_lengths = speech, speech_lengths
  
          # Extract auxiliary features
          if self.pitch_extract is not None and pitch is None:
              pitch, pitch_lengths = self.pitch_extract(
                  speech,
                  speech_lengths,
                  feats_lengths=feats_lengths,
                  durations=durations,
                  durations_lengths=durations_lengths,
              )
          if self.energy_extract is not None and energy is None:
              energy, energy_lengths = self.energy_extract(
                  speech,
                  speech_lengths,
                  feats_lengths=feats_lengths,
                  durations=durations,
                  durations_lengths=durations_lengths,
              )
  
          # Normalize
          if self.normalize is not None:
              feats, feats_lengths = self.normalize(
                  feats, feats_lengths
              )
          if self.pitch_normalize is not None:
              pitch, pitch_lengths = self.pitch_normalize(
                  pitch, pitch_lengths
              )
          if self.energy_normalize is not None:
              energy, energy_lengths = self.energy_normalize(
                  energy, energy_lengths
              )
  
      # Make batch for tts inputs
      batch = dict(
          text=text,
          text_lengths=text_lengths,
          feats=feats,
          feats_lengths=feats_lengths,
      )
  
      # Update batch for additional auxiliary inputs
      if spembs is not None:
          batch.update(spembs=spembs)
      if sids is not None:
          batch.update(sids=sids)
      if lids is not None:
          batch.update(lids=lids)
      if durations is not None:
          batch.update(
              durations=durations, durations_lengths=durations_lengths
          )
      if self.pitch_extract is not None and pitch is not None:
          batch.update(pitch=pitch, pitch_lengths=pitch_lengths)
      if self.energy_extract is not None and energy is not None:
          batch.update(energy=energy, energy_lengths=energy_lengths)
      if self.tts.require_raw_speech:
          batch.update(speech=speech, speech_lengths=speech_lengths)
  
      return self.tts(**batch)
  
file_path: espnet/espnet2/tts/espnet_model.py
imports: from contextlib import contextmanager
  from typing import Dict, Optional, Tuple
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.layers.inversible_interface import InversibleInterface
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet2.tts.abs_tts import AbsTTS
  from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract
label_desc: Use image node_id 2 for calling the ESPnetTTSModel obj's underlying member method code with example usage: obj.forward(text, text_lengths, speech, speech_lengths, durations, durations_lengths, pitch, pitch_lengths, energy, energy_lengths, spembs, sids, lids) and returns: self