code: def test_unfused_gradnorm(self, monkeypatch):
      if not required_torch_version():
          pytest.skip(
              "DeepSpeed MoE tests need torch 1.8 or higher to run correctly"
          )
  
      config_dict = {
          "train_batch_size": 2,
          "steps_per_print": 1,
          "fp16": {"enabled": True},
      }
      hidden_dim = 10
  
      def mock_unscale_and_clip_grads(total_norm, apply_scale=True):
          torch_norm_tensor = torch.cuda.FloatTensor([total_norm])
          all_gather_results = [
              torch.zeros_like(torch_norm_tensor)
              for _ in range(dist.get_world_size())
          ]
          dist.all_gather(all_gather_results, torch_norm_tensor)
          assert len(set([x.item() for x in all_gather_results])) == 1
          return 1.0
  
      # initialize MoE
      model = SimpleMoEModel(hidden_dim, ep_size=2)
      optimizer = torch.optim.AdamW(params=model.parameters())
      engine, optimizer, _, _ = deepspeed.initialize(
          config=config_dict,
          model=model,
          optimizer=optimizer,
          dist_init_required=False,
      )
      monkeypatch.setattr(
          optimizer,
          "unscale_and_clip_grads",
          mock_unscale_and_clip_grads,
      )
      data_loader = sequence_dataloader(
          model=engine,
          total_samples=50,
          hidden_dim=hidden_dim,
          device=engine.device,
      )
      for n, batch in enumerate(data_loader):
          loss = engine(batch[0], batch[1])
          engine.backward(loss)
          engine.step()
  
imports: import torch
  import deepspeed.comm
  import deepspeed
  import pytest
  from deepspeed.ops.adam import FusedAdam
  from unit.common import DistributedTest
  from deepspeed.ops.op_builder import CPUAdamBuilder
  from unit.simple_model import SimpleModel, SimpleOptimizer, random_dataloader, SimpleMoEModel, sequence_dataloader
  from unit.util import required_torch_version
label_desc: Use image node_id 1 for calling the TestFP16OptimizerForMoE obj's underlying member method code with example usage: obj.test_unfused_gradnorm(monkeypatch) and returns: int