class_docstr: Feed Forward Transformer for TTS a.k.a. FastSpeech.
  
  This is a module of FastSpeech,
  feed-forward Transformer with duration predictor described in
  `FastSpeech: Fast, Robust and Controllable Text to Speech`_,
  which does not require any auto-regressive
  processing during inference,
  resulting in fast decoding compared with auto-regressive Transformer.
  
  .. _`FastSpeech: Fast, Robust and Controllable Text to Speech`:
      https://arxiv.org/pdf/1905.09263.pdf
class_docstr_tok: ["Feed","Forward","Transformer","for","TTS","a.k.a",".","FastSpeech",".","This","is","a","module","of","FastSpeech",",","feed-forward","Transformer","with","duration","predictor","described","in","`","FastSpeech",":","Fast",",","Robust","and","Controllable","Text","to","Speech","`","_",",","which","does","not","require","any","auto-regressive","processing","during","inference",",","resulting","in","fast","decoding","compared","with","auto-regressive","Transformer",".","..","_","`","FastSpeech",":","Fast",",","Robust","and","Controllable","Text","to","Speech","`",":","https",":","\/\/arxiv.org\/pdf\/1905.09263.pdf"]
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).
      extras (Tensor, optional): Batch of precalculated durations (B, Tmax, 1).
  
  Returns:
      dict: Dict of attention weights and outputs.
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",")",".","extras","(","Tensor",",","optional",")",":","Batch","of","precalculated","durations","(","B",",","Tmax",",","1",")",".","Returns",":","dict",":","Dict","of","attention","weights","and","outputs","."]
code: def calculate_all_attentions(
      self,
      xs,
      ilens,
      ys,
      olens,
      spembs=None,
      extras=None,
      *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).
          extras (Tensor, optional): Batch of precalculated durations (B, Tmax, 1).
  
      Returns:
          dict: Dict of attention weights and outputs.
  
      """
      with torch.no_grad():
          # remove unnecessary padded part (for multi-gpus)
          xs = xs[:, : max(ilens)]
          ys = ys[:, : max(olens)]
          if extras is not None:
              extras = extras[:, : max(ilens)].squeeze(-1)
  
          # forward propagation
          outs = self._forward(
              xs,
              ilens,
              ys,
              olens,
              spembs=spembs,
              ds=extras,
              is_inference=False,
          )[1]
  
      att_ws_dict = dict()
      for name, m in self.named_modules():
          if isinstance(m, MultiHeadedAttention):
              attn = m.attn.cpu().numpy()
              if "encoder" in name:
                  attn = [
                      a[:, :l, :l] for a, l in zip(attn, ilens.tolist())
                  ]
              elif "decoder" in name:
                  if "src" in name:
                      attn = [
                          a[:, :ol, :il]
                          for a, il, ol in zip(
                              attn, ilens.tolist(), olens.tolist()
                          )
                      ]
                  elif "self" in name:
                      attn = [
                          a[:, :l, :l]
                          for a, l in zip(attn, olens.tolist())
                      ]
                  else:
                      logging.warning(
                          "unknown attention module: " + name
                      )
              else:
                  logging.warning("unknown attention module: " + name)
              att_ws_dict[name] = attn
      att_ws_dict["predicted_fbank"] = [
          m[:l].T for m, l in zip(outs.cpu().numpy(), olens.tolist())
      ]
  
      return att_ws_dict
  
imports: import logging
  import torch
  import torch.nn.functional
  from espnet.asr.asr_utils import get_model_conf, torch_load
  from espnet.nets.pytorch_backend.fastspeech.duration_calculator import DurationCalculator
  from espnet.nets.pytorch_backend.fastspeech.duration_predictor import DurationPredictor, DurationPredictorLoss
  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.attention import MultiHeadedAttention
  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.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 FeedForwardTransformer obj's underlying member method code with example usage: obj.calculate_all_attentions(xs, ilens, ys, olens, spembs, extras) and returns: att_ws_dict