class_docstr: This is an abstract base class.
  Don't inherit from unittest.TestCase, and don't name it 'Test*'.
  Do, however, do these things in classes which inherit from this.
code: def _gradient_ratio_reference(self, model, params, max_gradient_norm):
      from caffe2.python import core
  
      sum_squared_norms = 0.0
      for param in params:
          grad = (
              model.param_to_grad[param]
              if not isinstance(
                  model.param_to_grad[param],
                  core.GradientSlice,
              )
              else model.param_to_grad[param].values
          )
          val = workspace.FetchBlob(grad)
          sum_squared_norms += np.power(np.linalg.norm(val), 2.0)
      global_norm = np.sqrt(sum_squared_norms)
      clip_norm = max_gradient_norm
      norm_ratio = clip_norm / np.maximum(clip_norm, global_norm)
      return norm_ratio
  
file_path: pytorch/caffe2/python/optimizer_test_util.py
imports: import unittest
  import numpy
  from caffe2.python import brew, core, workspace, cnn, optimizer
  from caffe2.python.modeling.initializers import Initializer, PseudoFP16Initializer
  from caffe2.python.model_helper import ModelHelper
label_desc: Use image node_id 1 for calling the LRModificationTestBase obj's underlying member method code with example usage: obj._gradient_ratio_reference(model, params, max_gradient_norm) and returns: norm_ratio