def __init__(self, args, model, vocab, symbols, global_scorer=None, logger=None, dump_beam=''):
    self.logger = logger
    self.cuda = (args.visible_gpus != '-1')
    self.args = args
    self.model = model
    self.generator = self.model.generator
    self.vocab = vocab
    self.symbols = symbols
    self.start_token = symbols['BOS']
    self.end_token = symbols['EOS']
    self.global_scorer = global_scorer
    self.beam_size = args.beam_size
    self.min_length = args.min_length
    self.max_length = args.max_length
    self.dump_beam = dump_beam
    self.beam_trace = (self.dump_beam != '')
    self.beam_accum = None
    tensorboard_log_dir = args.model_path
    self.tensorboard_writer = SummaryWriter(tensorboard_log_dir, comment='Unmt')
    if self.beam_trace:
        self.beam_accum = {'predicted_ids': [], 'beam_parent_ids': [], 'scores': [], 'log_probs': []}
def __init__(self, args, model, vocab, symbols, global_scorer=None, logger=None, dump_beam=):
    self.logger = logger
    self.cuda = (args.visible_gpus != '-1')
    self.args = args
    self.model = model
    self.generator = self.model.generator
    self.vocab = vocab
    self.symbols = symbols
    self.start_token = symbols['BOS']
    self.end_token = symbols['EOS']
    self.global_scorer = global_scorer
    self.beam_size = args.beam_size
    self.min_length = args.min_length
    self.max_length = args.max_length
    self.dump_beam = dump_beam
    self.beam_trace = (self.dump_beam != )
    self.beam_accum = None
    tensorboard_log_dir = args.model_path
    self.tensorboard_writer = SummaryWriter(tensorboard_log_dir, comment='Unmt')
    if self.beam_trace:
        self.beam_accum = {'predicted_ids': [], 'beam_parent_ids': [], 'scores': [], 'log_probs': []}