class_docstr: Residual affine coupling block module.
  
  This is a module of residual affine coupling block, which used as "Flow" 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).
      x_lengths (Tensor): Length tensor (B,).
      g (Optional[Tensor]): Global conditioning tensor (B, global_channels, 1).
      inverse (bool): Whether to inverse the flow.
  
  Returns:
      Tensor: Output tensor (B, in_channels, T).
code: def forward(
      self,
      x: torch.Tensor,
      x_mask: torch.Tensor,
      g: Optional[torch.Tensor] = None,
      inverse: bool = False,
  ) -> torch.Tensor:
      """Calculate forward propagation.
  
      Args:
          x (Tensor): Input tensor (B, in_channels, T).
          x_lengths (Tensor): Length tensor (B,).
          g (Optional[Tensor]): Global conditioning tensor (B, global_channels, 1).
          inverse (bool): Whether to inverse the flow.
  
      Returns:
          Tensor: Output tensor (B, in_channels, T).
  
      """
      if not inverse:
          for flow in self.flows:
              x, _ = flow(x, x_mask, g=g, inverse=inverse)
      else:
          for flow in reversed(self.flows):
              x = flow(x, x_mask, g=g, inverse=inverse)
      return x
  
file_path: espnet/espnet2/gan_tts/vits/residual_coupling.py
imports: from typing import Optional, Tuple, Union
  import torch
  from espnet2.gan_tts.vits.flow import FlipFlow
  from espnet2.gan_tts.wavenet import WaveNet
label_desc: Use image node_id 2 for calling the ResidualAffineCouplingBlock obj's underlying member method code with example usage: obj.forward(x, x_mask, g, inverse) and returns: x