def build_revert_indices(
    B: int, T: int, C: int, delay_pattern: tp.List[int]
) -> tp.Tuple[mx.array, mx.array]:
    """
    Precompute indices for the revert operation using MLX.

    Returns:
        A tuple (t_idx_BxTxC, indices_BTCx3) where:
            - t_idx_BxTxC is a tensor of shape [B, T, C] computed as time indices plus the delay.
            - indices_BTCx3 is a tensor of shape [B*T*C, 3] used for gathering, computed from:
                batch indices, clamped time indices, and channel indices.
    """
    delay_arr = mx.array(delay_pattern, dtype=mx.int32)

    t_idx_BT1 = mx.broadcast_to(mx.expand_dims(mx.arange(T), 0), [B, T])
    t_idx_BT1 = mx.expand_dims(t_idx_BT1, -1)

    t_idx_BxTxC = mx.minimum(
        t_idx_BT1 + mx.reshape(delay_arr, (1, 1, C)),
        mx.array(T - 1, dtype=mx.int32),
    )
    b_idx_BxTxC = mx.broadcast_to(mx.reshape(mx.arange(B), (B, 1, 1)), [B, T, C])
    c_idx_BxTxC = mx.broadcast_to(mx.reshape(mx.arange(C), (1, 1, C)), [B, T, C])

    indices_BTCx3 = mx.stack(
        [
            mx.reshape(b_idx_BxTxC, (-1,)),
            mx.reshape(t_idx_BxTxC, (-1,)),
            mx.reshape(c_idx_BxTxC, (-1,)),
        ],
        axis=1,
    ).astype(mx.int32)

    return t_idx_BxTxC, indices_BTCx3

    Precompute indices for the revert operation using MLX.

    Returns:
        A tuple (t_idx_BxTxC, indices_BTCx3) where:
            - t_idx_BxTxC is a tensor of shape [B, T, C] computed as time indices plus the delay.
            - indices_BTCx3 is a tensor of shape [B*T*C, 3] used for gathering, computed from:
                batch indices, clamped time indices, and channel indices.
    
mlx_audio/tts/models/dia/audio.py