def _pre_permute(self, x: torch.Tensor, rev: bool = False) -> torch.Tensor:
        """Permute before coupling block.

        Only used if ``reverse_permutation`` is True.

        Args:
            x (torch.Tensor): Input tensor
            rev (bool, optional): Reverse the permutation. Defaults to False.

        Returns:
            torch.Tensor: Permuted tensor
        """
        if rev:
            return self.permute_function(x, self.w_perm)

        return self.permute_function(x, self.w_perm_inv)
Permute before coupling block.

        Only used if ``reverse_permutation`` is True.

        Args:
            x (torch.Tensor): Input tensor
            rev (bool, optional): Reverse the permutation. Defaults to False.

        Returns:
            torch.Tensor: Permuted tensor
        
src/anomalib/models/components/flow/all_in_one_block.py