def __init__(self, permutation: Sequence[int]):
        """Create a `cirq.QubitPermutationGate`.

        Args:
            permutation: A shuffled sequence of integers from 0 to
                len(permutation) - 1. The entry at offset `i` is the result
                of permuting `i`.

        Raises:
            ValueError: If the supplied permutation is not valid (empty, repeated indices, indices
                out of range).
        """
        if not permutation:
            raise ValueError(f"Invalid permutation (empty): {permutation}")

        if len(set(permutation)) < len(permutation):
            raise ValueError(f"Invalid permutation {permutation} Each index must appear only once.")

        invalid_indices = [x for x in permutation if not 0 <= x < len(permutation)]
        if len(invalid_indices) > 0:
            raise ValueError(
                f"All indices have to satisfy 0 <= i < {len(permutation)}.\n"
                f"Invalid indices: {invalid_indices}"
            )

        self._permutation = tuple(permutation)
Create a `cirq.QubitPermutationGate`.

        Args:
            permutation: A shuffled sequence of integers from 0 to
                len(permutation) - 1. The entry at offset `i` is the result
                of permuting `i`.

        Raises:
            ValueError: If the supplied permutation is not valid (empty, repeated indices, indices
                out of range).
        
cirq-core/cirq/ops/permutation_gate.py