class_docstr: Glow TTS models from https://arxiv.org/abs/2005.11129
  
  Args:
      num_chars (int): number of embedding characters.
      hidden_channels_enc (int): number of embedding and encoder channels.
      hidden_channels_dec (int): number of decoder channels.
      use_encoder_prenet (bool): enable/disable prenet for encoder. Prenet modules are hard-coded for each alternative encoder.
      hidden_channels_dp (int): number of duration predictor channels.
      out_channels (int): number of output channels. It should be equal to the number of spectrogram filter.
      num_flow_blocks_dec (int): number of decoder blocks.
      kernel_size_dec (int): decoder kernel size.
      dilation_rate (int): rate to increase dilation by each layer in a decoder block.
      num_block_layers (int): number of decoder layers in each decoder block.
      dropout_p_dec (float): dropout rate for decoder.
      num_speaker (int): number of speaker to define the size of speaker embedding layer.
      c_in_channels (int): number of speaker embedding channels. It is set to 512 if embeddings are learned.
      num_splits (int): number of split levels in inversible conv1x1 operation.
      num_squeeze (int): number of squeeze levels. When squeezing channels increases and time steps reduces by the factor 'num_squeeze'.
      sigmoid_scale (bool): enable/disable sigmoid scaling in decoder.
      mean_only (bool): if True, encoder only computes mean value and uses constant variance for each time step.
      encoder_type (str): encoder module type.
      encoder_params (dict): encoder module parameters.
      external_speaker_embedding_dim (int): channels of external speaker embedding vectors.
class_docstr_tok: ["Glow","TTS","models","from","https",":","\/\/arxiv.org\/abs\/2005.11129","Args",":","num_chars","(","int",")",":","number","of","embedding","characters",".","hidden_channels_enc","(","int",")",":","number","of","embedding","and","encoder","channels",".","hidden_channels_dec","(","int",")",":","number","of","decoder","channels",".","use_encoder_prenet","(","bool",")",":","enable\/disable","prenet","for","encoder",".","Prenet","modules","are","hard-coded","for","each","alternative","encoder",".","hidden_channels_dp","(","int",")",":","number","of","duration","predictor","channels",".","out_channels","(","int",")",":","number","of","output","channels",".","It","should","be","equal","to","the","number","of","spectrogram","filter",".","num_flow_blocks_dec","(","int",")",":","number","of","decoder","blocks",".","kernel_size_dec","(","int",")",":","decoder","kernel","size",".","dilation_rate","(","int",")",":","rate","to","increase","dilation","by","each","layer","in","a","decoder","block",".","num_block_layers","(","int",")",":","number","of","decoder","layers","in","each","decoder","block",".","dropout_p_dec","(","float",")",":","dropout","rate","for","decoder",".","num_speaker","(","int",")",":","number","of","speaker","to","define","the","size","of","speaker","embedding","layer",".","c_in_channels","(","int",")",":","number","of","speaker","embedding","channels",".","It","is","set","to","512","if","embeddings","are","learned",".","num_splits","(","int",")",":","number","of","split","levels","in","inversible","conv1x1","operation",".","num_squeeze","(","int",")",":","number","of","squeeze","levels",".","When","squeezing","channels","increases","and","time","steps","reduces","by","the","factor","'num_squeeze","'",".","sigmoid_scale","(","bool",")",":","enable\/disable","sigmoid","scaling","in","decoder",".","mean_only","(","bool",")",":","if","True",",","encoder","only","computes","mean","value","and","uses","constant","variance","for","each","time","step",".","encoder_type","(","str",")",":","encoder","module","type",".","encoder_params","(","dict",")",":","encoder","module","parameters",".","external_speaker_embedding_dim","(","int",")",":","channels","of","external","speaker","embedding","vectors","."]
docstr: Shapes:
      x: [B, T]
      x_lenghts: B
      y: [B, C, T]
      y_lengths: B
      g: [B, C] or B
docstr_tok: ["Shapes",":","x",":","[","B",",","T","]","x_lenghts",":","B","y",":","[","B",",","C",",","T","]","y_lengths",":","B","g",":","[","B",",","C","]","or","B"]
code: def forward(
      self, x, x_lengths, y=None, y_lengths=None, attn=None, g=None
  ):
      """
      Shapes:
          x: [B, T]
          x_lenghts: B
          y: [B, C, T]
          y_lengths: B
          g: [B, C] or B
      """
      y_max_length = y.size(2)
      # norm speaker embeddings
      if g is not None:
          if self.external_speaker_embedding_dim:
              g = F.normalize(g).unsqueeze(-1)
          else:
              g = F.normalize(self.emb_g(g)).unsqueeze(-1)  # [b, h, 1]
  
      # embedding pass
      o_mean, o_log_scale, o_dur_log, x_mask = self.encoder(
          x, x_lengths, g=g
      )
      # drop redisual frames wrt num_squeeze and set y_lengths.
      y, y_lengths, y_max_length, attn = self.preprocess(
          y, y_lengths, y_max_length, None
      )
      # create masks
      y_mask = torch.unsqueeze(
          sequence_mask(y_lengths, y_max_length), 1
      ).to(x_mask.dtype)
      attn_mask = torch.unsqueeze(x_mask, -1) * torch.unsqueeze(
          y_mask, 2
      )
      # decoder pass
      z, logdet = self.decoder(y, y_mask, g=g, reverse=False)
      # find the alignment path
      with torch.no_grad():
          o_scale = torch.exp(-2 * o_log_scale)
          logp1 = torch.sum(
              -0.5 * math.log(2 * math.pi) - o_log_scale, [1]
          ).unsqueeze(
              -1
          )  # [b, t, 1]
          logp2 = torch.matmul(
              o_scale.transpose(1, 2), -0.5 * (z**2)
          )  # [b, t, d] x [b, d, t'] = [b, t, t']
          logp3 = torch.matmul(
              (o_mean * o_scale).transpose(1, 2), z
          )  # [b, t, d] x [b, d, t'] = [b, t, t']
          logp4 = torch.sum(
              -0.5 * (o_mean**2) * o_scale, [1]
          ).unsqueeze(
              -1
          )  # [b, t, 1]
          logp = logp1 + logp2 + logp3 + logp4  # [b, t, t']
          attn = (
              maximum_path(logp, attn_mask.squeeze(1))
              .unsqueeze(1)
              .detach()
          )
      y_mean, y_log_scale, o_attn_dur = self.compute_outputs(
          attn, o_mean, o_log_scale, x_mask
      )
      attn = attn.squeeze(1).permute(0, 2, 1)
      return z, logdet, y_mean, y_log_scale, attn, o_dur_log, o_attn_dur
  
file_path: TTS/TTS/tts/models/glow_tts.py
imports: import math
  import torch
  from torch import nn
  from torch.nn import functional
  from TTS.tts.layers.glow_tts.encoder import Encoder
  from TTS.tts.layers.glow_tts.decoder import Decoder
  from TTS.tts.utils.generic_utils import sequence_mask
  from TTS.tts.layers.glow_tts.monotonic_align import maximum_path, generate_path
label_desc: Use image node_id 3 for calling the GlowTts obj's underlying member method code with example usage: obj.forward(x, x_lengths, y, y_lengths, attn, g) and returns: z,  logdet,  y_mean,  y_log_scale,  attn,  o_dur_log,  o_attn_dur