def cflow_head(
    condition_vector: int,
    coupling_blocks: int,
    clamp_alpha: float,
    n_features: int,
    permute_soft: bool = False,
) -> SequenceINN:
    """Create an invertible decoder network for CFlow.

    Args:
        condition_vector (int): Length of the condition vector
        coupling_blocks (int): Number of coupling blocks in the decoder
        clamp_alpha (float): Clamping value to avoid exploding values
        n_features (int): Number of decoder features
        permute_soft (bool, optional): Whether to sample the permutation matrix
            from SO(N) (True) or use hard permutations (False). Note that
            ``permute_soft=True`` is very slow for >512 dimensions.
            Defaults to False.

    Returns:
        SequenceINN: Invertible decoder network

    Example:
        >>> decoder = cflow_head(
        ...     condition_vector=128,
        ...     coupling_blocks=4,
        ...     clamp_alpha=1.9,
        ...     n_features=256
        ... )
    """
    coder = SequenceINN(n_features)
    logger.info("CNF coder: %d", n_features)
    for _ in range(coupling_blocks):
        coder.append(
            AllInOneBlock,
            cond=0,
            cond_shape=(condition_vector,),
            subnet_constructor=subnet_fc,
            affine_clamping=clamp_alpha,
            global_affine_type="SOFTPLUS",
            permute_soft=permute_soft,
        )
    return coder
Create an invertible decoder network for CFlow.

    Args:
        condition_vector (int): Length of the condition vector
        coupling_blocks (int): Number of coupling blocks in the decoder
        clamp_alpha (float): Clamping value to avoid exploding values
        n_features (int): Number of decoder features
        permute_soft (bool, optional): Whether to sample the permutation matrix
            from SO(N) (True) or use hard permutations (False). Note that
            ``permute_soft=True`` is very slow for >512 dimensions.
            Defaults to False.

    Returns:
        SequenceINN: Invertible decoder network

    Example:
        >>> decoder = cflow_head(
        ...     condition_vector=128,
        ...     coupling_blocks=4,
        ...     clamp_alpha=1.9,
        ...     n_features=256
        ... )
    
src/anomalib/models/image/cflow/utils.py