def update_mapping(
        self, mapping: dict[ops.Qid, LogicalIndex], keys: Sequence[cirq.Qid]
    ) -> None:
        """Updates a mapping (in place) from qubits to logical indices.

        Args:
            mapping: The mapping to update.
            keys: The qubits acted on by the gate.
        """
        permutation = self.permutation()
        indices = tuple(permutation.keys())
        new_keys = [keys[permutation[i]] for i in indices]
        old_elements = [mapping.get(keys[i]) for i in indices]
        for new_key, old_element in zip(new_keys, old_elements):
            if old_element is None:
                if new_key in mapping:
                    del mapping[new_key]
            else:
                mapping[new_key] = old_element
Updates a mapping (in place) from qubits to logical indices.

        Args:
            mapping: The mapping to update.
            keys: The qubits acted on by the gate.
        
cirq-core/cirq/contrib/acquaintance/permutation.py