def _slice_csr_matrix(csr, idx):
    """Return a slice of a CSR matrix matching the given indices (applied to both rows and cols"""
    from copy import copy
    m = copy(csr)
    m.data = m.data.copy()
    m.data += 1
    m = m[idx][:, (idx)]
    m.data -= 1
    return m
