for vocab in vocabs:
if vocab[0] == "src":
enc_vocab = vocab[1]
if vocab[0] == "tgt":
dec_vocab = vocab[1]
assert enc_vocab is not None and dec_vocab is not None
logger.info("From: %s" % dict_file)
logger.info("\t* source vocab: %d words" % len(enc_vocab))
After Change
fields = torch.load(dict_path)
if old_style_vocab(fields):
enc_vocab = next((v for n, v in fields if n == "src"), None)
dec_vocab = next((v for n, v in fields if n == "tgt"), None)
else:
enc_vocab = fields["src"][0][1].vocab
dec_vocab = fields["tgt"][0][1].vocab