code: def test_seq_sort(
      name,
      train_params,
      translate_params,
      use_prepared_data,
      n_source_factors,
      n_target_factors,
      perplexity_thresh,
      bleu_thresh,
      compare_output,
  ):
      """Task: sort short sequences of digits"""
      with tmp_digits_dataset(
          "test_seq_sort.",
          _TRAIN_LINE_COUNT,
          _TRAIN_LINE_COUNT_EMPTY,
          _LINE_MAX_LENGTH,
          _DEV_LINE_COUNT,
          _LINE_MAX_LENGTH,
          _TEST_LINE_COUNT,
          _TEST_LINE_COUNT_EMPTY,
          _TEST_MAX_LENGTH,
          sort_target=True,
          seed_train=_SEED_TRAIN_DATA,
          seed_dev=_SEED_DEV_DATA,
          with_n_source_factors=n_source_factors,
          with_n_target_factors=n_target_factors,
      ) as data:
          data = check_train_translate(
              train_params=train_params,
              translate_params=translate_params,
              data=data,
              use_prepared_data=use_prepared_data,
              max_seq_len=_LINE_MAX_LENGTH,
              compare_output=compare_output,
              seed=seed,
          )
  
          # get best validation perplexity
          metrics = sockeye.utils.read_metrics_file(
              os.path.join(data["model"], C.METRICS_NAME)
          )
          perplexity = min(m[C.PERPLEXITY + "-val"] for m in metrics)
  
          # compute metrics
          hypotheses = [
              json["translation"] for json in data["test_outputs"]
          ]
          bleu = sockeye.evaluate.raw_corpus_bleu(
              hypotheses=hypotheses, references=data["test_targets"]
          )
          chrf = sockeye.evaluate.raw_corpus_chrf(
              hypotheses=hypotheses, references=data["test_targets"]
          )
          if "test_outputs_restricted" in data:
              hypotheses_restricted = [
                  json["translation"]
                  for json in data["test_outputs_restricted"]
              ]
              bleu_restrict = sockeye.evaluate.raw_corpus_bleu(
                  hypotheses=hypotheses_restricted,
                  references=data["test_targets"],
              )
          else:
              bleu_restrict = None
  
          logger.info("================")
          logger.info("test results: %s", name)
          logger.info(
              "perplexity=%f, bleu=%f, bleu_restrict=%f chrf=%f",
              perplexity,
              bleu,
              bleu_restrict,
              chrf,
          )
          logger.info("================\n")
          assert perplexity <= perplexity_thresh
          assert bleu >= bleu_thresh
          if bleu_restrict is not None:
              assert bleu_restrict >= bleu_thresh
  
file_path: sockeye/test/system/test_seq_copy_sys.py
imports: import logging
  import os
  import random
  import pytest
  import sockeye.constants
  import sockeye.evaluate
  import sockeye.utils
  from sockeye.test_utils import tmp_digits_dataset
  from test.common import check_train_translate
label_desc: Use image node_id 2 for calling a global function with example usage: test_seq_sort(name, train_params, translate_params, use_prepared_data, n_source_factors, n_target_factors, perplexity_thresh, bleu_thresh, compare_output) without return types