def get_csr_position(index, shape, crow_indices, col_indices):
    """Return the position of index in CSR indices representation. If
    index is not in indices, return None.
    """
    # binary search
    row, col = index
    left = crow_indices[row]
    right = crow_indices[row+1] - 1
    while left <= right:
        i = (left + right) // 2
        d = col_indices[i] - col
        if d == 0:
            return i
        if d < 0:
            left = i + 1
        elif d > 0:
            right = i - 1
    # index is not in indices
    return