docstr: Shapes:
      - x: :math:`[B, C, T]`
      - x_lengths: :math:`[B, 1]`
      - g: :math:`[B, C, 1]`
docstr_tok: ["Shapes",":","-","x",":",":","math",":","`","[","B",",","C",",","T","]","`","-","x_lengths",":",":","math",":","`","[","B",",","1","]","`","-","g",":",":","math",":","`","[","B",",","C",",","1","]","`"]
code: def forward(self, x, x_lengths, g=None):
      """
      Shapes:
          - x: :math:`[B, C, T]`
          - x_lengths: :math:`[B, 1]`
          - g: :math:`[B, C, 1]`
      """
      x_mask = torch.unsqueeze(
          sequence_mask(x_lengths, x.size(2)), 1
      ).to(x.dtype)
      x = self.pre(x) * x_mask
      x = self.enc(x, x_mask, g=g)
      stats = self.proj(x) * x_mask
      mean, log_scale = torch.split(stats, self.out_channels, dim=1)
      z = (
          mean + torch.randn_like(mean) * torch.exp(log_scale)
      ) * x_mask
      return z, mean, log_scale, x_mask
  
imports: import math
  import torch
  from torch import nn
  from TTS.tts.layers.glow_tts.glow import WN
  from TTS.tts.layers.glow_tts.transformer import RelativePositionTransformer
  from TTS.tts.utils.helpers import sequence_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,  mean,  log_scale,  x_mask