class_docstr: JETS module (generator + discriminator).
  
  This is a module of JETS described in `JETS: Jointly Training FastSpeech2
  and HiFi-GAN for End to End Text to Speech'_.
  
  .. _`JETS: Jointly Training FastSpeech2 and HiFi-GAN for End to End Text to Speech`
      : https://arxiv.org/abs/2203.16852
class_docstr_tok: ["JETS","module","(","generator","+","discriminator",")",".","This","is","a","module","of","JETS","described","in","`","JETS",":","Jointly","Training","FastSpeech2","and","HiFi-GAN","for","End","to","End","Text","to","Speech","'","_",".","..","_","`","JETS",":","Jointly","Training","FastSpeech2","and","HiFi-GAN","for","End","to","End","Text","to","Speech","`",":","https",":","\/\/arxiv.org\/abs\/2203.16852"]
docstr: Run inference.
  
  Args:
      text (Tensor): Input text index tensor (T_text,).
      feats (Tensor): Feature tensor (T_feats, aux_channels).
      pitch (Tensor): Pitch tensor (T_feats, 1).
      energy (Tensor): Energy tensor (T_feats, 1).
      use_teacher_forcing (bool): Whether to use teacher forcing.
  
  Returns:
      Dict[str, Tensor]:
          * wav (Tensor): Generated waveform tensor (T_wav,).
          * duration (Tensor): Predicted duration tensor (T_text,).
docstr_tok: ["Run","inference",".","Args",":","text","(","Tensor",")",":","Input","text","index","tensor","(","T_text",",",")",".","feats","(","Tensor",")",":","Feature","tensor","(","T_feats",",","aux_channels",")",".","pitch","(","Tensor",")",":","Pitch","tensor","(","T_feats",",","1",")",".","energy","(","Tensor",")",":","Energy","tensor","(","T_feats",",","1",")",".","use_teacher_forcing","(","bool",")",":","Whether","to","use","teacher","forcing",".","Returns",":","Dict","[","str",",","Tensor","]",":","*","wav","(","Tensor",")",":","Generated","waveform","tensor","(","T_wav",",",")",".","*","duration","(","Tensor",")",":","Predicted","duration","tensor","(","T_text",",",")","."]
code: def inference(
      self,
      text: torch.Tensor,
      feats: Optional[torch.Tensor] = None,
      pitch: Optional[torch.Tensor] = None,
      energy: Optional[torch.Tensor] = None,
      use_teacher_forcing: bool = False,
      **kwargs,
  ) -> Dict[str, torch.Tensor]:
      """Run inference.
  
      Args:
          text (Tensor): Input text index tensor (T_text,).
          feats (Tensor): Feature tensor (T_feats, aux_channels).
          pitch (Tensor): Pitch tensor (T_feats, 1).
          energy (Tensor): Energy tensor (T_feats, 1).
          use_teacher_forcing (bool): Whether to use teacher forcing.
  
      Returns:
          Dict[str, Tensor]:
              * wav (Tensor): Generated waveform tensor (T_wav,).
              * duration (Tensor): Predicted duration tensor (T_text,).
  
      """
      # setup
      text = text[None]
      text_lengths = torch.tensor(
          [text.size(1)],
          dtype=torch.long,
          device=text.device,
      )
      if "spembs" in kwargs:
          kwargs["spembs"] = kwargs["spembs"][None]
      if self.use_gst and "speech" in kwargs:
          # NOTE(kan-bayashi): Workaround for the use of GST
          kwargs.pop("speech")
  
      # inference
      if use_teacher_forcing:
          assert feats is not None
          feats = feats[None]
          feats_lengths = torch.tensor(
              [feats.size(1)],
              dtype=torch.long,
              device=feats.device,
          )
          assert pitch is not None
          pitch = pitch[None]
          assert energy is not None
          energy = energy[None]
  
          wav, dur = self.generator.inference(
              text=text,
              text_lengths=text_lengths,
              feats=feats,
              feats_lengths=feats_lengths,
              pitch=pitch,
              energy=energy,
              use_teacher_forcing=use_teacher_forcing,
              **kwargs,
          )
      else:
          wav, dur = self.generator.inference(
              text=text,
              text_lengths=text_lengths,
              feats=feats[None] if self.use_gst else None,
              **kwargs,
          )
      return dict(wav=wav.view(-1), duration=dur[0])
  
file_path: espnet/espnet2/gan_tts/jets/jets.py
imports: from typing import Any, Dict, Optional
  import torch
  from typeguard import check_argument_types
  from espnet2.gan_tts.abs_gan_tts import AbsGANTTS
  from espnet2.gan_tts.hifigan import HiFiGANMultiPeriodDiscriminator, HiFiGANMultiScaleDiscriminator, HiFiGANMultiScaleMultiPeriodDiscriminator, HiFiGANPeriodDiscriminator, HiFiGANScaleDiscriminator
  from espnet2.gan_tts.hifigan.loss import DiscriminatorAdversarialLoss, FeatureMatchLoss, GeneratorAdversarialLoss, MelSpectrogramLoss
  from espnet2.gan_tts.jets.generator import JETSGenerator
  from espnet2.gan_tts.jets.loss import ForwardSumLoss, VarianceLoss
  from espnet2.gan_tts.utils import get_segments
  from espnet2.torch_utils.device_funcs import force_gatherable
label_desc: Use image node_id 7 for calling the JETS obj's underlying member method code with example usage: obj.inference(text, feats, pitch, energy, use_teacher_forcing) and returns: dict