class_docstr: XiaoiceSing module for Singing Voice Synthesis.
  
  This is a module of XiaoiceSing. A high-quality singing voice synthesis system which
  employs an integrated network for spectrum, F0 and duration modeling. It follows the
  main architecture of FastSpeech while proposing some singing-specific design:
      1) Add features from musical score (e.g.note pitch and length)
      2) Add a residual connection in F0 prediction to attenuate off-key issues
      3) The duration of all the phonemes in a musical note is accumulated to
      calculate the syllable duration loss for rhythm enhancement (syllable loss)
  .. _`XiaoiceSing: A High-Quality and Integrated Singing Voice Synthesis System`:
      https://arxiv.org/pdf/2006.06261.pdf
docstr: Initialize XiaoiceSing module.
  
  Args:
      idim (int): Dimension of the label inputs.
      odim (int): Dimension of the outputs.
      midi_dim (int): Dimension of the midi inputs.
      duration_dim (int): Dimension of the duration inputs.
      elayers (int): Number of encoder layers.
      eunits (int): Number of encoder hidden units.
      dlayers (int): Number of decoder layers.
      dunits (int): Number of decoder hidden units.
      postnet_layers (int): Number of postnet layers.
      postnet_chans (int): Number of postnet channels.
      postnet_filts (int): Kernel size of postnet.
      postnet_dropout_rate (float): Dropout rate in postnet.
      use_scaled_pos_enc (bool): Whether to use trainable scaled pos encoding.
      use_batch_norm (bool): Whether to use batch normalization in encoder prenet.
      encoder_normalize_before (bool): Whether to apply layernorm layer before
          encoder block.
      decoder_normalize_before (bool): Whether to apply layernorm layer before
          decoder block.
      encoder_concat_after (bool): Whether to concatenate attention layer's input
          and output in encoder.
      decoder_concat_after (bool): Whether to concatenate attention layer's input
          and output in decoder.
      duration_predictor_layers (int): Number of duration predictor layers.
      duration_predictor_chans (int): Number of duration predictor channels.
      duration_predictor_kernel_size (int): Kernel size of duration predictor.
      duration_predictor_dropout_rate (float): Dropout rate in duration predictor.
      reduction_factor (int): Reduction factor.
      encoder_type (str): Encoder type ("transformer" or "conformer").
      decoder_type (str): Decoder type ("transformer" or "conformer").
      transformer_enc_dropout_rate (float): Dropout rate in encoder except
          attention and positional encoding.
      transformer_enc_positional_dropout_rate (float): Dropout rate after encoder
          positional encoding.
      transformer_enc_attn_dropout_rate (float): Dropout rate in encoder
          self-attention module.
      transformer_dec_dropout_rate (float): Dropout rate in decoder except
          attention & positional encoding.
      transformer_dec_positional_dropout_rate (float): Dropout rate after decoder
          positional encoding.
      transformer_dec_attn_dropout_rate (float): Dropout rate in decoder
          self-attention module.
      spks (Optional[int]): Number of speakers. If set to > 1, assume that the
          sids will be provided as the input and use sid embedding layer.
      langs (Optional[int]): Number of languages. If set to > 1, assume that the
          lids will be provided as the input and use sid embedding layer.
      spk_embed_dim (Optional[int]): Speaker embedding dimension. If set to > 0,
          assume that spembs will be provided as the input.
      spk_embed_integration_type: How to integrate speaker embedding.
      init_type (str): How to initialize transformer parameters.
      init_enc_alpha (float): Initial value of alpha in scaled pos encoding of the
          encoder.
      init_dec_alpha (float): Initial value of alpha in scaled pos encoding of the
          decoder.
      use_masking (bool): Whether to apply masking for padded part in loss
          calculation.
      use_weighted_masking (bool): Whether to apply weighted masking in loss
          calculation.
      loss_function (str): Loss functions ("FastSpeech1" or "XiaoiceSing2")
      loss_type (str): Mel loss type ("L1" (MAE), "L2" (MSE) or "L1+L2")
      lambda_mel (float): Loss scaling coefficient for Mel loss.
      lambda_dur (float): Loss scaling coefficient for duration loss.
      lambda_pitch (float): Loss scaling coefficient for pitch loss.
      lambda_vuv (float): Loss scaling coefficient for VUV loss.
