code: def test_state_dict(self):
      for opt_level in self.test_opt_levels:
          # Skip O3
          if opt_level == "O3":
              continue
  
          model = MyModel().to("cuda")
          optimizer = optim.Adam(model.parameters(), lr=1e-3)
          model, optimizer = amp.initialize(
              model, optimizer, opt_level=opt_level, verbosity=0
          )
  
          # Export state_dict and check for Half
          state_dict = model.state_dict()
          for key in state_dict:
              self.assertFalse("Half" in state_dict[key].type())
  
          # Check, if model is still trainable
          # Create dummy data
          data = torch.randn(10, 3, 4, 4, device="cuda")
          target = torch.randn(10, 6, 4, 4, device="cuda")
  
          # Get initnial loss
          optimizer.zero_grad()
          output = model(data)
          loss = F.mse_loss(output, target)
          with amp.scale_loss(loss, optimizer) as scaled_loss:
              scaled_loss.backward()
          optimizer.step()
          last_loss = loss.item()
  
          # train for some epochs
          for epoch in range(10):
              optimizer.zero_grad()
              output = model(data)
              loss = F.mse_loss(output, target)
              with amp.scale_loss(loss, optimizer) as scaled_loss:
                  scaled_loss.backward()
              optimizer.step()
              self.assertTrue(loss.item() < last_loss)
              last_loss = loss.item()
  
imports: import unittest
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from apex import amp
  from utils import common_init, FLOAT
label_desc: Use image node_id 8 for calling the TestCheckpointing obj's underlying member method code with example usage: obj.test_state_dict() without return types