code: def test_checkpoint_scaler_loading(self):
      with mock_env_with_temp():
          original_scaler = deepcopy(self.trainer.scaler)
  
          checkpoint = Checkpoint(self.trainer)
          self._init_early_stopping(checkpoint)
  
          self._do_a_fp16_pass()
          checkpoint.save(1000)
          self.trainer.config.checkpoint.resume = True
          self.trainer.config.checkpoint.reset.all = False
          self.trainer.config.checkpoint.reset.optimizer = True
          self.trainer.config.checkpoint.reset.counts = True
          self.trainer.config.checkpoint.reset.fp16_scaler = True
  
          # Reset to make it same as the default grad scaler
          self.trainer.scaler = torch.cuda.amp.GradScaler()
          checkpoint.load_state_dict()
          self.assertTrue(
              compare_state_dicts(
                  self.trainer.scaler.state_dict(),
                  original_scaler.state_dict(),
              )
          )
  
          self._do_a_fp16_pass()
          checkpoint.save(2000)
          self.trainer.config.checkpoint.reset.all = False
          self.trainer.config.checkpoint.reset.optimizer = True
          self.trainer.config.checkpoint.reset.counts = True
          self.trainer.config.checkpoint.reset.fp16_scaler = False
  
          # Reset again to make it same as the default grad scaler
          self.trainer.scaler = torch.cuda.amp.GradScaler()
          checkpoint.load_state_dict()
          self.assertFalse(
              compare_state_dicts(
                  self.trainer.scaler.state_dict(),
                  original_scaler.state_dict(),
              )
          )
  
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 7 for calling the TestUtilsCheckpoint obj's underlying member method code with example usage: obj.test_checkpoint_scaler_loading() without return types