docstr_tok: ["Initialize","XiaoiceSing","module",".","Args",":","idim","(","int",")",":","Dimension","of","the","label","inputs",".","odim","(","int",")",":","Dimension","of","the","outputs",".","midi_dim","(","int",")",":","Dimension","of","the","midi","inputs",".","duration_dim","(","int",")",":","Dimension","of","the","duration","inputs",".","elayers","(","int",")",":","Number","of","encoder","layers",".","eunits","(","int",")",":","Number","of","encoder","hidden","units",".","dlayers","(","int",")",":","Number","of","decoder","layers",".","dunits","(","int",")",":","Number","of","decoder","hidden","units",".","postnet_layers","(","int",")",":","Number","of","postnet","layers",".","postnet_chans","(","int",")",":","Number","of","postnet","channels",".","postnet_filts","(","int",")",":","Kernel","size","of","postnet",".","postnet_dropout_rate","(","float",")",":","Dropout","rate","in","postnet",".","use_scaled_pos_enc","(","bool",")",":","Whether","to","use","trainable","scaled","pos","encoding",".","use_batch_norm","(","bool",")",":","Whether","to","use","batch","normalization","in","encoder","prenet",".","encoder_normalize_before","(","bool",")",":","Whether","to","apply","layernorm","layer","before","encoder","block",".","decoder_normalize_before","(","bool",")",":","Whether","to","apply","layernorm","layer","before","decoder","block",".","encoder_concat_after","(","bool",")",":","Whether","to","concatenate","attention","layer","'s","input","and","output","in","encoder",".","decoder_concat_after","(","bool",")",":","Whether","to","concatenate","attention","layer","'s","input","and","output","in","decoder",".","duration_predictor_layers","(","int",")",":","Number","of","duration","predictor","layers",".","duration_predictor_chans","(","int",")",":","Number","of","duration","predictor","channels",".","duration_predictor_kernel_size","(","int",")",":","Kernel","size","of","duration","predictor",".","duration_predictor_dropout_rate","(","float",")",":","Dropout","rate","in","duration","predictor",".","reduction_factor","(","int",")",":","Reduction","factor",".","encoder_type","(","str",")",":","Encoder","type","(","``","transformer","''","or","``","conformer","''",")",".","decoder_type","(","str",")",":","Decoder","type","(","``","transformer","''","or","``","conformer","''",")",".","transformer_enc_dropout_rate","(","float",")",":","Dropout","rate","in","encoder","except","attention","and","positional","encoding",".","transformer_enc_positional_dropout_rate","(","float",")",":","Dropout","rate","after","encoder","positional","encoding",".","transformer_enc_attn_dropout_rate","(","float",")",":","Dropout","rate","in","encoder","self-attention","module",".","transformer_dec_dropout_rate","(","float",")",":","Dropout","rate","in","decoder","except","attention","&","positional","encoding",".","transformer_dec_positional_dropout_rate","(","float",")",":","Dropout","rate","after","decoder","positional","encoding",".","transformer_dec_attn_dropout_rate","(","float",")",":","Dropout","rate","in","decoder","self-attention","module",".","spks","(","Optional","[","int","]",")",":","Number","of","speakers",".","If","set","to",">","1",",","assume","that","the","sids","will","be","provided","as","the","input","and","use","sid","embedding","layer",".","langs","(","Optional","[","int","]",")",":","Number","of","languages",".","If","set","to",">","1",",","assume","that","the","lids","will","be","provided","as","the","input","and","use","sid","embedding","layer",".","spk_embed_dim","(","Optional","[","int","]",")",":","Speaker","embedding","dimension",".","If","set","to",">","0",",","assume","that","spembs","will","be","provided","as","the","input",".","spk_embed_integration_type",":","How","to","integrate","speaker","embedding",".","init_type","(","str",")",":","How","to","initialize","transformer","parameters",".","init_enc_alpha","(","float",")",":","Initial","value","of","alpha","in","scaled","pos","encoding","of","the","encoder",".","init_dec_alpha","(","float",")",":","Initial","value","of","alpha","in","scaled","pos","encoding","of","the","decoder",".","use_masking","(","bool",")",":","Whether","to","apply","masking","for","padded","part","in","loss","calculation",".","use_weighted_masking","(","bool",")",":","Whether","to","apply","weighted","masking","in","loss","calculation",".","loss_function","(","str",")",":","Loss","functions","(","``","FastSpeech1","''","or","``","XiaoiceSing2","''",")","loss_type","(","str",")",":","Mel","loss","type","(","``","L1","''","(","MAE",")",",","``","L2","''","(","MSE",")","or","``","L1+L2","''",")","lambda_mel","(","float",")",":","Loss","scaling","coefficient","for","Mel","loss",".","lambda_dur","(","float",")",":","Loss","scaling","coefficient","for","duration","loss",".","lambda_pitch","(","float",")",":","Loss","scaling","coefficient","for","pitch","loss",".","lambda_vuv","(","float",")",":","Loss","scaling","coefficient","for","VUV","loss","."]
code: def __init__(
      self,
      # network structure related
      idim: int,
      odim: int,
      midi_dim: int = 129,
      duration_dim: int = 500,
      adim: int = 384,
      aheads: int = 4,
      elayers: int = 6,
      eunits: int = 1536,
      dlayers: int = 6,
      dunits: int = 1536,
      postnet_layers: int = 5,
      postnet_chans: int = 512,
      postnet_filts: int = 5,
      postnet_dropout_rate: float = 0.5,
      positionwise_layer_type: str = "conv1d",
      positionwise_conv_kernel_size: int = 1,
      use_scaled_pos_enc: bool = True,
      use_batch_norm: bool = True,
      encoder_normalize_before: bool = True,
      decoder_normalize_before: bool = True,
      encoder_concat_after: bool = False,
      decoder_concat_after: bool = False,
      duration_predictor_layers: int = 2,
      duration_predictor_chans: int = 384,
      duration_predictor_kernel_size: int = 3,
      duration_predictor_dropout_rate: float = 0.1,
      reduction_factor: int = 1,
      encoder_type: str = "transformer",
      decoder_type: str = "transformer",
      transformer_enc_dropout_rate: float = 0.1,
      transformer_enc_positional_dropout_rate: float = 0.1,
      transformer_enc_attn_dropout_rate: float = 0.1,
      transformer_dec_dropout_rate: float = 0.1,
      transformer_dec_positional_dropout_rate: float = 0.1,
      transformer_dec_attn_dropout_rate: float = 0.1,
      # only for conformer
      conformer_rel_pos_type: str = "legacy",
      conformer_pos_enc_layer_type: str = "rel_pos",
      conformer_self_attn_layer_type: str = "rel_selfattn",
      conformer_activation_type: str = "swish",
      use_macaron_style_in_conformer: bool = True,
      use_cnn_in_conformer: bool = True,
      zero_triu: bool = False,
      conformer_enc_kernel_size: int = 7,
      conformer_dec_kernel_size: int = 31,
      # extra embedding related
      spks: Optional[int] = None,
      langs: Optional[int] = None,
      spk_embed_dim: Optional[int] = None,
      spk_embed_integration_type: str = "add",
      # training related
      init_type: str = "xavier_uniform",
      init_enc_alpha: float = 1.0,
      init_dec_alpha: float = 1.0,
      use_masking: bool = False,
      use_weighted_masking: bool = False,
      loss_function: str = "XiaoiceSing2",  # FastSpeech1, XiaoiceSing2
      loss_type: str = "L1",
      lambda_mel: float = 1,
      lambda_dur: float = 0.1,
      lambda_pitch: float = 0.01,
      lambda_vuv: float = 0.01,
  ):
      """Initialize XiaoiceSing module.
  
      Args:
          idim (int): Dimension of the label inputs.
          odim (int): Dimension of the outputs.
          midi_dim (int): Dimension of the midi inputs.
          duration_dim (int): Dimension of the duration inputs.
          elayers (int): Number of encoder layers.
          eunits (int): Number of encoder hidden units.
          dlayers (int): Number of decoder layers.
          dunits (int): Number of decoder hidden units.
          postnet_layers (int): Number of postnet layers.
          postnet_chans (int): Number of postnet channels.
          postnet_filts (int): Kernel size of postnet.
          postnet_dropout_rate (float): Dropout rate in postnet.
          use_scaled_pos_enc (bool): Whether to use trainable scaled pos encoding.
          use_batch_norm (bool): Whether to use batch normalization in encoder prenet.
          encoder_normalize_before (bool): Whether to apply layernorm layer before
              encoder block.
          decoder_normalize_before (bool): Whether to apply layernorm layer before
              decoder block.
          encoder_concat_after (bool): Whether to concatenate attention layer's input
              and output in encoder.
          decoder_concat_after (bool): Whether to concatenate attention layer's input
              and output in decoder.
          duration_predictor_layers (int): Number of duration predictor layers.
          duration_predictor_chans (int): Number of duration predictor channels.
          duration_predictor_kernel_size (int): Kernel size of duration predictor.
          duration_predictor_dropout_rate (float): Dropout rate in duration predictor.
          reduction_factor (int): Reduction factor.
          encoder_type (str): Encoder type ("transformer" or "conformer").
          decoder_type (str): Decoder type ("transformer" or "conformer").
          transformer_enc_dropout_rate (float): Dropout rate in encoder except
              attention and positional encoding.
          transformer_enc_positional_dropout_rate (float): Dropout rate after encoder
              positional encoding.
          transformer_enc_attn_dropout_rate (float): Dropout rate in encoder
              self-attention module.
          transformer_dec_dropout_rate (float): Dropout rate in decoder except
              attention & positional encoding.
          transformer_dec_positional_dropout_rate (float): Dropout rate after decoder
              positional encoding.
          transformer_dec_attn_dropout_rate (float): Dropout rate in decoder
              self-attention module.
          spks (Optional[int]): Number of speakers. If set to > 1, assume that the
              sids will be provided as the input and use sid embedding layer.
          langs (Optional[int]): Number of languages. If set to > 1, assume that the
              lids will be provided as the input and use sid embedding layer.
          spk_embed_dim (Optional[int]): Speaker embedding dimension. If set to > 0,
              assume that spembs will be provided as the input.
          spk_embed_integration_type: How to integrate speaker embedding.
          init_type (str): How to initialize transformer parameters.
          init_enc_alpha (float): Initial value of alpha in scaled pos encoding of the
              encoder.
          init_dec_alpha (float): Initial value of alpha in scaled pos encoding of the
              decoder.
          use_masking (bool): Whether to apply masking for padded part in loss
              calculation.
          use_weighted_masking (bool): Whether to apply weighted masking in loss
              calculation.
          loss_function (str): Loss functions ("FastSpeech1" or "XiaoiceSing2")
          loss_type (str): Mel loss type ("L1" (MAE), "L2" (MSE) or "L1+L2")
          lambda_mel (float): Loss scaling coefficient for Mel loss.
          lambda_dur (float): Loss scaling coefficient for duration loss.
          lambda_pitch (float): Loss scaling coefficient for pitch loss.
          lambda_vuv (float): Loss scaling coefficient for VUV loss.
  
      """
      assert check_argument_types()
      super().__init__()
  
      # store hyperparameters
      self.idim = idim
      self.midi_dim = midi_dim
      self.duration_dim = duration_dim
      self.odim = odim
      self.eos = idim - 1
      self.reduction_factor = reduction_factor
      self.encoder_type = encoder_type
      self.decoder_type = decoder_type
      self.use_scaled_pos_enc = use_scaled_pos_enc
      self.loss_function = loss_function
      self.loss_type = loss_type
      self.lambda_mel = lambda_mel
      self.lambda_dur = lambda_dur
      self.lambda_pitch = lambda_pitch
      self.lambda_vuv = lambda_vuv
  
      # use idx 0 as padding idx
      self.padding_idx = 0
  
      # get positional encoding class
      pos_enc_class = (
          ScaledPositionalEncoding
          if self.use_scaled_pos_enc
          else PositionalEncoding
      )
  
      # check relative positional encoding compatibility
      if "conformer" in [encoder_type, decoder_type]:
          if conformer_rel_pos_type == "legacy":
              if conformer_pos_enc_layer_type == "rel_pos":
                  conformer_pos_enc_layer_type = "legacy_rel_pos"
                  logging.warning(
                      "Fallback to conformer_pos_enc_layer_type = 'legacy_rel_pos' "
                      "due to the compatibility. If you want to use the new one, "
                      "please use conformer_pos_enc_layer_type = 'latest'."
                  )
              if conformer_self_attn_layer_type == "rel_selfattn":
                  conformer_self_attn_layer_type = "legacy_rel_selfattn"
                  logging.warning(
                      "Fallback to "
                      "conformer_self_attn_layer_type = 'legacy_rel_selfattn' "
                      "due to the compatibility. If you want to use the new one, "
                      "please use conformer_pos_enc_layer_type = 'latest'."
                  )
          elif conformer_rel_pos_type == "latest":
              assert conformer_pos_enc_layer_type != "legacy_rel_pos"
              assert (
                  conformer_self_attn_layer_type
                  != "legacy_rel_selfattn"
              )
          else:
              raise ValueError(
                  f"Unknown rel_pos_type: {conformer_rel_pos_type}"
              )
  
      # define encoder
      self.phone_encode_layer = torch.nn.Embedding(
          num_embeddings=idim,
          embedding_dim=adim,
          padding_idx=self.padding_idx,
      )
      self.midi_encode_layer = torch.nn.Embedding(
          num_embeddings=midi_dim,
          embedding_dim=adim,
          padding_idx=self.padding_idx,
      )
      self.duration_encode_layer = torch.nn.Embedding(
          num_embeddings=duration_dim,
          embedding_dim=adim,
          padding_idx=self.padding_idx,
      )
      if encoder_type == "transformer":
          self.encoder = TransformerEncoder(
              idim=0,
              attention_dim=adim,
              attention_heads=aheads,
              linear_units=eunits,
              num_blocks=elayers,
              input_layer=None,
              dropout_rate=transformer_enc_dropout_rate,
              positional_dropout_rate=transformer_enc_positional_dropout_rate,
              attention_dropout_rate=transformer_enc_attn_dropout_rate,
              pos_enc_class=pos_enc_class,
              normalize_before=encoder_normalize_before,
              concat_after=encoder_concat_after,
              positionwise_layer_type=positionwise_layer_type,
              positionwise_conv_kernel_size=positionwise_conv_kernel_size,
          )
      elif encoder_type == "conformer":
          self.encoder = ConformerEncoder(
              idim=idim,
              attention_dim=adim,
              attention_heads=aheads,
              linear_units=eunits,
              num_blocks=elayers,
              input_layer=None,
              dropout_rate=transformer_enc_dropout_rate,
              positional_dropout_rate=transformer_enc_positional_dropout_rate,
              attention_dropout_rate=transformer_enc_attn_dropout_rate,
              normalize_before=encoder_normalize_before,
              concat_after=encoder_concat_after,
              positionwise_layer_type=positionwise_layer_type,
              positionwise_conv_kernel_size=positionwise_conv_kernel_size,
              macaron_style=use_macaron_style_in_conformer,
              pos_enc_layer_type=conformer_pos_enc_layer_type,
              selfattention_layer_type=conformer_self_attn_layer_type,
              activation_type=conformer_activation_type,
              use_cnn_module=use_cnn_in_conformer,
              cnn_module_kernel=conformer_enc_kernel_size,
              zero_triu=zero_triu,
          )
      else:
          raise ValueError(f"{encoder_type} is not supported.")
  
      # define spk and lang embedding
      self.spks = None
      if spks is not None and spks > 1:
          self.spks = spks
          self.sid_emb = torch.nn.Embedding(spks, adim)
      self.langs = None
      if langs is not None and langs > 1:
          self.langs = langs
          self.lid_emb = torch.nn.Embedding(langs, adim)
  
      # define additional projection for speaker embedding
      self.spk_embed_dim = None
      if spk_embed_dim is not None and spk_embed_dim > 0:
          self.spk_embed_dim = spk_embed_dim
          self.spk_embed_integration_type = spk_embed_integration_type
      if self.spk_embed_dim is not None:
          if self.spk_embed_integration_type == "add":
              self.projection = torch.nn.Linear(
                  self.spk_embed_dim, adim
              )
          else:
              self.projection = torch.nn.Linear(
                  adim + self.spk_embed_dim, adim
              )
  
      # define duration predictor
      self.duration_predictor = DurationPredictor(
          idim=adim,
          n_layers=duration_predictor_layers,
          n_chans=duration_predictor_chans,
          kernel_size=duration_predictor_kernel_size,
          dropout_rate=duration_predictor_dropout_rate,
      )
  
      # define length regulator
      self.length_regulator = LengthRegulator()
  
      # define decoder
      # NOTE: we use encoder as decoder
      # because fastspeech's decoder is the same as encoder
      if decoder_type == "transformer":
          self.decoder = TransformerEncoder(
              idim=0,
              attention_dim=adim,
              attention_heads=aheads,
              linear_units=dunits,
              num_blocks=dlayers,
              input_layer=None,
              dropout_rate=transformer_dec_dropout_rate,
              positional_dropout_rate=transformer_dec_positional_dropout_rate,
              attention_dropout_rate=transformer_dec_attn_dropout_rate,
              pos_enc_class=pos_enc_class,
              normalize_before=decoder_normalize_before,
              concat_after=decoder_concat_after,
              positionwise_layer_type=positionwise_layer_type,
              positionwise_conv_kernel_size=positionwise_conv_kernel_size,
          )
      elif decoder_type == "conformer":
          self.decoder = ConformerEncoder(
              idim=0,
              attention_dim=adim,
              attention_heads=aheads,
              linear_units=dunits,
              num_blocks=dlayers,
              input_layer=None,
              dropout_rate=transformer_dec_dropout_rate,
              positional_dropout_rate=transformer_dec_positional_dropout_rate,
              attention_dropout_rate=transformer_dec_attn_dropout_rate,
              normalize_before=decoder_normalize_before,
              concat_after=decoder_concat_after,
              positionwise_layer_type=positionwise_layer_type,
              positionwise_conv_kernel_size=positionwise_conv_kernel_size,
              macaron_style=use_macaron_style_in_conformer,
              pos_enc_layer_type=conformer_pos_enc_layer_type,
              selfattention_layer_type=conformer_self_attn_layer_type,
              activation_type=conformer_activation_type,
              use_cnn_module=use_cnn_in_conformer,
              cnn_module_kernel=conformer_dec_kernel_size,
          )
      else:
          raise ValueError(f"{decoder_type} is not supported.")
  
      # define final projection
      self.linear_projection = torch.nn.Linear(
          adim, (odim + 2) * reduction_factor
      )
  
      # define postnet
      self.postnet = (
          None
          if postnet_layers == 0
          else Postnet(
              idim=idim,
              odim=odim,
              n_layers=postnet_layers,
              n_chans=postnet_chans,
              n_filts=postnet_filts,
              use_batch_norm=use_batch_norm,
              dropout_rate=postnet_dropout_rate,
          )
      )
  
      # initialize parameters
      self._reset_parameters(
          init_type=init_type,
          init_enc_alpha=init_enc_alpha,
          init_dec_alpha=init_dec_alpha,
      )
  
      # define criterions
      if self.loss_function == "FastSpeech1":
          self.criterion = XiaoiceSingLoss(
              use_masking=use_masking,
              use_weighted_masking=use_weighted_masking,
          )
      elif self.loss_function == "XiaoiceSing2":
          self.criterion = XiaoiceSing2Loss(
              use_masking=use_masking,
              use_weighted_masking=use_weighted_masking,
          )
      else:
          raise ValueError(f"{self.loss_function} is not supported.")
  
