code: def check_train_translate(
      train_params: str,
      translate_params: str,
      data: Dict[str, Any],
      use_prepared_data: bool,
      max_seq_len: int,
      compare_output: bool = True,
      seed: int = 13,
  ) -> Dict[str, Any]:
      """
      Tests core features (training, inference).
      """
      # train model and translate test set
      data = run_train_translate(
          train_params=train_params,
          translate_params=translate_params,
          data=data,
          use_prepared_data=use_prepared_data,
          max_seq_len=max_seq_len,
          seed=seed,
      )
  
      # Test equivalence of batch decoding
      # With neural-vocab-selection the vocabulary is determined on the batch level so that batch and non-batch outputs
      # may differ.
      if (
          "greedy" not in translate_params
          and "neural-vocab-selection" not in train_params
      ):
          translate_params_batch = translate_params + " --batch-size 2"
          test_translate_equivalence(
              data,
              translate_params_batch,
              compare_output=compare_output,
          )
  
      # Run translate with restrict-lexicon
      if "neural-vocab-selection " not in train_params:
          data = run_translate_restrict(data, translate_params)
  
      test_translate_equivalence(
          data, translate_params, compare_output=compare_output
      )
  
      # Test scoring by ensuring that the sockeye.scoring module produces the same scores when scoring the output
      # of sockeye.translate. However, since this training is on very small datasets, the output of sockeye.translate
      # is often pure garbage or empty and cannot be scored. So we only try to score if we have some valid output
      # to work with.
      # Only run scoring under these conditions. Why?
      # - translate splits up too-long sentences and translates them in sequence, invalidating the score, so skip that
      # - scoring requires valid translation output to compare against
      if (
          "--max-input-length" not in translate_params
          and _translate_output_is_valid(data["test_outputs"])
          and "greedy" not in translate_params
          and "neural-vocab-selection" not in train_params
          and _translate_output_is_valid(
              data["test_with_target_prefix_outputs"]
          )
      ):
          test_scoring(
              data, train_params, translate_params, compare_output
          )
  
      # Test correct prediction of target factors if enabled
      if compare_output and "train_target_factors" in data:
          test_odd_even_target_factors(data)
  
      return data
  
file_path: sockeye/test/common.py
imports: import logging
  import os
  import sys
  from contextlib import ExitStack
  from typing import Any, Dict, List
  from unittest.mock import patch
  import numpy
  import sockeye.score
  import sockeye.translate
  from sockeye import constants
  from sockeye.test_utils import run_train_translate, run_translate_restrict, TRANSLATE_PARAMS_COMMON, TRANSLATE_WITH_FACTORS_COMMON, collect_translate_output_and_scores, SCORE_PARAMS_COMMON, SCORE_WITH_SOURCE_FACTORS_COMMON, SCORE_WITH_TARGET_FACTORS_COMMON, TRANSLATE_WITH_JSON_FORMAT
label_desc: Use image node_id 1 for calling a global function with example usage: check_train_translate(train_params, translate_params, data, use_prepared_data, max_seq_len, compare_output, seed) and returns: data