code: def test_max_to_keep(self):
      with mock_env_with_temp():
          checkpoint = Checkpoint(self.trainer)
          self._init_early_stopping(checkpoint)
  
          ckpt_paths = []
          for indx in [2000, 3000, 4000, 5000, 6000]:
              self._do_a_pass()
              checkpoint.save(indx, update_best=False)
  
              ckpt_paths.append(
                  os.path.join(
                      checkpoint.models_foldername,
                      "model_%d.ckpt" % indx,
                  )
              )
              self.assertTrue(os.path.exists(ckpt_paths[-1]))
  
          for indx, u in enumerate([7000, 8000, 9000, 10000, 11000]):
              self._do_a_pass()
              checkpoint.save(u, update_best=False)
  
              ckpt_paths.append(
                  os.path.join(
                      checkpoint.models_foldername, "model_%d.ckpt" % u
                  )
              )
              self.assertTrue(os.path.exists(ckpt_paths[-1]))
              self.assertFalse(os.path.exists(ckpt_paths[indx]))
  
imports: import contextlib
  import os
  import tempfile
  import unittest
  from copy import deepcopy
  from io import StringIO
  from unittest.mock import Mock, patch
  import torch
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.trainers.callbacks.checkpoint import CheckpointCallback
  from mmf.trainers.callbacks.early_stopping import EarlyStoppingCallback
  from mmf.trainers.callbacks.lr_scheduler import LRSchedulerCallback
  from mmf.utils.checkpoint import Checkpoint
  from mmf.utils.configuration import load_yaml
  from mmf.utils.file_io import PathManager
  from omegaconf import OmegaConf
  from tests.test_utils import compare_state_dicts, skip_if_no_cuda
label_desc: Use image node_id 8 for calling the TestUtilsCheckpoint obj's underlying member method code with example usage: obj.test_max_to_keep() without return types