def revert_audio_delay(
    audio_BxTxC: mx.array,
    pad_value: int,
    precomp: tp.Tuple[mx.array, mx.array],
    T: int,
) -> mx.array:
    """
    Reverts a delay pattern from batched audio tokens using precomputed indices (MLX version).

    Args:
        audio_BxTxC: Input delayed audio tensor
        pad_value: Padding value for out-of-bounds indices
        precomp: Precomputed revert indices tuple containing:
            - t_idx_BxTxC: Time offset indices tensor
            - indices_BTCx3: Gather indices tensor for original audio
        T: Original sequence length before padding

    Returns:
        Reverted audio tensor with same shape as input
    """
    t_idx_BxTxC, indices_BTCx3 = precomp

    def gather_nd(array, indices):
        gathered = []
        for idx in range(indices.shape[0]):
            b, t, c = indices[idx, 0], indices[idx, 1], indices[idx, 2]
            gathered.append(array[b, t, c])
        return mx.array(gathered)

    gathered_flat = gather_nd(audio_BxTxC, indices_BTCx3)
    gathered_BxTxC = mx.reshape(gathered_flat, audio_BxTxC.shape)
    pad_tensor = mx.full(1, pad_value, dtype=audio_BxTxC.dtype)
    T_tensor = mx.array(T)

    result_BxTxC = mx.where(t_idx_BxTxC >= T_tensor, pad_tensor, gathered_BxTxC)

    return result_BxTxC

    Reverts a delay pattern from batched audio tokens using precomputed indices (MLX version).

    Args:
        audio_BxTxC: Input delayed audio tensor
        pad_value: Padding value for out-of-bounds indices
        precomp: Precomputed revert indices tuple containing:
            - t_idx_BxTxC: Time offset indices tensor
            - indices_BTCx3: Gather indices tensor for original audio
        T: Original sequence length before padding

    Returns:
        Reverted audio tensor with same shape as input
    
mlx_audio/tts/models/dia/audio.py