def _parse_dd_sequence(
    schema: str | tuple[ops.Gate, ...],
) -> tuple[tuple[ops.Gate, ...], dict[ops.Gate, ops.Pauli]]:
    """Parses and returns dynamical decoupling sequence and its associated pauli map from schema."""
    dd_sequence = None
    if isinstance(schema, str):
        dd_sequence = _get_dd_sequence_from_schema_name(schema)
    else:
        _validate_dd_sequence(schema)
        dd_sequence = schema

    # Map gate to Pauli gate. This is necessary as dd sequence might contain gates like X^-1.
    pauli_map: dict[ops.Gate, ops.Pauli] = {}
    for gate in dd_sequence:
        pauli_gate = _pauli_up_to_global_phase(gate)
        if pauli_gate is not None:
            pauli_map[gate] = pauli_gate
    for gate in [ops.X, ops.Y, ops.Z]:
        pauli_map[gate] = gate

    return (dd_sequence, pauli_map)
Parses and returns dynamical decoupling sequence and its associated pauli map from schema.
cirq-core/cirq/transformers/dynamical_decoupling.py