import operator


def _split_data(data, indices):
    """Handles list and sparse/dense matrices
    
    Arguments
    -----
    data: list or matrix
        given data
    indices: indices to choose
        fetch these indices

    Returns
    -------
    chosen data in the same format
    """
    if isinstance(data, list):
        return list(operator.itemgetter(*indices)(data))
    else:
        return data[indices, :]