class_docstr: VITS module (generator + discriminator).
  
  This is a module of VITS described in `Conditional Variational Autoencoder
  with Adversarial Learning for End-to-End Text-to-Speech`_.
  
  .. _`Conditional Variational Autoencoder with Adversarial Learning for End-to-End
      Text-to-Speech`: https://arxiv.org/abs/2006.04558
docstr: Run inference.
  
  Args:
      text (Tensor): Input text index tensor (T_text,).
      feats (Tensor): Feature tensor (T_feats, aux_channels).
      label (Optional[Dict]): key is "lab" or "score";
          value (LongTensor): Batch of padded label ids (B, T_text).
      melody (Optional[Dict]): key is "lab" or "score";
          value (LongTensor): Batch of padded melody (B, T_text).
      pitch (FloatTensor): Batch of padded f0 (B, T_feats).
      slur (LongTensor): Batch of padded slur (B, T_text).
      sids (Tensor): Speaker index tensor (1,).
      spembs (Optional[Tensor]): Speaker embedding tensor (spk_embed_dim,).
      lids (Tensor): Language index tensor (1,).
      noise_scale (float): Noise scale value for flow.
      noise_scale_dur (float): Noise scale value for duration predictor.
      alpha (float): Alpha parameter to control the speed of generated singing.
      max_len (Optional[int]): Maximum length.
      use_teacher_forcing (bool): Whether to use teacher forcing.
      duration (Optional[Dict]): key is "lab", "score_phn" or "score_syb";
          value (LongTensor): Batch of padded duration (B, T_text).
  
  Returns:
      Dict[str, Tensor]:
          * wav (Tensor): Generated waveform tensor (T_wav,).
