code: def check_grads_unscaled(self, optimizer=None):
      if optimizer is not None:
          scaler = self.trainer.precision_plugin.scaler
          state = scaler._per_optimizer_states[id(optimizer)]
          assert state["stage"].name == "UNSCALED"
  
      grads = [p.grad for p in self.parameters()]
      assert len(grads) == len(self.original_grads)
      for actual, expected in zip(grads, self.original_grads):
          torch.testing.assert_close(actual, expected, equal_nan=True)
  
imports: import os
  import re
  from unittest import mock
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.plugins import MixedPrecision
  from torch import Tensor
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 2 for calling the TestPrecisionModel obj's underlying member method code with example usage: obj.check_grads_unscaled(optimizer) without return types