code: def test_cleanup_param_files_keep_first():
      with tempfile.TemporaryDirectory() as tmp_dir:
          for n in itertools.chain(range(0, 20, 2), range(21, 41)):
              # Create empty files
              open(
                  os.path.join(tmp_dir, C.PARAMS_NAME % n), "w"
              ).close()
          sockeye.training.cleanup_params_files(
              tmp_dir, 5, 40, 16, True, 8, "perplexity", "best"
          )
  
          expectedSurviving = set(
              [
                  os.path.join(tmp_dir, C.PARAMS_NAME % n)
                  for n in [0, 16, 36, 37, 38, 39, 40]
              ]
          )
          # 16 must survive because it is the best one
          # 0 should also survive because we set keep_first to True
          assert (
              set(
                  glob.glob(
                      os.path.join(tmp_dir, C.PARAMS_PREFIX + "*")
                  )
              )
              == expectedSurviving
          )
  
file_path: sockeye/test/unit/test_params.py
imports: import glob
  import itertools
  import os.path
  import tempfile
  import pytest
  import torch
  import sockeye.constants
  import sockeye.encoder
  import sockeye.model
  import sockeye.training
label_desc: Use image node_id 2 for calling a global function with example usage: test_cleanup_param_files_keep_first() without return types