code: def test_resets(self):
      with mock_env_with_temp():
          checkpoint = Checkpoint(self.trainer)
          self._init_early_stopping(checkpoint)
          self._do_a_pass()
  
          original_optimizer = deepcopy(self.trainer.optimizer)
          original_model = deepcopy(self.trainer.model)
          original_scaler = deepcopy(self.trainer.scaler)
  
          self.trainer.current_epoch = 3
          checkpoint.save(2000, update_best=True)
          self.trainer.current_epoch = 4
          # Test reset all
          self.trainer.config.checkpoint.resume = True
          self.trainer.config.checkpoint.reset.all = True
          checkpoint.load_state_dict()
  
          self.assertTrue(
              compare_state_dicts(
                  self.trainer.model.state_dict(),
                  original_model.state_dict(),
              )
          )
  
          self.assertTrue(
              self._compare_optimizers(
                  self.trainer.optimizer, original_optimizer
              )
          )
  
          self.assertTrue(
              compare_state_dicts(
                  self.trainer.scaler.state_dict(),
                  original_scaler.state_dict(),
              )
          )
  
          self.assertEqual(self.trainer.num_updates, 0)
          self.assertEqual(self.trainer.current_iteration, 0)
          self.assertEqual(self.trainer.current_epoch, 4)
  
          # Test reset_optimizer
          self._init_early_stopping(checkpoint)
          self.trainer.config.checkpoint.reset.all = False
          self.trainer.config.checkpoint.reset.optimizer = True
          checkpoint.load_state_dict()
  
          self.assertTrue(
              compare_state_dicts(
                  self.trainer.model.state_dict(),
                  original_model.state_dict(),
              )
          )
  
          self.assertTrue(
              self._compare_optimizers(
                  self.trainer.optimizer, original_optimizer
              )
          )
  
          self.assertEqual(self.trainer.num_updates, 2000)
          self.assertEqual(self.trainer.current_iteration, 2000)
          self.assertEqual(self.trainer.current_epoch, 3)
  
          self._init_early_stopping(checkpoint)
          # Test reset_counts
          self.trainer.config.checkpoint.reset.all = False
          self.trainer.config.checkpoint.reset.optimizer = False
          self.trainer.config.checkpoint.reset.counts = True
          checkpoint.load_state_dict()
  
          self.assertTrue(
              compare_state_dicts(
                  self.trainer.model.state_dict(),
                  original_model.state_dict(),
              )
          )
  
          self.assertTrue(
              self._compare_optimizers(
                  self.trainer.optimizer, original_optimizer
              )
          )
          self.assertEqual(self.trainer.num_updates, 0)
          self.assertEqual(self.trainer.current_iteration, 0)
          self.assertEqual(self.trainer.current_epoch, 2)
  
          # Test with resume_best
          self._do_a_pass()
          checkpoint.save(3000)
          self._init_early_stopping(checkpoint)
          self.trainer.config.checkpoint.reset.all = False
          self.trainer.config.checkpoint.resume_best = True
          self.trainer.config.checkpoint.reset.optimizer = True
          self.trainer.config.checkpoint.reset.counts = False
          checkpoint.load_state_dict()
  
          self.assertTrue(
              compare_state_dicts(
                  self.trainer.model.state_dict(),
                  original_model.state_dict(),
              )
          )
  
          self.assertFalse(
              self._compare_optimizers(
                  self.trainer.optimizer, original_optimizer
              )
          )
  
          self.assertEqual(self.trainer.num_updates, 1000)
          self.assertEqual(self.trainer.current_iteration, 1000)
          self.assertEqual(self.trainer.current_epoch, 3)
  
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 6 for calling the TestUtilsCheckpoint obj's underlying member method code with example usage: obj.test_resets() without return types