class_docstr: Non-attention Tacotron:
      - https://arxiv.org/abs/2010.04301
  this source code is implemenation of the ExpressiveTacotron from BridgetteSong
      - https://github.com/BridgetteSong/ExpressiveTacotron/
class_docstr_tok: ["Non-attention","Tacotron",":","-","https",":","\/\/arxiv.org\/abs\/2010.04301","this","source","code","is","implemenation","of","the","ExpressiveTacotron","from","BridgetteSong","-","https",":","\/\/github.com\/BridgetteSong\/ExpressiveTacotron\/"]
docstr: Gaussian upsampling.
  
  Args:
      encoder_outputs: encoder outputs  [batch_size, hidden_length, dim]
      durations: phoneme durations  [batch_size, hidden_length]
      vars : phoneme attended ranges [batch_size, hidden_length]
      input_lengths : [batch_size]
  
  Return:
      encoder_upsampling_outputs: upsampled encoder_output
          [batch_size, frame_length, dim]
docstr_tok: ["Gaussian","upsampling",".","Args",":","encoder_outputs",":","encoder","outputs","[","batch_size",",","hidden_length",",","dim","]","durations",":","phoneme","durations","[","batch_size",",","hidden_length","]","vars",":","phoneme","attended","ranges","[","batch_size",",","hidden_length","]","input_lengths",":","[","batch_size","]","Return",":","encoder_upsampling_outputs",":","upsampled","encoder_output","[","batch_size",",","frame_length",",","dim","]"]
code: def forward(
      self, encoder_outputs, durations, vars, input_lengths=None
  ):
      """Gaussian upsampling.
  
      Args:
          encoder_outputs: encoder outputs  [batch_size, hidden_length, dim]
          durations: phoneme durations  [batch_size, hidden_length]
          vars : phoneme attended ranges [batch_size, hidden_length]
          input_lengths : [batch_size]
  
      Return:
          encoder_upsampling_outputs: upsampled encoder_output
              [batch_size, frame_length, dim]
      """
      batch_size = encoder_outputs.size(0)
      hidden_length = encoder_outputs.size(1)
      frame_length = int(torch.sum(durations, dim=1).max().item())
      c = torch.cumsum(durations, dim=1).float() - 0.5 * durations
      c = c.unsqueeze(2)  # [batch_size, hidden_length, 1]
      t = (
          torch.arange(frame_length, device=encoder_outputs.device)
          .expand(batch_size, hidden_length, frame_length)
          .float()
      )  # [batch_size, hidden_length, frame_length]
      vars = vars.view(
          batch_size, -1, 1
      )  # [batch_size, hidden_length, 1]
  
      w_t = -0.5 * (
          np.log(2.0 * np.pi)
          + torch.log(vars)
          + torch.pow(t - c, 2) / vars
      )  # [batch_size, hidden_length, frame_length]
  
      if input_lengths is not None:
          input_masks = ~self.get_mask_from_lengths(
              input_lengths, hidden_length
          )  # [batch_size, hidden_length]
          input_masks = torch.tensor(
              input_masks, dtype=torch.bool, device=w_t.device
          )
          masks = input_masks.unsqueeze(2)
          w_t.data.masked_fill_(masks, self.mask_score)
      w_t = F.softmax(w_t, dim=1)
  
      encoder_upsampling_outputs = torch.bmm(
          w_t.transpose(1, 2), encoder_outputs
      )  # [batch_size, frame_length, encoder_hidden_size]
  
      return encoder_upsampling_outputs
  
imports: import logging
  from typing import Dict, Optional, Sequence, Tuple
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.s2st.synthesizer.abs_synthesizer import AbsSynthesizer
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.torch_utils.initialize import initialize
  from espnet2.tts.fastspeech2.loss import FastSpeech2Loss
  from espnet2.tts.fastspeech2.variance_predictor import VariancePredictor
  from espnet2.tts.gst.style_encoder import StyleEncoder
  from espnet.nets.pytorch_backend.conformer.encoder import Encoder
  from espnet.nets.pytorch_backend.fastspeech.duration_predictor import DurationPredictor
  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.embedding import PositionalEncoding, ScaledPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
label_desc: Use image node_id 2 for calling the GaussianUpsampling obj's underlying member method code with example usage: obj.forward(encoder_outputs, durations, vars, input_lengths) and returns: encoder_upsampling_outputs