def METHOD_NAME(self, states):
    token, index = self.model.predict_from_states(states)
    if (
        index == self.dict["tgt"].eos()
        or len(states["tokens"]["tgt"]) > self.max_len
    ):
        # Finish this sentence is predict EOS
        states["finished"] = True
        end_idx_last_full_word = self._target_length(states)
    else:
        states["tokens"]["tgt"] += [token]
        end_idx_last_full_word = self.word_splitter["tgt"].end_idx_last_full_word(
            states["tokens"]["tgt"]
        )
        self._append_indices(states, [index], "tgt")
    if end_idx_last_full_word > states["steps"]["tgt"]:
        # Only sent detokenized full words to the server
        word = self.word_splitter["tgt"].merge(
            states["tokens"]["tgt"][states["steps"]["tgt"] : end_idx_last_full_word]
        )
        states["steps"]["tgt"] = end_idx_last_full_word
        states["segments"]["tgt"] += [word]
        return {"key": SEND, "value": word}
    else:
        return None