def forward(
        self,
        x: torch.Tensor,
        c: list | None = None,
        rev: bool = False,
        jac: bool = True,
    ) -> tuple[tuple[torch.Tensor], torch.Tensor]:
        """Forward pass through the invertible block.

        Args:
            x (torch.Tensor): Input tensor
            c (list, optional): Conditioning tensors. Defaults to None.
            rev (bool, optional): Reverse the flow. Defaults to False.
            jac (bool, optional): Compute Jacobian determinant. Defaults to True.

        Returns:
            tuple[tuple[torch.Tensor], torch.Tensor]: Tuple of (output tensors,
                LogJacDet)
        """
        del jac  # Unused argument.

        if c is None:
            c = []

        if self.householder:
            self.w_perm = self._construct_householder_permutation()
            if rev or self.reverse_pre_permute:
                self.w_perm_inv = self.w_perm.transpose(0, 1).contiguous()

        if rev:
            x, global_scaling_jac = self._permute(x[0], rev=True)
            x = (x,)
        elif self.reverse_pre_permute:
            x = (self._pre_permute(x[0], rev=False),)

        x1, x2 = torch.split(x[0], self.splits, dim=1)

        x1c = torch.cat([x1, *c], 1) if self.conditional else x1

        if not rev:
            a1 = self.subnet(x1c)
            x2, j2 = self._affine(x2, a1)
        else:
            a1 = self.subnet(x1c)
            x2, j2 = self._affine(x2, a1, rev=True)

        log_jac_det = j2
        x_out = torch.cat((x1, x2), 1)

        if not rev:
            x_out, global_scaling_jac = self._permute(x_out, rev=False)
        elif self.reverse_pre_permute:
            x_out = self._pre_permute(x_out, rev=True)

        # add the global scaling Jacobian to the total.
        # trick to get the total number of non-channel dimensions:
        # number of elements of the first channel of the first batch member
        n_pixels = x_out[0, :1].numel()
        log_jac_det += (-1) ** rev * n_pixels * global_scaling_jac

        return (x_out,), log_jac_det
Forward pass through the invertible block.

        Args:
            x (torch.Tensor): Input tensor
            c (list, optional): Conditioning tensors. Defaults to None.
            rev (bool, optional): Reverse the flow. Defaults to False.
            jac (bool, optional): Compute Jacobian determinant. Defaults to True.

        Returns:
            tuple[tuple[torch.Tensor], torch.Tensor]: Tuple of (output tensors,
                LogJacDet)
        
src/anomalib/models/components/flow/all_in_one_block.py