class_docstr: UFlow Loss.
class_docstr_tok: ["UFlow","Loss","."]
docstr: Calculate the UFlow loss.
  
  Args:
      hidden_variables (list[Tensor]): Hidden variables from the fastflow model. f: X -> Z
      jacobians (list[Tensor]): Log of the jacobian determinants from the fastflow model.
  
  Returns:
      Tensor: UFlow loss computed based on the hidden variables and the log of the Jacobians.
docstr_tok: ["Calculate","the","UFlow","loss",".","Args",":","hidden_variables","(","list","[","Tensor","]",")",":","Hidden","variables","from","the","fastflow","model",".","f",":","X","-",">","Z","jacobians","(","list","[","Tensor","]",")",":","Log","of","the","jacobian","determinants","from","the","fastflow","model",".","Returns",":","Tensor",":","UFlow","loss","computed","based","on","the","hidden","variables","and","the","log","of","the","Jacobians","."]
code: def forward(
      self, hidden_variables: list[Tensor], jacobians: list[Tensor]
  ) -> Tensor:
      """Calculate the UFlow loss.
  
      Args:
          hidden_variables (list[Tensor]): Hidden variables from the fastflow model. f: X -> Z
          jacobians (list[Tensor]): Log of the jacobian determinants from the fastflow model.
  
      Returns:
          Tensor: UFlow loss computed based on the hidden variables and the log of the Jacobians.
      """
      lpz = torch.sum(
          torch.stack(
              [
                  0.5 * torch.sum(z_i**2, dim=(1, 2, 3))
                  for z_i in hidden_variables
              ],
              dim=0,
          )
      )
      flow_loss = torch.mean(lpz - jacobians)
      return flow_loss
  
imports: from __future__ import annotations
  import torch
  from torch import Tensor, nn
label_desc: Use image node_id 1 for calling the UFlowLoss obj's underlying member method code with example usage: obj.forward(hidden_variables, jacobians) and returns: flow_loss