code: def test_all_overflow(self):
      config_dict = {
          "train_batch_size": 1,
          "steps_per_print": 1,
          "optimizer": {"type": "Adam", "params": {"lr": 0.00015}},
          "fp16": {
              "enabled": True,
              "loss_scale": 0,
              "initial_scale_power": 4,
              "loss_scale_window": 2,
          },
      }
      hidden_dim = 1
      model = SimpleModel(hidden_dim)
      model, optim, _, _ = deepspeed.initialize(
          config=config_dict,
          model=model,
          model_parameters=model.parameters(),
      )
  
      expected_loss_scale = 2**4
      # Ensure the dynamic loss scaler is correctly configured.
      assert optim.dynamic_loss_scale == True
      assert optim.cur_scale == expected_loss_scale
  
      overflow_gradients = [float("inf"), float("-inf")] + [
          float("nan")
      ] * 6
      for i, value in enumerate(overflow_gradients):
          run_model_step(model, [value])
          expected_loss_scale = max(expected_loss_scale / 2, 1)
          assert optim.cur_scale == expected_loss_scale
          assert optim.cur_iter == (i + 1)
  
file_path: DeepSpeed/tests/unit/runtime/half_precision/test_dynamic_loss_scale.py
imports: import torch
  import deepspeed
  import numpy
  from unit.common import DistributedTest
  from unit.simple_model import SimpleModel
label_desc: Use image node_id 2 for calling the TestFused obj's underlying member method code with example usage: obj.test_all_overflow() without return types