def METHOD_NAME(
    slack_length: int, gates: List[Gate], spacing: int = -1
) -> Circuit:
    """Returns a digital dynamical decoupling sequence, based on inputs.
    Args:
        slack_length: Length of idle window to fill.
        spacing: How many identity spacing gates to apply between dynamical
            decoupling gates, as a non-negative int. Negative int corresponds
            to default. Defaults to maximal spacing that fits a single sequence
            in the given slack window.
            E.g. given slack_length = 8, gates = [X, X] the spacing defaults
            to 2 and the rule returns the sequence:
            ──I──I──X──I──I──X──I──I──
            given slack_length = 9, gates [X, Y, X, Y] the spacing defaults
            to 1 and the rule returns the sequence:
            ──I──X──I──Y──I──X──I──Y──I──.
        gates: A list of single qubit Cirq gates to build the rule. E.g. [X, X]
            is the xx sequence, [X, Y, X, Y] is the xyxy sequence.
            - Note: To repeat the sequence, specify a repeated gateset.
    Returns:
        A digital dynamical decoupling sequence, as a Cirq circuit.
    """
    if len(gates) < 2:
        raise ValueError("Gateset too short to make a ddd sequence.")
    if slack_length < 2 or slack_length < len(gates):
        return Circuit()
    num_decoupling_gates = len(gates)
    slack_difference = slack_length - num_decoupling_gates
    if spacing < 0:
        spacing = slack_difference // (num_decoupling_gates + 1)
    slack_remainder = slack_length - (
        spacing * (num_decoupling_gates + 1) + num_decoupling_gates
    )
    if slack_remainder < 0:
        return Circuit()
    q = LineQubit(0)
    slack_gates = [I(q) for _ in range(spacing)]
    sequence = Circuit(slack_gates)
    for gate in gates:
        sequence.append(gate.on(q))
        sequence.append(slack_gates)
    if not allclose_up_to_global_phase(np.eye(2), unitary(sequence)):
        raise ValueError("Sequence is not equivalent to the identity!")
    for i in range(slack_remainder):
        sequence.append(I(q)) if i % 2 else sequence.insert(0, I(q))
    return sequence