class_docstr: ESPnet model for singing voice synthesis task.
class_docstr_tok: ["ESPnet","model","for","singing","voice","synthesis","task","."]
docstr: Caclualte features and return them as a dict.
  
  Args:
      text (Tensor): Text index tensor (B, T_text).
      text_lengths (Tensor): Text length tensor (B,).
      singing (Tensor): Singing waveform tensor (B, T_wav).
      singing_lengths (Tensor): Singing length tensor (B,).
      label (Option[Tensor]): Label tensor (B, T_label).
      label_lengths (Optional[Tensor]): Label lrngth tensor (B,).
      phn_cnt (Optional[Tensor]): Number of phones in each syllable (B, T_syb)
      midi (Option[Tensor]): Midi tensor (B, T_label).
      midi_lengths (Optional[Tensor]): Midi lrngth tensor (B,).
      ---- duration* is duration in time_shift ----
      duration_phn (Optional[Tensor]): duration tensor (B, T_label).
      duration_phn_lengths (Optional[Tensor]): duration length tensor (B,).
      duration_ruled_phn (Optional[Tensor]): duration tensor (B, T_phone).
      duration_ruled_phn_lengths (Optional[Tensor]): duration length tensor (B,).
      duration_syb (Optional[Tensor]): duration tensor (B, T_syb).
      duration_syb_lengths (Optional[Tensor]): duration length tensor (B,).
      slur (Optional[Tensor]): slur tensor (B, T_slur).
      slur_lengths (Optional[Tensor]): slur length tensor (B,).
      pitch (Optional[Tensor]): Pitch tensor (B, T_wav). - f0 sequence
      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).
  
  Returns:
      Dict[str, Tensor]: Dict of features.