docstr_tok: ["Run","inference",".","Args",":","text","(","Tensor",")",":","Input","text","index","tensor","(","T_text",",",")",".","feats","(","Tensor",")",":","Feature","tensor","(","T_feats",",","aux_channels",")",".","label","(","Optional","[","Dict","]",")",":","key","is","``","lab","''","or","``","score","''",";","value","(","LongTensor",")",":","Batch","of","padded","label","ids","(","B",",","T_text",")",".","melody","(","Optional","[","Dict","]",")",":","key","is","``","lab","''","or","``","score","''",";","value","(","LongTensor",")",":","Batch","of","padded","melody","(","B",",","T_text",")",".","pitch","(","FloatTensor",")",":","Batch","of","padded","f0","(","B",",","T_feats",")",".","slur","(","LongTensor",")",":","Batch","of","padded","slur","(","B",",","T_text",")",".","sids","(","Tensor",")",":","Speaker","index","tensor","(","1",",",")",".","spembs","(","Optional","[","Tensor","]",")",":","Speaker","embedding","tensor","(","spk_embed_dim",",",")",".","lids","(","Tensor",")",":","Language","index","tensor","(","1",",",")",".","noise_scale","(","float",")",":","Noise","scale","value","for","flow",".","noise_scale_dur","(","float",")",":","Noise","scale","value","for","duration","predictor",".","alpha","(","float",")",":","Alpha","parameter","to","control","the","speed","of","generated","singing",".","max_len","(","Optional","[","int","]",")",":","Maximum","length",".","use_teacher_forcing","(","bool",")",":","Whether","to","use","teacher","forcing",".","duration","(","Optional","[","Dict","]",")",":","key","is","``","lab","''",",","``","score_phn","''","or","``","score_syb","''",";","value","(","LongTensor",")",":","Batch","of","padded","duration","(","B",",","T_text",")",".","Returns",":","Dict","[","str",",","Tensor","]",":","*","wav","(","Tensor",")",":","Generated","waveform","tensor","(","T_wav",",",")","."]
code: def inference(
      self,
      text: torch.Tensor,
      feats: Optional[torch.Tensor] = None,
      label: Optional[Dict[str, torch.Tensor]] = None,
      melody: Optional[Dict[str, torch.Tensor]] = None,
      pitch: Optional[torch.Tensor] = None,
      duration: Optional[Dict[str, torch.Tensor]] = None,
      slur: Optional[Dict[str, torch.Tensor]] = None,
      spembs: Optional[torch.Tensor] = None,
      sids: Optional[torch.Tensor] = None,
      lids: Optional[torch.Tensor] = None,
      noise_scale: float = 0.667,
      noise_scale_dur: float = 0.8,
      alpha: float = 1.0,
      max_len: Optional[int] = None,
      use_teacher_forcing: bool = False,
  ) -> Dict[str, torch.Tensor]:
      """Run inference.
  
      Args:
          text (Tensor): Input text index tensor (T_text,).
          feats (Tensor): Feature tensor (T_feats, aux_channels).
          label (Optional[Dict]): key is "lab" or "score";
              value (LongTensor): Batch of padded label ids (B, T_text).
          melody (Optional[Dict]): key is "lab" or "score";
              value (LongTensor): Batch of padded melody (B, T_text).
          pitch (FloatTensor): Batch of padded f0 (B, T_feats).
          slur (LongTensor): Batch of padded slur (B, T_text).
          sids (Tensor): Speaker index tensor (1,).
          spembs (Optional[Tensor]): Speaker embedding tensor (spk_embed_dim,).
          lids (Tensor): Language index tensor (1,).
          noise_scale (float): Noise scale value for flow.
          noise_scale_dur (float): Noise scale value for duration predictor.
          alpha (float): Alpha parameter to control the speed of generated singing.
          max_len (Optional[int]): Maximum length.
          use_teacher_forcing (bool): Whether to use teacher forcing.
          duration (Optional[Dict]): key is "lab", "score_phn" or "score_syb";
              value (LongTensor): Batch of padded duration (B, T_text).
  
      Returns:
          Dict[str, Tensor]:
              * wav (Tensor): Generated waveform tensor (T_wav,).
  
      """
      # setup
      label = label["lab"]
      melody = melody["lab"]
      score_dur = duration["score_syb"]
      gt_dur = duration["lab"]
      text = text[None]
      text_lengths = torch.tensor(
          [text.size(1)],
          dtype=torch.long,
          device=text.device,
      )
      label_lengths = torch.tensor(
          [label.size(1)],
          dtype=torch.long,
          device=text.device,
      )
  
      if sids is not None:
          sids = sids.view(1)
      if lids is not None:
          lids = lids.view(1)
  
      # inference
      if use_teacher_forcing:
          assert feats is not None
          assert pitch is not None
          feats = feats[None].transpose(1, 2)
          feats_lengths = torch.tensor(
              [feats.size(2)],
              dtype=torch.long,
              device=feats.device,
          )
          wav = self.generator.inference(
              text=text,
              text_lengths=text_lengths,
              feats=feats,
              feats_lengths=feats_lengths,
              label=label,
              label_lengths=label_lengths,
              melody=melody,
              score_dur=score_dur,
              slur=slur,
              gt_dur=gt_dur,
              pitch=pitch,
              sids=sids,
              spembs=spembs,
              lids=lids,
              noise_scale=noise_scale,
              noise_scale_dur=noise_scale_dur,
              alpha=alpha,
              max_len=max_len,
              use_teacher_forcing=use_teacher_forcing,
          )
      else:
          wav = self.generator.inference(
              text=text,
              text_lengths=text_lengths,
              label=label,
              label_lengths=label_lengths,
              melody=melody,
              score_dur=score_dur,
              slur=slur,
              sids=sids,
              spembs=spembs,
              lids=lids,
              noise_scale=noise_scale,
              noise_scale_dur=noise_scale_dur,
              alpha=alpha,
              max_len=max_len,
          )
      return dict(wav=wav.view(-1))
  
imports: from contextlib import contextmanager
  from distutils.version import LooseVersion
  from typing import Any, Dict, Optional
  import torch
  from torch.nn import functional
  from typeguard import check_argument_types
  from espnet2.gan_svs.abs_gan_svs import AbsGANSVS
  from espnet2.gan_svs.avocodo.avocodo import SBD, AvocodoDiscriminator, AvocodoDiscriminatorPlus, CoMBD
  from espnet2.gan_svs.visinger2.visinger2_vocoder import VISinger2Discriminator
  from espnet2.gan_svs.vits.generator import VISingerGenerator
  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.utils import get_segments
  from espnet2.gan_tts.vits.loss import KLDivergenceLoss, KLDivergenceLossWithoutFlow
  from espnet2.torch_utils.device_funcs import force_gatherable
label_desc: Use image node_id 7 for calling the VITS obj's underlying member method code with example usage: obj.inference(text, feats, label, melody, pitch, duration, slur, spembs, sids, lids, noise_scale, noise_scale_dur, alpha, max_len, use_teacher_forcing) and returns: dict