'''
Translates a source file using a translation model.
'''
import argparse

import numpy
import cPickle as pkl

from nmt import (build_sampler, init_params)
from mixer import *

from multiprocessing import Process, Queue


def gen_sample(tparams, f_inits, f_nexts, x, options, trng=None,
               k=1, maxlen=500, stochastic=True, argmax=False):

    # k is the beam size we have
    if k > 1:
        assert not stochastic, \
            'Beam search does not support stochastic sampling'

    sample = []
    sample_score = []
    if stochastic:
        sample_score = 0

    live_k = 1
    dead_k = 0

    hyp_samples = [[]] * live_k
    hyp_scores = numpy.zeros(live_k).astype('float32')
    hyp_states = []

    # get initial state of decoder rnn and encoder context
    rets = []
    next_state_chars = []
    next_state_words = []
    next_bound_chars = []
    next_bound_words = []
    ctx0s = []

    for f_init in f_inits:
        ret = f_init(x)