docstr_tok: ["Caclualte","features","and","return","them","as","a","dict",".","Args",":","text","(","Tensor",")",":","Text","index","tensor","(","B",",","T_text",")",".","text_lengths","(","Tensor",")",":","Text","length","tensor","(","B",",",")",".","singing","(","Tensor",")",":","Singing","waveform","tensor","(","B",",","T_wav",")",".","singing_lengths","(","Tensor",")",":","Singing","length","tensor","(","B",",",")",".","label","(","Option","[","Tensor","]",")",":","Label","tensor","(","B",",","T_label",")",".","label_lengths","(","Optional","[","Tensor","]",")",":","Label","lrngth","tensor","(","B",",",")",".","phn_cnt","(","Optional","[","Tensor","]",")",":","Number","of","phones","in","each","syllable","(","B",",","T_syb",")","midi","(","Option","[","Tensor","]",")",":","Midi","tensor","(","B",",","T_label",")",".","midi_lengths","(","Optional","[","Tensor","]",")",":","Midi","lrngth","tensor","(","B",",",")",".","--","--","duration","*","is","duration","in","time_shift","--","--","duration_phn","(","Optional","[","Tensor","]",")",":","duration","tensor","(","B",",","T_label",")",".","duration_phn_lengths","(","Optional","[","Tensor","]",")",":","duration","length","tensor","(","B",",",")",".","duration_ruled_phn","(","Optional","[","Tensor","]",")",":","duration","tensor","(","B",",","T_phone",")",".","duration_ruled_phn_lengths","(","Optional","[","Tensor","]",")",":","duration","length","tensor","(","B",",",")",".","duration_syb","(","Optional","[","Tensor","]",")",":","duration","tensor","(","B",",","T_syb",")",".","duration_syb_lengths","(","Optional","[","Tensor","]",")",":","duration","length","tensor","(","B",",",")",".","slur","(","Optional","[","Tensor","]",")",":","slur","tensor","(","B",",","T_slur",")",".","slur_lengths","(","Optional","[","Tensor","]",")",":","slur","length","tensor","(","B",",",")",".","pitch","(","Optional","[","Tensor","]",")",":","Pitch","tensor","(","B",",","T_wav",")",".","-","f0","sequence","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",")",".","Returns",":","Dict","[","str",",","Tensor","]",":","Dict","of","features","."]
code: def collect_feats(
      self,
      text: torch.Tensor,
      text_lengths: torch.Tensor,
      singing: torch.Tensor,
      singing_lengths: torch.Tensor,
      label: Optional[torch.Tensor] = None,
      label_lengths: Optional[torch.Tensor] = None,
      phn_cnt: Optional[torch.Tensor] = None,
      midi: Optional[torch.Tensor] = None,
      midi_lengths: Optional[torch.Tensor] = None,
      duration_phn: Optional[torch.Tensor] = None,
      duration_phn_lengths: Optional[torch.Tensor] = None,
      duration_ruled_phn: Optional[torch.Tensor] = None,
      duration_ruled_phn_lengths: Optional[torch.Tensor] = None,
      duration_syb: Optional[torch.Tensor] = None,
      duration_syb_lengths: Optional[torch.Tensor] = None,
      slur: Optional[torch.Tensor] = None,
      slur_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,
      ying: Optional[torch.Tensor] = None,
      ying_lengths: Optional[torch.Tensor] = None,
      spembs: Optional[torch.Tensor] = None,
      sids: Optional[torch.Tensor] = None,
      lids: Optional[torch.Tensor] = None,
      **kwargs,
  ) -> Dict[str, torch.Tensor]:
      """Caclualte features and return them as a dict.
  
      Args:
          text (Tensor): Text index tensor (B, T_text).
          text_lengths (Tensor): Text length tensor (B,).
          singing (Tensor): Singing waveform tensor (B, T_wav).
          singing_lengths (Tensor): Singing length tensor (B,).
          label (Option[Tensor]): Label tensor (B, T_label).
          label_lengths (Optional[Tensor]): Label lrngth tensor (B,).
          phn_cnt (Optional[Tensor]): Number of phones in each syllable (B, T_syb)
          midi (Option[Tensor]): Midi tensor (B, T_label).
          midi_lengths (Optional[Tensor]): Midi lrngth tensor (B,).
          ---- duration* is duration in time_shift ----
          duration_phn (Optional[Tensor]): duration tensor (B, T_label).
          duration_phn_lengths (Optional[Tensor]): duration length tensor (B,).
          duration_ruled_phn (Optional[Tensor]): duration tensor (B, T_phone).
          duration_ruled_phn_lengths (Optional[Tensor]): duration length tensor (B,).
          duration_syb (Optional[Tensor]): duration tensor (B, T_syb).
          duration_syb_lengths (Optional[Tensor]): duration length tensor (B,).
          slur (Optional[Tensor]): slur tensor (B, T_slur).
          slur_lengths (Optional[Tensor]): slur length tensor (B,).
          pitch (Optional[Tensor]): Pitch tensor (B, T_wav). - f0 sequence
          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).
  
      Returns:
          Dict[str, Tensor]: Dict of features.
      """
      feats = None
      if self.feats_extract is not None:
          feats, feats_lengths = self.feats_extract(
              singing, singing_lengths
          )
      else:
          # Use precalculated feats (feats_type != raw case)
          feats, feats_lengths = singing, singing_lengths
      # cut length
      for i in range(feats.size(0)):
          dur_len = sum(duration_phn[i])
          if feats_lengths[i] > dur_len:
              feats_lengths[i] = dur_len
          else:  # decrease duration at the end of sequence
              delta = dur_len - feats_lengths[i]
              end = duration_phn_lengths[i] - 1
              while delta > 0 and end >= 0:
                  new = duration_phn[i][end] - delta
                  if new < 0:  # keep on decreasing the previous one
                      delta -= duration_phn[i][end]
                      duration_phn[i][end] = 0
                      end -= 1
                  else:  # stop
                      delta -= duration_phn[i][end] - new
                      duration_phn[i][end] = new
      feats = feats[:, : feats_lengths.max()]
  
      if self.pitch_extract is not None:
          pitch, pitch_lengths = self.pitch_extract(
              input=singing,
              input_lengths=singing_lengths,
              feats_lengths=feats_lengths,
          )
      if self.energy_extract is not None:
          energy, energy_lengths = self.energy_extract(
              singing,
              singing_lengths,
              feats_lengths=feats_lengths,
          )
      if self.ying_extract is not None and ying is None:
          ying, ying_lengths = self.ying_extract(
              singing,
              singing_lengths,
              feats_lengths=feats_lengths,
          )
  
      # store in dict
      feats_dict = {}
      if feats is not None:
          feats_dict.update(feats=feats, feats_lengths=feats_lengths)
      if pitch is not None:
          feats_dict.update(pitch=pitch, pitch_lengths=pitch_lengths)
      if energy is not None:
          feats_dict.update(
              energy=energy, energy_lengths=energy_lengths
          )
      if ying is not None:
          feats_dict.update(ying=ying, ying_lengths=ying_lengths)
  
      return feats_dict
  
file_path: espnet/espnet2/svs/espnet_model.py
imports: from contextlib import contextmanager
  from distutils.version import LooseVersion
  from typing import Dict, Optional, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.layers.inversible_interface import InversibleInterface
  from espnet2.svs.abs_svs import AbsSVS
  from espnet2.svs.feats_extract.score_feats_extract import FrameScoreFeats, SyllableScoreFeats, expand_to_frame
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract
label_desc: Use image node_id 3 for calling the ESPnetSVSModel obj's underlying member method code with example usage: obj.collect_feats(text, text_lengths, singing, singing_lengths, label, label_lengths, phn_cnt, midi, midi_lengths, duration_phn, duration_phn_lengths, duration_ruled_phn, duration_ruled_phn_lengths, duration_syb, duration_syb_lengths, slur, slur_lengths, pitch, pitch_lengths, energy, energy_lengths, ying, ying_lengths, spembs, sids, lids) and returns: feats_dict