(sentence, vocab_size)
return x
Convert a sentence into a bag of words representation
    Args
        - sentence: a list of token ids
        - vocab_size: V
    Returns
        - bow: a integer vector of size V
Convert a sentence into a bag of words representation
    Args
        - sentence: a list of token ids
        - vocab_size: V
    Returns
        - bow: a integer vector of size V
Convert a sentence into a bag of words representation Args - sentence : a list of token ids - vocab_size : V Returns - bow : a integer vector of size V
def to_bow(sentence, vocab_size):
    '''  Convert a sentence into a bag of words representation
    Args
        - sentence: a list of token ids
        - vocab_size: V
    Returns
        - bow: a integer vector of size V
    '''
    bow = Counter(sentence)
    # Remove EOS tokens
    bow[PAD_ID] = 0
    bow[EOS_ID] = 0

    x = np.zeros(vocab_size, dtype=np.int64)
    x[list(bow.keys())] = list(bow.values())

    return x
def to_bow ( sentence , vocab_size ) : bow = Counter ( sentence ) # Remove EOS tokens bow [ PAD_ID ] = 0 bow [ EOS_ID ] = 0 x = np . zeros ( vocab_size , dtype = np . int64 ) x [ list ( bow . keys ( ) ) ] = list ( bow . values ( ) ) return x