class_docstr: Text-to-Speech Transformer module.
  
  This is a module of text-to-speech Transformer described
  in `Neural Speech Synthesis with Transformer Network`_,
  which convert the sequence of characters
  or phonemes into the sequence of Mel-filterbanks.
  
  .. _`Neural Speech Synthesis with Transformer Network`:
      https://arxiv.org/pdf/1809.08895.pdf
class_docstr_tok: ["Text-to-Speech","Transformer","module",".","This","is","a","module","of","text-to-speech","Transformer","described","in","`","Neural","Speech","Synthesis","with","Transformer","Network","`","_",",","which","convert","the","sequence","of","characters","or","phonemes","into","the","sequence","of","Mel-filterbanks",".","..","_","`","Neural","Speech","Synthesis","with","Transformer","Network","`",":","https",":","\/\/arxiv.org\/pdf\/1809.08895.pdf"]
docstr: Integrate speaker embedding with hidden states.
  
  Args:
      hs (Tensor): Batch of hidden state sequences (B, Tmax, adim).
      spembs (Tensor): Batch of speaker embeddings (B, spk_embed_dim).
  
  Returns:
      Tensor: Batch of integrated hidden state sequences (B, Tmax, adim)
docstr_tok: ["Integrate","speaker","embedding","with","hidden","states",".","Args",":","hs","(","Tensor",")",":","Batch","of","hidden","state","sequences","(","B",",","Tmax",",","adim",")",".","spembs","(","Tensor",")",":","Batch","of","speaker","embeddings","(","B",",","spk_embed_dim",")",".","Returns",":","Tensor",":","Batch","of","integrated","hidden","state","sequences","(","B",",","Tmax",",","adim",")"]
code: def _integrate_with_spk_embed(self, hs, spembs):
      """Integrate speaker embedding with hidden states.
  
      Args:
          hs (Tensor): Batch of hidden state sequences (B, Tmax, adim).
          spembs (Tensor): Batch of speaker embeddings (B, spk_embed_dim).
  
      Returns:
          Tensor: Batch of integrated hidden state sequences (B, Tmax, adim)
  
      """
      if self.spk_embed_integration_type == "add":
          # apply projection and then add to hidden states
          spembs = self.projection(F.normalize(spembs))
          hs = hs + spembs.unsqueeze(1)
      elif self.spk_embed_integration_type == "concat":
          # concat hidden states with spk embeds and then apply projection
          spembs = (
              F.normalize(spembs)
              .unsqueeze(1)
              .expand(-1, hs.size(1), -1)
          )
          hs = self.projection(torch.cat([hs, spembs], dim=-1))
      else:
          raise NotImplementedError("support only add or concat.")
  
      return hs
  
imports: import logging
  import torch
  import torch.nn.functional
  from espnet.nets.pytorch_backend.e2e_tts_tacotron2 import GuidedAttentionLoss
  from espnet.nets.pytorch_backend.e2e_tts_tacotron2 import Tacotron2Loss
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
  from espnet.nets.pytorch_backend.tacotron2.decoder import Postnet
  from espnet.nets.pytorch_backend.tacotron2.decoder import Prenet
  from espnet.nets.pytorch_backend.tacotron2.encoder import Encoder
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.decoder import Decoder
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding, ScaledPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
  from espnet.nets.pytorch_backend.transformer.initializer import initialize
  from espnet.nets.pytorch_backend.transformer.mask import subsequent_mask
  from espnet.nets.tts_interface import TTSInterface
  from espnet.utils.cli_utils import strtobool
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 9 for calling the Transformer obj's underlying member method code with example usage: obj._integrate_with_spk_embed(hs, spembs) and returns: hs