class_docstr: Text encoder module in VITS.
  
  This is a module of text encoder described in `Conditional Variational Autoencoder
  with Adversarial Learning for End-to-End Text-to-Speech`_.
  
  Instead of the relative positional Transformer, we use conformer architecture as
  the encoder module, which contains additional convolution layers.
  
  .. _`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 index tensor (B, T_text).
      x_lengths (Tensor): Length tensor (B,).
  
  Returns:
      Tensor: Encoded hidden representation (B, attention_dim, T_text).
      Tensor: Projected mean tensor (B, attention_dim, T_text).
      Tensor: Projected scale tensor (B, attention_dim, T_text).
      Tensor: Mask tensor for input tensor (B, 1, T_text).
code: def forward(
      self,
      x: torch.Tensor,
      x_lengths: torch.Tensor,
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
      """Calculate forward propagation.
  
      Args:
          x (Tensor): Input index tensor (B, T_text).
          x_lengths (Tensor): Length tensor (B,).
  
      Returns:
          Tensor: Encoded hidden representation (B, attention_dim, T_text).
          Tensor: Projected mean tensor (B, attention_dim, T_text).
          Tensor: Projected scale tensor (B, attention_dim, T_text).
          Tensor: Mask tensor for input tensor (B, 1, T_text).
  
      """
      x = self.emb(x) * math.sqrt(self.attention_dim)
      x_mask = (
          make_non_pad_mask(x_lengths)
          .to(
              device=x.device,
              dtype=x.dtype,
          )
          .unsqueeze(1)
      )
      # encoder assume the channel last (B, T_text, attention_dim)
      # but mask shape shoud be (B, 1, T_text)
      x, _ = self.encoder(x, x_mask)
  
      # convert the channel first (B, attention_dim, T_text)
      x = x.transpose(1, 2)
      stats = self.proj(x) * x_mask
      m, logs = stats.split(stats.size(1) // 2, dim=1)
  
      return x, m, logs, x_mask
  
file_path: espnet/espnet2/gan_tts/vits/text_encoder.py
imports: import math
  from typing import Tuple
  import torch
  from espnet.nets.pytorch_backend.conformer.encoder import Encoder
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
label_desc: Use image node_id 2 for calling the TextEncoder obj's underlying member method code with example usage: obj.forward(x, x_lengths) and returns: x,  m,  logs,  x_mask