def transform_qubits(
        self, qubit_map: dict[cirq.Qid, cirq.Qid] | Callable[[cirq.Qid], cirq.Qid]
    ) -> Self:
        """Returns the same operation, but with different qubits.

        This function will return a new operation with the same gate but
        with qubits mapped according to the argument.

        For example, the following will translate LineQubits to GridQubits
        using a grid with 4 columns:

        >>> op = cirq.CZ(cirq.LineQubit(5), cirq.LineQubit(9))
        >>> op.transform_qubits(lambda q: cirq.GridQubit(q.x // 4, q.x % 4))
        cirq.CZ(cirq.GridQubit(1, 1), cirq.GridQubit(2, 1))

        This can also be used with a dictionary that has a mapping, such
        as the following which maps named qubits to line qubits:

        >>> a = cirq.NamedQubit('alice')
        >>> b = cirq.NamedQubit('bob')
        >>> d = {a: cirq.LineQubit(4), b: cirq.LineQubit(5)}
        >>> op = cirq.CNOT(a, b)
        >>> op.transform_qubits(d)
        cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(5))

        Args:
            qubit_map: A function or a dict mapping each current qubit into a desired
                new qubit.

        Returns:
            The receiving operation but with qubits transformed by the given
                function.
        Raises:
            TypeError: qubit_map was not a function or dict mapping qubits to
                qubits.
        """
        if callable(qubit_map):
            transform = qubit_map
        elif isinstance(qubit_map, dict):
            transform = lambda q: qubit_map.get(q, q)
        else:
            raise TypeError('qubit_map must be a function or dict mapping qubits to qubits.')
        return self.with_qubits(*(transform(q) for q in self.qubits))
Returns the same operation, but with different qubits.

        This function will return a new operation with the same gate but
        with qubits mapped according to the argument.

        For example, the following will translate LineQubits to GridQubits
        using a grid with 4 columns:

        >>> op = cirq.CZ(cirq.LineQubit(5), cirq.LineQubit(9))
        >>> op.transform_qubits(lambda q: cirq.GridQubit(q.x // 4, q.x % 4))
        cirq.CZ(cirq.GridQubit(1, 1), cirq.GridQubit(2, 1))

        This can also be used with a dictionary that has a mapping, such
        as the following which maps named qubits to line qubits:

        >>> a = cirq.NamedQubit('alice')
        >>> b = cirq.NamedQubit('bob')
        >>> d = {a: cirq.LineQubit(4), b: cirq.LineQubit(5)}
        >>> op = cirq.CNOT(a, b)
        >>> op.transform_qubits(d)
        cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(5))

        Args:
            qubit_map: A function or a dict mapping each current qubit into a desired
                new qubit.

        Returns:
            The receiving operation but with qubits transformed by the given
                function.
        Raises:
            TypeError: qubit_map was not a function or dict mapping qubits to
                qubits.
        
cirq-core/cirq/ops/raw_types.py