class_docstr: Decoder module of Spectrogram prediction network.
  
  This is a module of decoder of Spectrogram prediction network in Tacotron2,
  which described in `Natural TTS
  Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`_.
  The decoder generates the sequence of
  features from the sequence of the hidden states.
  
  .. _`Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`:
     https://arxiv.org/abs/1712.05884
docstr: Calculate all of the attention weights.
  
  Args:
      hs (Tensor): Batch of the sequences of padded hidden states (B, Tmax, idim).
      hlens (LongTensor): Batch of lengths of each input batch (B,).
      ys (Tensor):
          Batch of the sequences of padded target features (B, Lmax, odim).
  
  Returns:
      numpy.ndarray: Batch of attention weights (B, Lmax, Tmax).
  
  Note:
      This computation is performed in teacher-forcing manner.
docstr_tok: ["Calculate","all","of","the","attention","weights",".","Args",":","hs","(","Tensor",")",":","Batch","of","the","sequences","of","padded","hidden","states","(","B",",","Tmax",",","idim",")",".","hlens","(","LongTensor",")",":","Batch","of","lengths","of","each","input","batch","(","B",",",")",".","ys","(","Tensor",")",":","Batch","of","the","sequences","of","padded","target","features","(","B",",","Lmax",",","odim",")",".","Returns",":","numpy.ndarray",":","Batch","of","attention","weights","(","B",",","Lmax",",","Tmax",")",".","Note",":","This","computation","is","performed","in","teacher-forcing","manner","."]
code: def calculate_all_attentions(self, hs, hlens, ys):
      """Calculate all of the attention weights.
  
      Args:
          hs (Tensor): Batch of the sequences of padded hidden states (B, Tmax, idim).
          hlens (LongTensor): Batch of lengths of each input batch (B,).
          ys (Tensor):
              Batch of the sequences of padded target features (B, Lmax, odim).
  
      Returns:
          numpy.ndarray: Batch of attention weights (B, Lmax, Tmax).
  
      Note:
          This computation is performed in teacher-forcing manner.
  
      """
      # thin out frames (B, Lmax, odim) ->  (B, Lmax/r, odim)
      if self.reduction_factor > 1:
          ys = ys[:, self.reduction_factor - 1 :: self.reduction_factor]
  
      # length list should be list of int
      hlens = list(map(int, hlens))
  
      # initialize hidden states of decoder
      c_list = [self._zero_state(hs)]
      z_list = [self._zero_state(hs)]
      for _ in range(1, len(self.lstm)):
          c_list += [self._zero_state(hs)]
          z_list += [self._zero_state(hs)]
      prev_out = hs.new_zeros(hs.size(0), self.odim)
  
      # initialize attention
      prev_att_w = None
      self.att.reset()
  
      # loop for an output sequence
      att_ws = []
      for y in ys.transpose(0, 1):
          if self.use_att_extra_inputs:
              att_c, att_w = self.att(
                  hs, hlens, z_list[0], prev_att_w, prev_out
              )
          else:
              att_c, att_w = self.att(hs, hlens, z_list[0], prev_att_w)
          att_ws += [att_w]
          prenet_out = (
              self.prenet(prev_out)
              if self.prenet is not None
              else prev_out
          )
          xs = torch.cat([att_c, prenet_out], dim=1)
          z_list[0], c_list[0] = self.lstm[0](
              xs, (z_list[0], c_list[0])
          )
          for i in range(1, len(self.lstm)):
              z_list[i], c_list[i] = self.lstm[i](
                  z_list[i - 1], (z_list[i], c_list[i])
              )
          prev_out = y  # teacher forcing
          if self.cumulate_att_w and prev_att_w is not None:
              prev_att_w = prev_att_w + att_w  # Note: error when use +=
          else:
              prev_att_w = att_w
  
      att_ws = torch.stack(att_ws, dim=1)  # (B, Lmax, Tmax)
  
      return att_ws
  
imports: import torch
  import torch.nn.functional
  from espnet.nets.pytorch_backend.rnn.attentions import AttForwardTA
label_desc: Use image node_id 5 for calling the Decoder obj's underlying member method code with example usage: obj.calculate_all_attentions(hs, hlens, ys) and returns: att_ws