class_docstr: Log flow module.
class_docstr_tok: ["Log","flow","module","."]
docstr: Calculate forward propagation.
  
  Args:
      x (Tensor): Input tensor (B, channels, T).
      x_mask (Tensor): Mask tensor (B, 1, T).
      inverse (bool): Whether to inverse the flow.
      eps (float): Epsilon for log.
  
  Returns:
      Tensor: Output tensor (B, channels, T).
      Tensor: Log-determinant tensor for NLL (B,) if not inverse.
docstr_tok: ["Calculate","forward","propagation",".","Args",":","x","(","Tensor",")",":","Input","tensor","(","B",",","channels",",","T",")",".","x_mask","(","Tensor",")",":","Mask","tensor","(","B",",","1",",","T",")",".","inverse","(","bool",")",":","Whether","to","inverse","the","flow",".","eps","(","float",")",":","Epsilon","for","log",".","Returns",":","Tensor",":","Output","tensor","(","B",",","channels",",","T",")",".","Tensor",":","Log-determinant","tensor","for","NLL","(","B",",",")","if","not","inverse","."]
code: def forward(
      self,
      x: torch.Tensor,
      x_mask: torch.Tensor,
      inverse: bool = False,
      eps: float = 1e-5,
      **kwargs,
  ) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
      """Calculate forward propagation.
  
      Args:
          x (Tensor): Input tensor (B, channels, T).
          x_mask (Tensor): Mask tensor (B, 1, T).
          inverse (bool): Whether to inverse the flow.
          eps (float): Epsilon for log.
  
      Returns:
          Tensor: Output tensor (B, channels, T).
          Tensor: Log-determinant tensor for NLL (B,) if not inverse.
  
      """
      if not inverse:
          y = torch.log(torch.clamp_min(x, eps)) * x_mask
          logdet = torch.sum(-y, [1, 2])
          return y, logdet
      else:
          x = torch.exp(x) * x_mask
          return x
  
imports: import math
  from typing import Optional, Tuple, Union
  import torch
  from espnet2.gan_tts.vits.transform import piecewise_rational_quadratic_transform
label_desc: Use image node_id 1 for calling the LogFlow obj's underlying member method code with example usage: obj.forward(x, x_mask, inverse, eps) and returns: y,  logdet, x