code: def run_iter(self, model, params, optimizer):
      optimizer.zero_grad()
      with autocast():
          y = model(self.x)
          loss = self.loss_fn(y, self.target)
      self.scaler.scale(loss).backward()
      self.assertEqual(
          loss, torch.tensor(1.0, device="cuda:0", dtype=torch.float16)
      )
  
      self.scaler.unscale_(optimizer)
      grad_norm = optimizer.clip_grad_norm(0)
      self.assertAlmostEqual(grad_norm.item(), 2.2361, 4)
  
      self.scaler.step(optimizer)
      self.scaler.update()
      self.assertEqual(
          model.weight,
          torch.tensor([[3.1]], device="cuda:0", requires_grad=True),
      )
      self.assertEqual(
          model.bias,
          torch.tensor([5.1], device="cuda:0", requires_grad=True),
      )
      self.assertEqual(self.scaler.get_scale(), 2.0)
  
file_path: fairseq/tests/test_amp_optimizer.py
imports: import argparse
  import copy
  import unittest
  import torch
  from torch.cuda.amp import GradScaler, autocast
  from fairseq.optim import build_optimizer
label_desc: Use image node_id 2 for calling the TestGradientScalingAMP obj's underlying member method code with example usage: obj.run_iter(model, params, optimizer) without return types