class_docstr: Posterior encoder module in VITS.
  
  This is a module of posterior encoder described in `Conditional Variational
  Autoencoder with Adversarial Learning for End-to-End Text-to-Speech`_.
  
  .. _`Conditional Variational Autoencoder with Adversarial Learning for End-to-End
      Text-to-Speech`: https://arxiv.org/abs/2006.04558
docstr: Calculate forward propagation.
  
  Args:
      x (Tensor): Input tensor (B, in_channels, T_feats).
      x_lengths (Tensor): Length tensor (B,).
      g (Optional[Tensor]): Global conditioning tensor (B, global_channels, 1).
  
  Returns:
      Tensor: Encoded hidden representation tensor (B, out_channels, T_feats).
      Tensor: Projected mean tensor (B, out_channels, T_feats).
      Tensor: Projected scale tensor (B, out_channels, T_feats).
      Tensor: Mask tensor for input tensor (B, 1, T_feats).
code: def forward(
      self,
      x: torch.Tensor,
      x_lengths: torch.Tensor,
      g: Optional[torch.Tensor] = None,
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
      """Calculate forward propagation.
  
      Args:
          x (Tensor): Input tensor (B, in_channels, T_feats).
          x_lengths (Tensor): Length tensor (B,).
          g (Optional[Tensor]): Global conditioning tensor (B, global_channels, 1).
  
      Returns:
          Tensor: Encoded hidden representation tensor (B, out_channels, T_feats).
          Tensor: Projected mean tensor (B, out_channels, T_feats).
          Tensor: Projected scale tensor (B, out_channels, T_feats).
          Tensor: Mask tensor for input tensor (B, 1, T_feats).
  
      """
      x_mask = (
          make_non_pad_mask(x_lengths)
          .unsqueeze(1)
          .to(
              dtype=x.dtype,
              device=x.device,
          )
      )
      x = self.input_conv(x) * x_mask
      x = self.encoder(x, x_mask, g=g)
      stats = self.proj(x) * x_mask
      m, logs = stats.split(stats.size(1) // 2, dim=1)
      z = (m + torch.randn_like(m) * torch.exp(logs)) * x_mask
  
      return z, m, logs, x_mask
  
file_path: espnet/espnet2/gan_tts/vits/posterior_encoder.py
imports: from typing import Optional, Tuple
  import torch
  from espnet2.gan_tts.wavenet import WaveNet
  from espnet2.gan_tts.wavenet.residual_block import Conv1d
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
label_desc: Use image node_id 2 for calling the PosteriorEncoder obj's underlying member method code with example usage: obj.forward(x, x_lengths, g) and returns: z,  m,  logs,  x_mask