@numba_njit<EOL>def cbow_lookup(context_row, context_col, subwordidxs, subwordidxsptr,<EOL>offset=<NUM_LIT:0>):
row = []<EOL>col = []<EOL>data = []<EOL>num_rows = np.max(context_row) + <NUM_LIT:1><EOL>row_to_numwords = np.zeros(num_rows)<EOL>for i, idx in enumerate(context_col):<EOL><INDENT>start = subwordidxsptr[idx]<EOL>end = subwordidxsptr[idx + <NUM_LIT:1>]<EOL>row_ = context_row[i]<EOL>row_to_numwords[row_] += <NUM_LIT:1><EOL>row.append(row_)<EOL>col.append(idx)<EOL>data.append(<NUM_LIT:1> / (<NUM_LIT:1> + end - start))<EOL>for subword in subwordidxs[start:end]:<EOL><INDENT>row.append(row_)<EOL>col.append(subword + offset)<EOL>data.append(<NUM_LIT:1> / (<NUM_LIT:1> + end - start))<EOL><DEDENT><DEDENT>for i, row_ in enumerate(row):<EOL><INDENT>assert <NUM_LIT:0> <= row_ <= num_rows<EOL>data[i] /= row_to_numwords[row_]<EOL><DEDENT>return (np.array(data, dtype=np.float32), np.array(row, dtype=np.int64),<EOL>np.array(col, dtype=np.int64))<EOL>
Get a sparse COO array of words and subwords for CBOW.

    Parameters
    ----------
    context_row : numpy.ndarray of dtype int64
        Array of same length as context_col containing numbers in [0,
        batch_size). For each idx, context_row[idx] specifies the row that
        context_col[idx] occurs in a sparse matrix.
    context_col : numpy.ndarray of dtype int64
        Array of same length as context_row containing numbers in [0,
        vocabulary_size). For each idx, context_col[idx] is one of the
        context words in the context_row[idx] row of the batch.
    subwordidxs : numpy.ndarray
        Array containing concatenation of all subwords of all tokens in the
        vocabulary, in order of their occurrence in the vocabulary.
        For example np.concatenate(idx_to_subwordidxs)
    subwordidxsptr
        Array containing pointers into subwordidxs array such that
        subwordidxs[subwordidxsptr[i]:subwordidxsptr[i+1]] returns all subwords
        of of token i. For example subwordidxsptr = np.cumsum([
        len(subwordidxs) for subwordidxs in idx_to_subwordidxs])
    offset : int, default 0
        Offset to add to each subword index.

    Returns
    -------
    numpy.ndarray of dtype float32
        Array containing weights summing to 1. The weights are chosen such
        that the sum of weights for all subwords and word units of a given
        context word is equal to 1 / number_of_context_words_in_the_row.
        This array is the data array of a sparse array of COO format.
    numpy.ndarray of dtype int64
        This array is the row array of a sparse array of COO format.
    numpy.ndarray of dtype int64
        This array is the col array of a sparse array of COO format.
        Array containing weights such that for each row, all weights sum to
        1. In particular, all elements in a row have weight 1 /
        num_elements_in_the_row