def load_translation_data(dataset, src_lang='<STR_LIT>', tgt_lang='<STR_LIT>'):
if dataset == '<STR_LIT>':<EOL><INDENT>common_prefix = '<STR_LIT>'.format(src_lang, tgt_lang,<EOL>hparams.src_max_len, hparams.tgt_max_len)<EOL>data_train = nlp.data.WMT2014BPE('<STR_LIT:train>', src_lang=src_lang, tgt_lang=tgt_lang)<EOL>data_val = nlp.data.WMT2014BPE('<STR_LIT>', src_lang=src_lang, tgt_lang=tgt_lang)<EOL>data_test = nlp.data.WMT2014BPE('<STR_LIT>', src_lang=src_lang, tgt_lang=tgt_lang,<EOL>full=False)<EOL><DEDENT>elif dataset == '<STR_LIT>':<EOL><INDENT>common_prefix = '<STR_LIT>'.format(src_lang, tgt_lang,<EOL>hparams.src_max_len, hparams.tgt_max_len)<EOL>data_train = nmt.dataset.TOY('<STR_LIT:train>', src_lang=src_lang, tgt_lang=tgt_lang)<EOL>data_val = nmt.dataset.TOY('<STR_LIT>', src_lang=src_lang, tgt_lang=tgt_lang)<EOL>data_test = nmt.dataset.TOY('<STR_LIT:test>', src_lang=src_lang, tgt_lang=tgt_lang)<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>src_vocab, tgt_vocab = data_train.src_vocab, data_train.tgt_vocab<EOL>data_train_processed = load_cached_dataset(common_prefix + '<STR_LIT>')<EOL>if not data_train_processed:<EOL><INDENT>data_train_processed = process_dataset(data_train, src_vocab, tgt_vocab,<EOL>hparams.src_max_len, hparams.tgt_max_len)<EOL>cache_dataset(data_train_processed, common_prefix + '<STR_LIT>')<EOL><DEDENT>data_val_processed = load_cached_dataset(common_prefix + '<STR_LIT>')<EOL>if not data_val_processed:<EOL><INDENT>data_val_processed = process_dataset(data_val, src_vocab, tgt_vocab)<EOL>cache_dataset(data_val_processed, common_prefix + '<STR_LIT>')<EOL><DEDENT>data_test_processed = load_cached_dataset(common_prefix + '<STR_LIT:_>' + str(False) + '<STR_LIT>')<EOL>if not data_test_processed:<EOL><INDENT>data_test_processed = process_dataset(data_test, src_vocab, tgt_vocab)<EOL>cache_dataset(data_test_processed, common_prefix + '<STR_LIT:_>' + str(False) + '<STR_LIT>')<EOL><DEDENT>fetch_tgt_sentence = lambda src, tgt: tgt<EOL>if dataset == '<STR_LIT>':<EOL><INDENT>val_text = nlp.data.WMT2014('<STR_LIT>', src_lang=src_lang, tgt_lang=tgt_lang)<EOL>test_text = nlp.data.WMT2014('<STR_LIT>', src_lang=src_lang, tgt_lang=tgt_lang,<EOL>full=False)<EOL><DEDENT>elif dataset == '<STR_LIT>':<EOL><INDENT>val_text = data_val<EOL>test_text = data_test<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>val_tgt_sentences = list(val_text.transform(fetch_tgt_sentence))<EOL>test_tgt_sentences = list(test_text.transform(fetch_tgt_sentence))<EOL>return data_train_processed, data_val_processed, data_test_processed, val_tgt_sentences, test_tgt_sentences, src_vocab, tgt_vocab<EOL>
Load translation dataset

    Parameters
    ----------
    dataset : str
    src_lang : str, default 'en'
    tgt_lang : str, default 'de'

    Returns
    -------