If I read your code correctly it will get you the hidden state for the first input word (data[0, ..] ) instead for the last one.
Here’s a complete example that gets you the hidden state for the last word:
model: SequentialRNN = <Lesson 4 or 10 model>
encoder: RNN_Encoder = model[0]
ary = np.reshape(np.array(tokensAsNumbers), (-1, 1))
hidden_states, outputs_with_dropout = encoder(V(ary))
hidden_states_last_layer = hidden_states[-1]
hidden_state_last_word = hidden_states_last_layer[-1].squeeze()
feature_vec = to_np(hidden_state_last_word.data)