class_docstr: Tacotron2 module for end-to-end text-to-speech (E2E-TTS).
  
  This is a module of Spectrogram prediction network in Tacotron2 described
  in `Natural TTS Synthesis
  by Conditioning WaveNet on Mel Spectrogram Predictions`_,
  which converts the sequence of characters
  into the sequence of Mel-filterbanks.
  
  .. _`Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`:
     https://arxiv.org/abs/1712.05884
class_docstr_tok: ["Tacotron2","module","for","end-to-end","text-to-speech","(","E2E-TTS",")",".","This","is","a","module","of","Spectrogram","prediction","network","in","Tacotron2","described","in","`","Natural","TTS","Synthesis","by","Conditioning","WaveNet","on","Mel","Spectrogram","Predictions","`","_",",","which","converts","the","sequence","of","characters","into","the","sequence","of","Mel-filterbanks",".","..","_","`","Natural","TTS","Synthesis","by","Conditioning","WaveNet","on","Mel","Spectrogram","Predictions","`",":","https",":","\/\/arxiv.org\/abs\/1712.05884"]
docstr: Calculate all of the attention weights.
  
  Args:
      xs (Tensor): Batch of padded character ids (B, Tmax).
      ilens (LongTensor): Batch of lengths of each input batch (B,).
      ys (Tensor): Batch of padded target features (B, Lmax, odim).
      olens (LongTensor): Batch of the lengths of each target (B,).
      spembs (Tensor, optional):
          Batch of speaker embedding vectors (B, spk_embed_dim).
      keep_tensor (bool, optional): Whether to keep original tensor.
  
  Returns:
      Union[ndarray, Tensor]: Batch of attention weights (B, Lmax, Tmax).
docstr_tok: ["Calculate","all","of","the","attention","weights",".","Args",":","xs","(","Tensor",")",":","Batch","of","padded","character","ids","(","B",",","Tmax",")",".","ilens","(","LongTensor",")",":","Batch","of","lengths","of","each","input","batch","(","B",",",")",".","ys","(","Tensor",")",":","Batch","of","padded","target","features","(","B",",","Lmax",",","odim",")",".","olens","(","LongTensor",")",":","Batch","of","the","lengths","of","each","target","(","B",",",")",".","spembs","(","Tensor",",","optional",")",":","Batch","of","speaker","embedding","vectors","(","B",",","spk_embed_dim",")",".","keep_tensor","(","bool",",","optional",")",":","Whether","to","keep","original","tensor",".","Returns",":","Union","[","ndarray",",","Tensor","]",":","Batch","of","attention","weights","(","B",",","Lmax",",","Tmax",")","."]
code: def calculate_all_attentions(
      self,
      xs,
      ilens,
      ys,
      spembs=None,
      keep_tensor=False,
      *args,
      **kwargs,
  ):
      """Calculate all of the attention weights.
  
      Args:
          xs (Tensor): Batch of padded character ids (B, Tmax).
          ilens (LongTensor): Batch of lengths of each input batch (B,).
          ys (Tensor): Batch of padded target features (B, Lmax, odim).
          olens (LongTensor): Batch of the lengths of each target (B,).
          spembs (Tensor, optional):
              Batch of speaker embedding vectors (B, spk_embed_dim).
          keep_tensor (bool, optional): Whether to keep original tensor.
  
      Returns:
          Union[ndarray, Tensor]: Batch of attention weights (B, Lmax, Tmax).
  
      """
      # check ilens type (should be list of int)
      if isinstance(ilens, torch.Tensor) or isinstance(
          ilens, np.ndarray
      ):
          ilens = list(map(int, ilens))
  
      self.eval()
      with torch.no_grad():
          hs, hlens = self.enc(xs, ilens)
          if self.spk_embed_dim is not None:
              spembs = (
                  F.normalize(spembs)
                  .unsqueeze(1)
                  .expand(-1, hs.size(1), -1)
              )
              hs = torch.cat([hs, spembs], dim=-1)
          att_ws = self.dec.calculate_all_attentions(hs, hlens, ys)
      self.train()
  
      if keep_tensor:
          return att_ws
      else:
          return att_ws.cpu().numpy()
  
imports: import logging
  import numpy
  import torch
  import torch.nn.functional
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
  from espnet.nets.pytorch_backend.rnn.attentions import AttForward, AttForwardTA, AttLoc
  from espnet.nets.pytorch_backend.tacotron2.cbhg import CBHG, CBHGLoss
  from espnet.nets.pytorch_backend.tacotron2.decoder import Decoder
  from espnet.nets.pytorch_backend.tacotron2.encoder import Encoder
  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 5 for calling the Tacotron2 obj's underlying member method code with example usage: obj.calculate_all_attentions(xs, ilens, ys, spembs, keep_tensor) and returns: att_ws, att_ws