def extract_channel(k, cdim):
    """Create a :class:`CPermutation` that extracts channel `k`

    Return a permutation circuit that maps the k-th (zero-based)
    input to the last output, while preserving the relative order of all other
    channels.

    Args:
        k (int): Extracted channel index
        cdim (int): The circuit dimension (number of channels)

    Returns:
        Circuit: Permutation circuit
    """
    n = cdim
    perm = tuple(list(range(k)) + [n - 1] + list(range(k, n - 1)))
    return CPermutation.create(perm)
def extract_channel ( k , cdim ) : n = cdim perm = tuple ( list ( range ( k ) ) + [ n - 1 ] + list ( range ( k , n - 1 ) ) ) return CPermutation . create ( perm )
Create a :class:`CPermutation` that extracts channel `k`

    Return a permutation circuit that maps the k-th (zero-based)
    input to the last output, while preserving the relative order of all other
    channels.

    Args:
        k (int): Extracted channel index
        cdim (int): The circuit dimension (number of channels)

    Returns:
        Circuit: Permutation circuit