code: def on_before_optimizer_step(
      self, trainer, pl_module, optimizer, optimizer_idx
  ):
      for param in pl_module.parameters():
          self.assertLessEqual(param.grad, self.grad_clip_magnitude)
  
      for lightning_param in pl_module.parameters():
          lightning_grad = (
              torch.clone(lightning_param.grad).detach().item()
          )
          self.lightning_grads.append(lightning_grad)
  
file_path: mmf/tests/trainers/lightning/test_grad_clipping.py
imports: import unittest
  from unittest.mock import MagicMock, patch
  import torch
  from mmf.utils.general import clip_gradients
  from pytorch_lightning.callbacks.base import Callback
  from tests.trainers.test_utils import get_config_with_defaults, get_lightning_trainer, get_mmf_trainer
label_desc: Use image node_id 3 for calling the TestLightningTrainerGradClipping obj's underlying member method code with example usage: obj.on_before_optimizer_step(trainer, pl_module, optimizer, optimizer_idx) without return types