imports: import logging
  from typing import Dict, Optional, Tuple
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.svs.abs_svs import AbsSVS
  from espnet2.svs.xiaoice.loss import XiaoiceSing2Loss
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.torch_utils.initialize import initialize
  from espnet.nets.pytorch_backend.conformer.encoder import Encoder
  from espnet.nets.pytorch_backend.e2e_tts_fastspeech import FeedForwardTransformerLoss
  from espnet.nets.pytorch_backend.fastspeech.duration_predictor import DurationPredictor
  from espnet.nets.pytorch_backend.fastspeech.length_regulator import LengthRegulator
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask, make_pad_mask
  from espnet.nets.pytorch_backend.tacotron2.decoder import Postnet
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding, ScaledPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
label_desc: Use image node_id 1 to create a new XiaoiceSing object from inherited base classes: AbsSVS with example: obj = XiaoiceSing(idim, odim, midi_dim, duration_dim, adim, aheads, elayers, eunits, dlayers, dunits, postnet_layers, postnet_chans, postnet_filts, postnet_dropout_rate, positionwise_layer_type, positionwise_conv_kernel_size, use_scaled_pos_enc, use_batch_norm, encoder_normalize_before, decoder_normalize_before, encoder_concat_after, decoder_concat_after, duration_predictor_layers, duration_predictor_chans, duration_predictor_kernel_size, duration_predictor_dropout_rate, reduction_factor, encoder_type, decoder_type, transformer_enc_dropout_rate, transformer_enc_positional_dropout_rate, transformer_enc_attn_dropout_rate, transformer_dec_dropout_rate, transformer_dec_positional_dropout_rate, transformer_dec_attn_dropout_rate, conformer_rel_pos_type, conformer_pos_enc_layer_type, conformer__attn_layer_type, conformer_activation_type, use_macaron_style_in_conformer, use_cnn_in_conformer, zero_triu, conformer_enc_kernel_size, conformer_dec_kernel_size, spks, langs, spk_embed_dim, spk_embed_integration_type, init_type, init_enc_alpha, init_dec_alpha, use_masking, use_weighted_masking, loss_function, loss_type, lambda_mel, lambda_dur, lambda_pitch, lambda_vuv)