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: Generate the sequence of features given the sequences of characters.
  
  Args:
      h (Tensor): Input sequence of encoder hidden states (T, C).
      threshold (float, optional): Threshold to stop generation.
      minlenratio (float, optional): Minimum length ratio.
          If set to 1.0 and the length of input is 10,
          the minimum length of outputs will be 10 * 1 = 10.
      minlenratio (float, optional): Minimum length ratio.
          If set to 10 and the length of input is 10,
          the maximum length of outputs will be 10 * 10 = 100.
      use_att_constraint (bool):
          Whether to apply attention constraint introduced in `Deep Voice 3`_.
      backward_window (int): Backward window size in attention constraint.
      forward_window (int): Forward window size in attention constraint.
  
  Returns:
      Tensor: Output sequence of features (L, odim).
      Tensor: Output sequence of stop probabilities (L,).
      Tensor: Attention weights (L, T).
  
  Note:
      This computation is performed in auto-regressive manner.
  
  .. _`Deep Voice 3`: https://arxiv.org/abs/1710.07654
docstr_tok: ["Generate","the","sequence","of","features","given","the","sequences","of","characters",".","Args",":","h","(","Tensor",")",":","Input","sequence","of","encoder","hidden","states","(","T",",","C",")",".","threshold","(","float",",","optional",")",":","Threshold","to","stop","generation",".","minlenratio","(","float",",","optional",")",":","Minimum","length","ratio",".","If","set","to","1.0","and","the","length","of","input","is","10",",","the","minimum","length","of","outputs","will","be","10","*","1","=","10.","minlenratio","(","float",",","optional",")",":","Minimum","length","ratio",".","If","set","to","10","and","the","length","of","input","is","10",",","the","maximum","length","of","outputs","will","be","10","*","10","=","100.","use_att_constraint","(","bool",")",":","Whether","to","apply","attention","constraint","introduced","in","`","Deep","Voice","3","`","_",".","backward_window","(","int",")",":","Backward","window","size","in","attention","constraint",".","forward_window","(","int",")",":","Forward","window","size","in","attention","constraint",".","Returns",":","Tensor",":","Output","sequence","of","features","(","L",",","odim",")",".","Tensor",":","Output","sequence","of","stop","probabilities","(","L",",",")",".","Tensor",":","Attention","weights","(","L",",","T",")",".","Note",":","This","computation","is","performed","in","auto-regressive","manner",".","..","_","`","Deep","Voice","3","`",":","https",":","\/\/arxiv.org\/abs\/1710.07654"]
code: def inference(
      self,
      h,
      threshold=0.5,
      minlenratio=0.0,
      maxlenratio=10.0,
      use_att_constraint=False,
      backward_window=None,
      forward_window=None,
  ):
      """Generate the sequence of features given the sequences of characters.
  
      Args:
          h (Tensor): Input sequence of encoder hidden states (T, C).
          threshold (float, optional): Threshold to stop generation.
          minlenratio (float, optional): Minimum length ratio.
              If set to 1.0 and the length of input is 10,
              the minimum length of outputs will be 10 * 1 = 10.
          minlenratio (float, optional): Minimum length ratio.
              If set to 10 and the length of input is 10,
              the maximum length of outputs will be 10 * 10 = 100.
          use_att_constraint (bool):
              Whether to apply attention constraint introduced in `Deep Voice 3`_.
          backward_window (int): Backward window size in attention constraint.
          forward_window (int): Forward window size in attention constraint.
  
      Returns:
          Tensor: Output sequence of features (L, odim).
          Tensor: Output sequence of stop probabilities (L,).
          Tensor: Attention weights (L, T).
  
      Note:
          This computation is performed in auto-regressive manner.
  
      .. _`Deep Voice 3`: https://arxiv.org/abs/1710.07654
  
      """
      # setup
      assert len(h.size()) == 2
      hs = h.unsqueeze(0)
      ilens = [h.size(0)]
      maxlen = int(h.size(0) * maxlenratio)
      minlen = int(h.size(0) * minlenratio)
  
      # 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(1, self.odim)
  
      # initialize attention
      prev_att_w = None
      self.att.reset()
  
      # setup for attention constraint
      if use_att_constraint:
          last_attended_idx = 0
      else:
          last_attended_idx = None
  
      # loop for an output sequence
      idx = 0
      outs, att_ws, probs = [], [], []
      while True:
          # updated index
          idx += self.reduction_factor
  
          # decoder calculation
          if self.use_att_extra_inputs:
              att_c, att_w = self.att(
                  hs,
                  ilens,
                  z_list[0],
                  prev_att_w,
                  prev_out,
                  last_attended_idx=last_attended_idx,
                  backward_window=backward_window,
                  forward_window=forward_window,
              )
          else:
              att_c, att_w = self.att(
                  hs,
                  ilens,
                  z_list[0],
                  prev_att_w,
                  last_attended_idx=last_attended_idx,
                  backward_window=backward_window,
                  forward_window=forward_window,
              )
  
          if (
              type(att_w) is list
          ):  # for multihead attention (used for translatotron in s2st)
              att_w = torch.stack(att_w, dim=1)
  
          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])
              )
          zcs = (
              torch.cat([z_list[-1], att_c], dim=1)
              if self.use_concate
              else z_list[-1]
          )
          outs += [
              self.feat_out(zcs).view(1, self.odim, -1)
          ]  # [(1, odim, r), ...]
          probs += [torch.sigmoid(self.prob_out(zcs))[0]]  # [(r), ...]
          if self.output_activation_fn is not None:
              prev_out = self.output_activation_fn(
                  outs[-1][:, :, -1]
              )  # (1, odim)
          else:
              prev_out = outs[-1][:, :, -1]  # (1, odim)
          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
          if use_att_constraint:
              last_attended_idx = int(att_w.argmax())
  
          # check whether to finish generation
          if int(sum(probs[-1] >= threshold)) > 0 or idx >= maxlen:
              # check mininum length
              if idx < minlen:
                  continue
              outs = torch.cat(outs, dim=2)  # (1, odim, L)
              if self.postnet is not None:
                  outs = outs + self.postnet(outs)  # (1, odim, L)
              outs = outs.transpose(2, 1).squeeze(0)  # (L, odim)
              probs = torch.cat(probs, dim=0)
              att_ws = torch.cat(att_ws, dim=0)
              break
  
      if self.output_activation_fn is not None:
          outs = self.output_activation_fn(outs)
  
      return outs, probs, att_ws
  
imports: import torch
  import torch.nn.functional
  from espnet.nets.pytorch_backend.rnn.attentions import AttForwardTA
label_desc: Use image node_id 4 for calling the Decoder obj's underlying member method code with example usage: obj.inference(h, threshold, minlenratio, maxlenratio, use_att_constraint, backward_window, forward_window) and returns: outs,  probs,  att_ws